Changeset a3b1c790


Ignore:
Timestamp:
Nov 4, 2009 4:06:46 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
413ab6d7
Parents:
5190b2d (diff), 5a7d3ba4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge of '0d58ec9e2b160029e92a584b0c707ffdf4f25c7e'

and 'd4e270a4df0c8134d7bac1585e30ef8ddef37f85'

Files:
17 edited
8 moved

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigRestartBean.java

    r5190b2d ra3b1c790  
    3434                //ctx.router().shutdown(Router.EXIT_HARD); // never returns
    3535                ctx.router().shutdownGracefully(Router.EXIT_HARD); // give the UI time to respond
    36             } else if ("cancelShutdown".equals(action) || _("Cancel shutdown", ctx).equals(action)) {
     36            } else if ("cancelShutdown".equals(action) || _("Cancel shutdown", ctx).equals(action) ||
     37                       _("Cancel restart", ctx).equals(action)) {
    3738                ctx.router().cancelGracefulShutdown();
    3839            } else if ("restartImmediate".equals(action) || _("Restart immediately", ctx).equals(action)) {
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigUIHelper.java

    r5190b2d ra3b1c790  
    3838
    3939    private static final String langs[] = {"de", "en", "fr", "nl", "se", "zh"};
     40    private static final String flags[] = {"de", "us", "fr", "nl", "se", "cn"};
    4041    private static final String xlangs[] = {_x("German"), _x("English"), _x("French"),
    4142                                            _x("Dutch"), _x("Swedish"), _x("Chinese")};
     
    5051            if (langs[i].equals(current))
    5152                buf.append("checked=\"true\" ");
    52             buf.append("value=\"").append(langs[i]).append("\">").append(_(xlangs[i])).append("<br>\n");
     53            buf.append("value=\"").append(langs[i]).append("\">")
     54               .append("<img height=\"11\" width=\"16\" alt=\"\" src=\"/flags.jsp?c=").append(flags[i]).append("\"> ")
     55               .append(_(xlangs[i])).append("<br>\n");
    5356        }
    5457        return buf.toString();
  • apps/routerconsole/java/src/net/i2p/router/web/NetDbRenderer.java

    r5190b2d ra3b1c790  
    8585        StringBuilder buf = new StringBuilder(4*1024);
    8686        buf.append("<h2>" + _("Network Database Contents") + "</h2>\n");
    87         buf.append("<a href=\"netdb.jsp\">" + _("View") + " RouterInfo</a>");
    88         buf.append("<h3>LeaseSets</h3>\n");
     87        buf.append("<a href=\"netdb.jsp\">" + _("View RouterInfo") + "</a>");
     88        buf.append("<h3>").append(_("LeaseSets")).append("</h3>\n");
    8989        Set leases = new TreeSet(new LeaseSetComparator());
    9090        leases.addAll(_context.netDb().getLeases());
     
    133133
    134134    public void renderStatusHTML(Writer out, boolean full) throws IOException {
    135         out.write("<h2>" + _("Network Database Contents") + " (<a href=\"netdb.jsp?l=1\">" + _("View") + " LeaseSets</a>)</h2>\n");
     135        out.write("<h2>" + _("Network Database Contents") + " (<a href=\"netdb.jsp?l=1\">" + _("View LeaseSets") + "</a>)</h2>\n");
    136136        if (!_context.netDb().isInitialized()) {
    137137            out.write(_("Not initialized"));
     
    245245        for (Iterator iter = info.getAddresses().iterator(); iter.hasNext(); ) {
    246246            RouterAddress addr = (RouterAddress)iter.next();
    247             buf.append(DataHelper.stripHTML(addr.getTransportStyle())).append(": ");
     247            buf.append("<b>").append(DataHelper.stripHTML(addr.getTransportStyle())).append("</b>: ");
    248248            for (Iterator optIter = addr.getOptions().keySet().iterator(); optIter.hasNext(); ) {
    249249                String name = (String)optIter.next();
  • apps/routerconsole/java/src/net/i2p/router/web/ProfileOrganizerRenderer.java

    r5190b2d ra3b1c790  
    106106            buf.append("<tr><td align=\"center\" nowrap>");
    107107            buf.append(_context.commSystem().renderPeerHTML(peer));
     108            // debug
     109            //if(prof.getIsExpandedDB())
     110            //   buf.append(" ** ");
    108111            buf.append("</td><td align=\"center\">");
    109112           
     
    146149            buf.append("</td><td align=\"center\">");
    147150            if (_context.shitlist().isShitlisted(peer)) buf.append(_("Banned"));
    148             if (prof.getIsFailing()) buf.append(" ").append(_("Failing"));
    149             if (_context.commSystem().wasUnreachable(peer)) buf.append(" ").append(_("Unreachable"));
     151            if (prof.getIsFailing()) buf.append(' ').append(_("Failing"));
     152            if (_context.commSystem().wasUnreachable(peer)) buf.append(' ').append(_("Unreachable"));
    150153            Rate failed = prof.getTunnelHistory().getFailedRate().getRate(30*60*1000);
    151154            long fails = failed.getCurrentEventCount() + failed.getLastEventCount();
     
    154157                long total = fails + accepted.getCurrentEventCount() + accepted.getLastEventCount();
    155158                if (total / fails <= 10)   // hide if < 10%
    156                     buf.append(' ').append(fails).append('/').append(total).append(" ").append(_("Test Fails"));
     159                    buf.append(' ').append(fails).append('/').append(total).append(' ').append(_("Test Fails"));
    157160            }
    158161            buf.append("&nbsp;</td>");
    159             buf.append("<td nowrap align=\"center\"><a target=\"_blank\" href=\"dumpprofile.jsp?peer=").append(peer.toBase64().substring(0,6)).append("\">profile</a>");
     162            buf.append("<td nowrap align=\"center\"><a target=\"_blank\" href=\"dumpprofile.jsp?peer=")
     163               .append(peer.toBase64().substring(0,6)).append("\">").append(_("profile")).append("</a>");
    160164            buf.append("&nbsp;<a href=\"configpeer.jsp?peer=").append(peer.toBase64()).append("\">+-</a></td>\n");
    161165            buf.append("</tr>");
     
    224228                buf.append("<td align=\"right\">").append(davg(dbh, 60*60*1000l)).append("</td>");
    225229                buf.append("<td align=\"right\">").append(davg(dbh, 24*60*60*1000l)).append("</td>");
     230            } else {
     231                for (int i = 0; i < 6; i++)
     232                    buf.append("<td align=\"right\">").append(_(NA));
    226233            }
    227234        }
     
    229236
    230237        buf.append("<h3>").append(_("Thresholds:")).append("</h3>");
    231         buf.append("<p><b>").append(_("Speed")).append(":</b> ").append(num(_organizer.getSpeedThreshold())).append(" (").append(fast).append(" fast peers)<br>");
    232         buf.append("<b>").append(_("Capacity")).append(":</b> ").append(num(_organizer.getCapacityThreshold())).append(" (").append(reliable).append(" high capacity peers)<br>");
    233         buf.append("<b>").append(_("Integration")).append(":</b> ").append(num(_organizer.getIntegrationThreshold())).append(" (").append(integrated).append(" well integrated peers)</p>");
     238        buf.append("<p><b>").append(_("Speed")).append(":</b> ").append(num(_organizer.getSpeedThreshold()))
     239           .append(" (").append(fast).append(' ').append(_("fast peers")).append(")<br>");
     240        buf.append("<b>").append(_("Capacity")).append(":</b> ").append(num(_organizer.getCapacityThreshold()))
     241           .append(" (").append(reliable).append(' ').append(_("high capacity peers")).append(")<br>");
     242        buf.append("<b>").append(_("Integration")).append(":</b> ").append(num(_organizer.getIntegrationThreshold()))
     243           .append(" (").append(integrated).append(' ').append(_(" well integrated peers")).append(")</p>");
    234244        buf.append("<h3>").append(_("Definitions")).append(":</h3><ul>");
    235245                   buf.append("<li><b>").append(_("groups")).append("</b>: ").append(_("as determined by the profile organizer")).append("</li>");
     
    296306    private final static DecimalFormat _fmt = new DecimalFormat("###,##0.00");
    297307    private final static String num(double num) { synchronized (_fmt) { return _fmt.format(num); } }
    298     private final static String na = "n/a";
    299 
    300     private static String avg (PeerProfile prof, long rate) {
     308    private final static String NA = HelperBase._x("n/a");
     309
     310    private String avg (PeerProfile prof, long rate) {
    301311            RateStat rs = prof.getDbResponseTime();
    302312            if (rs == null)
    303                 return na;
     313                return _(NA);
    304314            Rate r = rs.getRate(rate);
    305315            if (r == null)
    306                 return na;
     316                return _(NA);
    307317            long c = r.getCurrentEventCount() + r.getLastEventCount();
    308318            if (c == 0)
    309                 return na;
     319                return _(NA);
    310320            double d = r.getCurrentTotalValue() + r.getLastTotalValue();
    311321            return Math.round(d/c) + "ms";
    312322    }
    313323
    314     private static String davg (DBHistory dbh, long rate) {
     324    private String davg (DBHistory dbh, long rate) {
    315325            RateStat rs = dbh.getFailedLookupRate();
    316326            if (rs == null)
    317                 return na;
     327                return _(NA);
    318328            Rate r = rs.getRate(rate);
    319329            if (r == null)
    320                 return na;
     330                return _(NA);
    321331            long c = r.getCurrentEventCount() + r.getLastEventCount();
    322332            return "" + c;
  • apps/routerconsole/jsp/config.jsp

    r5190b2d ra3b1c790  
    105105    <% String[] ips = nethelper.getAddresses();
    106106       if (ips.length > 0) {
    107            out.print(" " + intl._("or") + " <select name=\"udpHost2\"><option value=\"\" selected=\"true\">"+intl._("Select Interface")+"</option>\n");
     107           out.print(intl._("or") + " <select name=\"udpHost2\"><option value=\"\" selected=\"true\">"+intl._("Select Interface")+"</option>\n");
    108108           for (int i = 0; i < ips.length; i++) {
    109109               out.print("<option value=\"");
     
    157157 <input type="submit" name="save" value="<%=intl._("Save changes")%>" /> <input type="reset" value="<%=intl._("Cancel")%>" />
    158158</div><h3><a name="chelp"><%=intl._("Configuration Help")%>:</a></h3><div align="justify"><p>
    159  <%=intl._("While I2P will work fine behind most firewalls, your speeds and network integration will generally improve if the I2P port (generally 8887) is forwarded for both UDP and TCP.")%>
     159 <%=intl._("While I2P will work fine behind most firewalls, your speeds and network integration will generally improve if the I2P port is forwarded for both UDP and TCP.")%>
    160160 </p><p>
    161161 <%=intl._("If you can, please poke a hole in your firewall to allow unsolicited UDP and TCP packets to reach you.")%>
     
    188188</p>
    189189<h3><a name="help"><%=intl._("Reachability Help")%>:</a></h3><p>
    190  <%=intl._("While I2P will work fine behind most firewalls, your speeds and network integration will generally improve if the I2P port (generally 8887) is forwarded for both UDP and TCP.")%>
     190 <%=intl._("While I2P will work fine behind most firewalls, your speeds and network integration will generally improve if the I2P port is forwarded for both UDP and TCP.")%>
    191191 <%=intl._("If you think you have opened up your firewall and I2P still thinks you are firewalled, remember that you may have multiple firewalls, for example both software packages and external hardware routers.")%>
    192192 <%=intl._("If there is an error, the <a href=\"logs.jsp\">logs</a> may also help diagnose the problem.")%>
     
    197197     <%=intl._("Your UDP port appears to be firewalled.")%>
    198198     <%=intl._("As the firewall detection methods are not 100% reliable, this may occasionally be displayed in error.")%>
    199      <%=intl._("However, if it appears consistently, you should check whether both your external and internal firewalls are open on port 8887.")%>
     199     <%=intl._("However, if it appears consistently, you should check whether both your external and internal firewalls are open for your port.")%>
    200200     <%=intl._("I2P will work fine when firewalled, there is no reason for concern. When firewalled, the router uses \"introducers\" to relay inbound connections.")%>
    201201     <%=intl._("However, you will get more participating traffic and help the network more if you can open your firewall(s).")%>
     
    231231<li class="tidylist"><b><%=intl._("ERR - UDP Port In Use - Set i2np.udp.internalPort=xxxx in advanced config and restart")%></b> -
    232232     <%=intl._("I2P was unable to bind to port 8887 or other configured port.")%>
    233      <%=intl._("Check to see if another program is using port 8887. If so, stop that program or configure I2P to use a different port.")%>
     233     <%=intl._("Check to see if another program is using the configured port. If so, stop that program or configure I2P to use a different port.")%>
    234234     <%=intl._("This may be a transient error, if the other program is no longer using the port.")%>
    235235     <%=intl._("However, a restart is always required after this error.")%>
  • build.xml

    r5190b2d ra3b1c790  
    292292             and uncomment the following -->
    293293        <!-- <copy file="installer/resources/toolbar.html" todir="pkg-temp/docs/" /> -->
    294         <copy file="initialNews.xml" tofile="pkg-temp/docs/news.xml" />
     294        <!-- overwrite the news put in by the updater -->
     295        <copy file="installer/resources/initialNews.xml" tofile="pkg-temp/docs/news.xml" overwrite="true" />
    295296        <copy file="installer/resources/startconsole.html" todir="pkg-temp/docs/" />
    296297        <copy file="installer/resources/start.ico" todir="pkg-temp/docs/" />
     
    352353        </copy>         
    353354        <copy todir="pkg-temp/docs/" >
    354           <fileset dir="." includes="readme*.html" />
     355          <fileset dir="installer/resources/readme/" includes="readme*.html" />
    355356        </copy>
    356357    </target>
     
    399400        <copy file="build/i2psnark.war" todir="pkg-temp/webapps/" />
    400401        <copy file="history.txt" todir="pkg-temp/" />
    401         <copy file="news.xml" todir="pkg-temp/docs/" />
     402        <!-- may be pointless now, people with split directories will never see this -->
     403        <copy file="installer/resources/news.xml" todir="pkg-temp/docs/" />
    402404    </target>
    403405    <target name="prepupdateSmall" depends="buildSmall, prepupdateRouter, prepthemeupdates">
     
    575577            <arg value="-l" />
    576578            <arg value="history.txt" />
    577             <arg value="initialNews.xml" />
     579            <arg value="installer/resources/initialNews.xml" />
    578580            <arg value="installer/install.xml" />
    579             <arg value="news.xml" />
     581            <arg value="installer/resources/news.xml" />
    580582            <arg value="core/java/src/net/i2p/CoreVersion.java" />
    581583            <arg value="router/java/src/net/i2p/router/RouterVersion.java" />
  • installer/resources/initialNews.xml

    r5190b2d ra3b1c790  
    99<li>
    1010While you are waiting, please <b>adjust your bandwidth settings</b> on the
    11 <a href="config.jsp">configuration page</a>.
    12 </li>
    13 <li>
    14 If you can, open up <b>port 8887</b> on your firewall, then <b>enable inbound TCP</b> on the
    1511<a href="config.jsp">configuration page</a>.
    1612</li>
     
    3632</li>
    3733<li>
    38 Bitte &ouml;ffne sobald m&ouml;glich  den <b>Port 8887</b> in deiner Firewall, aktiviere danach den <b>eingehenden TCP Verkehr</b> auf der <a href="config.jsp">Einstellungsseite</a>.
    39 </li>
    40 <li>
    4134Sobald auf der linken Seite eine "shared clients" Verbindung aufgelistet ist <b>besuche bitte</b> unsere <a href="http://www.i2p2.i2p/faq_de.html">FAQ</a>.
    4235</li>
  • router/java/src/net/i2p/router/RouterThrottleImpl.java

    r5190b2d ra3b1c790  
    3535    private static final String PROP_DEFAULT_KBPS_THROTTLE = "router.defaultKBpsThrottle";
    3636    private static final String PROP_MAX_PROCESSINGTIME = "router.defaultProcessingTimeThrottle";
    37     private static final int DEFAULT_MAX_PROCESSINGTIME = 1500;
     37    private static final int DEFAULT_MAX_PROCESSINGTIME = 1250;
    3838
    3939    /** tunnel acceptance */
     
    138138                            + " ms over the last two minutes, which is too much.");
    139139                }
    140                 setTunnelStatus("Rejecting tunnels: congestion");
     140                setTunnelStatus("Rejecting tunnels: High message delay");
    141141                return TunnelHistory.TUNNEL_REJECT_BANDWIDTH;
    142142            }
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    r5190b2d ra3b1c790  
    660660        long now = _context.clock().now();
    661661        boolean upLongEnough = _context.router().getUptime() > 60*60*1000;
    662         // Once we're over 150 routers, reduce the expiration time down from the default,
     662        // Once we're over 120 routers, reduce the expiration time down from the default,
    663663        // as a crude way of limiting memory usage.
    664664        // i.e. at 300 routers the expiration time will be about half the default, etc.
     
    674674            adjustedExpiration = Math.min(ROUTER_INFO_EXPIRATION,
    675675                                          ROUTER_INFO_EXPIRATION_MIN +
    676                                           ((ROUTER_INFO_EXPIRATION - ROUTER_INFO_EXPIRATION_MIN) * 150 / (_kb.size() + 1)));
     676                                          ((ROUTER_INFO_EXPIRATION - ROUTER_INFO_EXPIRATION_MIN) * 120 / (_kb.size() + 1)));
    677677
    678678        if (!key.equals(routerInfo.getIdentity().getHash())) {
     
    892892        PeerProfile prof = _context.profileOrganizer().getProfile(peer);
    893893        double responseTime = MAX_PER_PEER_TIMEOUT;
    894         if (prof != null)
     894        if (prof != null && prof.getIsExpandedDB()) {
    895895            responseTime = prof.getDbResponseTime().getLifetimeAverageValue();
    896         if (responseTime < MIN_PER_PEER_TIMEOUT)
    897             responseTime = MIN_PER_PEER_TIMEOUT;
    898         else if (responseTime > MAX_PER_PEER_TIMEOUT)
    899             responseTime = MAX_PER_PEER_TIMEOUT;
     896            if (responseTime < MIN_PER_PEER_TIMEOUT)
     897                responseTime = MIN_PER_PEER_TIMEOUT;
     898            else if (responseTime > MAX_PER_PEER_TIMEOUT)
     899                responseTime = MAX_PER_PEER_TIMEOUT;
     900        }
    900901        return 4 * (int)responseTime;  // give it up to 4x the average response time
    901902    }
  • router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java

    r5190b2d ra3b1c790  
    175175                } else {
    176176                    int peerTimeout = _facade.getPeerTimeout(peer);
    177                     PeerProfile prof = getContext().profileOrganizer().getProfile(peer);
    178                     if (prof != null) {
    179                         RateStat failing = prof.getDBHistory().getFailedLookupRate();
    180                         Rate failed = failing.getRate(60*60*1000);
    181                     }
     177
     178                    //PeerProfile prof = getContext().profileOrganizer().getProfile(peer);
     179                    //if (prof != null && prof.getIsExpandedDB()) {
     180                    //    RateStat failing = prof.getDBHistory().getFailedLookupRate();
     181                    //    Rate failed = failing.getRate(60*60*1000);
     182                    //}
     183
    182184                    //long failedCount = failed.getCurrentEventCount()+failed.getLastEventCount();
    183185                    //if (failedCount > 10) {
  • router/java/src/net/i2p/router/peermanager/IntegrationCalculator.java

    r5190b2d ra3b1c790  
    2020    @Override
    2121    public double calc(PeerProfile profile) {
    22         // give more weight to recent counts
    23         long val = profile.getDbIntroduction().getRate(24*60*60*1000l).getCurrentEventCount();
    24         val += 2 * 4 * profile.getDbIntroduction().getRate(6*60*60*1000l).getLastEventCount();
    25         val += 3 * 4 * profile.getDbIntroduction().getRate(6*60*60*1000l).getCurrentEventCount();
    26         val += 4 * 24 * profile.getDbIntroduction().getRate(60*60*1000l).getCurrentEventCount();
    27         val /= 10;
     22        long val = 0;
     23        if (profile.getIsExpandedDB()) {
     24            // give more weight to recent counts
     25            val = profile.getDbIntroduction().getRate(24*60*60*1000l).getCurrentEventCount();
     26            val += 2 * 4 * profile.getDbIntroduction().getRate(6*60*60*1000l).getLastEventCount();
     27            val += 3 * 4 * profile.getDbIntroduction().getRate(6*60*60*1000l).getCurrentEventCount();
     28            val += 4 * 24 * profile.getDbIntroduction().getRate(60*60*1000l).getCurrentEventCount();
     29            val /= 10;
     30        }
    2831        val += profile.getIntegrationBonus();
    2932        return val;
  • router/java/src/net/i2p/router/peermanager/PeerProfile.java

    r5190b2d ra3b1c790  
    3737    private double _tunnelTestResponseTimeAvg;
    3838    // periodic rates
    39     private RateStat _sendSuccessSize = null;
    40     private RateStat _receiveSize = null;
     39    //private RateStat _sendSuccessSize = null;
     40    //private RateStat _receiveSize = null;
    4141    private RateStat _dbResponseTime = null;
    4242    private RateStat _tunnelCreateResponseTime = null;
     
    5757    // does this peer profile contain expanded data, or just the basics?
    5858    private boolean _expanded;
     59    private boolean _expandedDB;
    5960    private int _consecutiveShitlists;
    6061   
     
    7374        _tunnelTestResponseTimeAvg = 0.0d;
    7475        _peer = peer;
     76        // this is always true, and there are several places in the router that will NPE
     77        // if it is false, so all need to be fixed before we can have non-expanded profiles
    7578        if (expand)
    7679            expandProfile();
     
    8891     */
    8992    public boolean getIsExpanded() { return _expanded; }
     93    public boolean getIsExpandedDB() { return _expandedDB; }
    9094   
    9195    public int incrementShitlists() { return _consecutiveShitlists++; }
     
    108112     * Note: this appears to be the only use for these two RateStats.
    109113     *
     114     * Update: Rewritten so we can get rid of the two RateStats.
     115     *         This also helps by not having it depend on coalesce boundaries.
     116     *
    110117     * @param period must be one of the periods in the RateStat constructors below
    111118     *        (5*60*1000 or 60*60*1000)
    112119     */
    113120    public boolean getIsActive(long period) {
    114         if ( (getSendSuccessSize().getRate(period).getCurrentEventCount() > 0) ||
    115              (getSendSuccessSize().getRate(period).getLastEventCount() > 0) ||
    116              (getReceiveSize().getRate(period).getCurrentEventCount() > 0) ||
    117              (getReceiveSize().getRate(period).getLastEventCount() > 0) ||
    118              _context.commSystem().isEstablished(_peer) )
    119             return true;
    120         else
    121             return false;
     121        //if ( (getSendSuccessSize().getRate(period).getCurrentEventCount() > 0) ||
     122        //     (getSendSuccessSize().getRate(period).getLastEventCount() > 0) ||
     123        //     (getReceiveSize().getRate(period).getCurrentEventCount() > 0) ||
     124        //     (getReceiveSize().getRate(period).getLastEventCount() > 0) ||
     125        //     _context.commSystem().isEstablished(_peer) )
     126        //    return true;
     127        //else
     128        //    return false;
     129        long before = _context.clock().now() - period;
     130        return getLastHeardFrom() < before ||
     131               getLastSendSuccessful() < before ||
     132             _context.commSystem().isEstablished(_peer);
    122133    }
    123134   
     
    143154    public void setLastHeardFrom(long when) { _lastHeardFrom = when; }
    144155   
    145     /** history of tunnel activity with the peer */
     156    /** history of tunnel activity with the peer
     157        Warning - may return null if !getIsExpanded() */
    146158    public TunnelHistory getTunnelHistory() { return _tunnelHistory; }
    147159    public void setTunnelHistory(TunnelHistory history) { _tunnelHistory = history; }
    148160   
    149     /** history of db activity with the peer */
     161    /** history of db activity with the peer
     162        Warning - may return null if !getIsExpandedDB() */
    150163    public DBHistory getDBHistory() { return _dbHistory; }
    151164    public void setDBHistory(DBHistory hist) { _dbHistory = hist; }
    152165   
    153166    /** how large successfully sent messages are, calculated over a 1 minute, 1 hour, and 1 day period */
    154     public RateStat getSendSuccessSize() { return _sendSuccessSize; }
     167    //public RateStat getSendSuccessSize() { return _sendSuccessSize; }
    155168    /** how large received messages are, calculated over a 1 minute, 1 hour, and 1 day period */
    156     public RateStat getReceiveSize() { return _receiveSize; }
    157     /** how long it takes to get a db response from the peer (in milliseconds), calculated over a 1 minute, 1 hour, and 1 day period */
     169    //public RateStat getReceiveSize() { return _receiveSize; }
     170    /** how long it takes to get a db response from the peer (in milliseconds), calculated over a 1 minute, 1 hour, and 1 day period
     171        Warning - may return null if !getIsExpandedDB() */
    158172    public RateStat getDbResponseTime() { return _dbResponseTime; }
    159     /** how long it takes to get a tunnel create response from the peer (in milliseconds), calculated over a 1 minute, 1 hour, and 1 day period */
     173    /** how long it takes to get a tunnel create response from the peer (in milliseconds), calculated over a 1 minute, 1 hour, and 1 day period
     174        Warning - may return null if !getIsExpanded() */
    160175    public RateStat getTunnelCreateResponseTime() { return _tunnelCreateResponseTime; }
    161     /** how long it takes to successfully test a tunnel this peer participates in (in milliseconds), calculated over a 10 minute, 1 hour, and 1 day period */
     176    /** how long it takes to successfully test a tunnel this peer participates in (in milliseconds), calculated over a 10 minute, 1 hour, and 1 day period
     177        Warning - may return null if !getIsExpanded() */
    162178    public RateStat getTunnelTestResponseTime() { return _tunnelTestResponseTime; }
    163     /** how many new peers we get from dbSearchReplyMessages or dbStore messages, calculated over a 1 hour, 1 day, and 1 week period */
     179    /** how many new peers we get from dbSearchReplyMessages or dbStore messages, calculated over a 1 hour, 1 day, and 1 week period
     180        Warning - may return null if !getIsExpandedDB() */
    164181    public RateStat getDbIntroduction() { return _dbIntroduction; }
    165182   
     
    328345     * this drops the rates, the tunnelHistory, and the dbHistory.
    329346     *
    330      */
     347     * UNUSED for now, will cause NPEs elsewhere
     348     */
     349/*****
    331350    public void shrinkProfile() {
    332         _sendSuccessSize = null;
    333         _receiveSize = null;
     351        //_sendSuccessSize = null;
     352        //_receiveSize = null;
    334353        _dbResponseTime = null;
    335354        _tunnelCreateResponseTime = null;
     
    340359       
    341360        _expanded = false;
    342     }
     361        _expandedDB = false;
     362    }
     363******/
    343364   
    344365    /**
     
    351372    public void expandProfile() {
    352373        String group = (null == _peer ? "profileUnknown" : _peer.toBase64().substring(0,6));
    353         if (_sendSuccessSize == null)
    354             _sendSuccessSize = new RateStat("sendSuccessSize", "How large successfully sent messages are", group, new long[] { 5*60*1000l, 60*60*1000l });
    355         if (_receiveSize == null)
    356             _receiveSize = new RateStat("receiveSize", "How large received messages are", group, new long[] { 5*60*1000l, 60*60*1000l } );
    357         if (_dbResponseTime == null)
    358             _dbResponseTime = new RateStat("dbResponseTime", "how long it takes to get a db response from the peer (in milliseconds)", group, new long[] { 10*60*1000l, 60*60*1000l, 24*60*60*1000 } );
     374        //if (_sendSuccessSize == null)
     375        //    _sendSuccessSize = new RateStat("sendSuccessSize", "How large successfully sent messages are", group, new long[] { 5*60*1000l, 60*60*1000l });
     376        //if (_receiveSize == null)
     377        //    _receiveSize = new RateStat("receiveSize", "How large received messages are", group, new long[] { 5*60*1000l, 60*60*1000l } );
    359378        if (_tunnelCreateResponseTime == null)
    360379            _tunnelCreateResponseTime = new RateStat("tunnelCreateResponseTime", "how long it takes to get a tunnel create response from the peer (in milliseconds)", group, new long[] { 10*60*1000l, 30*60*1000l, 60*60*1000l, 24*60*60*1000 } );
    361380        if (_tunnelTestResponseTime == null)
    362381            _tunnelTestResponseTime = new RateStat("tunnelTestResponseTime", "how long it takes to successfully test a tunnel this peer participates in (in milliseconds)", group, new long[] { 10*60*1000l, 30*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000 } );
     382
     383        if (_tunnelHistory == null)
     384            _tunnelHistory = new TunnelHistory(_context, group);
     385
     386        //_sendSuccessSize.setStatLog(_context.statManager().getStatLog());
     387        //_receiveSize.setStatLog(_context.statManager().getStatLog());
     388        _tunnelCreateResponseTime.setStatLog(_context.statManager().getStatLog());
     389        _tunnelTestResponseTime.setStatLog(_context.statManager().getStatLog());
     390        _expanded = true;
     391    }
     392
     393    /**
     394     * For floodfills
     395     */
     396    public synchronized void expandDBProfile() {
     397        String group = (null == _peer ? "profileUnknown" : _peer.toBase64().substring(0,6));
     398        if (_dbResponseTime == null)
     399            _dbResponseTime = new RateStat("dbResponseTime", "how long it takes to get a db response from the peer (in milliseconds)", group, new long[] { 10*60*1000l, 60*60*1000l, 24*60*60*1000 } );
    363400        if (_dbIntroduction == null)
    364401            _dbIntroduction = new RateStat("dbIntroduction", "how many new peers we get from dbSearchReplyMessages or dbStore messages", group, new long[] { 60*60*1000l, 6*60*60*1000l, 24*60*60*1000l });
    365402
    366         if (_tunnelHistory == null)
    367             _tunnelHistory = new TunnelHistory(_context, group);
    368403        if (_dbHistory == null)
    369404            _dbHistory = new DBHistory(_context, group);
    370405
    371         _sendSuccessSize.setStatLog(_context.statManager().getStatLog());
    372         _receiveSize.setStatLog(_context.statManager().getStatLog());
    373406        _dbResponseTime.setStatLog(_context.statManager().getStatLog());
    374         _tunnelCreateResponseTime.setStatLog(_context.statManager().getStatLog());
    375         _tunnelTestResponseTime.setStatLog(_context.statManager().getStatLog());
    376407        _dbIntroduction.setStatLog(_context.statManager().getStatLog());
    377         _expanded = true;
    378     }
     408        _expandedDB = true;
     409    }
     410
    379411    /** once a day, on average, cut the measured throughtput values in half */
    380412    /** let's try once an hour times 3/4 */
     
    420452    public void coalesceStats() {
    421453        if (!_expanded) return;
    422         _dbIntroduction.coalesceStats();
    423         _dbResponseTime.coalesceStats();
    424         _receiveSize.coalesceStats();
    425         _sendSuccessSize.coalesceStats();
     454        //_receiveSize.coalesceStats();
     455        //_sendSuccessSize.coalesceStats();
    426456        _tunnelCreateResponseTime.coalesceStats();
    427457        _tunnelTestResponseTime.coalesceStats();
    428         _dbHistory.coalesceStats();
    429458        _tunnelHistory.coalesceStats();
     459        if (_expandedDB) {
     460            _dbIntroduction.coalesceStats();
     461            _dbResponseTime.coalesceStats();
     462            _dbHistory.coalesceStats();
     463        }
    430464       
    431465        coalesceThroughput();
  • router/java/src/net/i2p/router/peermanager/ProfileManagerImpl.java

    r5190b2d ra3b1c790  
    4040        if (data == null) return;
    4141        data.setLastSendSuccessful(_context.clock().now());
    42         data.getSendSuccessSize().addData(bytesSent, msToSend);
     42        //data.getSendSuccessSize().addData(bytesSent, msToSend);
    4343    }
    4444   
     
    170170     * Note that the peer was able to return the valid data for a db lookup
    171171     *
     172     * This will force creation of DB stats
    172173     */
    173174    public void dbLookupSuccessful(Hash peer, long responseTimeMs) {
     
    175176        if (data == null) return;
    176177        data.setLastHeardFrom(_context.clock().now());
     178        if (!data.getIsExpandedDB())
     179            data.expandDBProfile();
    177180        data.getDbResponseTime().addData(responseTimeMs, responseTimeMs);
    178181        DBHistory hist = data.getDBHistory();
     
    184187     * a lookupReply redirecting the user elsewhere
    185188     *
     189     * This will force creation of DB stats
    186190     */
    187191    public void dbLookupFailed(Hash peer) {
    188192        PeerProfile data = getProfile(peer);
    189193        if (data == null) return;
     194        if (!data.getIsExpandedDB())
     195            data.expandDBProfile();
    190196        DBHistory hist = data.getDBHistory();
    191197        hist.lookupFailed();
     
    204210        if (data == null) return;
    205211        data.setLastHeardFrom(_context.clock().now());
     212        if (!data.getIsExpandedDB())
     213            return;
    206214        data.getDbResponseTime().addData(responseTimeMs, responseTimeMs);
    207215        data.getDbIntroduction().addData(newPeers, responseTimeMs);
     
    218226        if (data == null) return;
    219227        data.setLastHeardFrom(_context.clock().now());
     228        if (!data.getIsExpandedDB())
     229            return;
    220230        DBHistory hist = data.getDBHistory();
    221231        hist.lookupReceived();
     
    230240        if (data == null) return;
    231241        data.setLastHeardFrom(_context.clock().now());
     242        if (!data.getIsExpandedDB())
     243            return;
    232244        DBHistory hist = data.getDBHistory();
    233245        hist.unpromptedStoreReceived(wasNewKey);
     
    243255        if (data == null) return;
    244256        long now = _context.clock().now();
     257        data.setLastHeardFrom(now);
     258        if (!data.getIsExpandedDB())
     259            return;
    245260        data.setLastSendSuccessful(now);
    246         data.setLastHeardFrom(now);
    247261        // we could do things like update some sort of "how many successful stores we've sent them"...
    248262        // naah.. dont really care now
     
    280294        if (data == null) return;
    281295        data.setLastHeardFrom(_context.clock().now());
    282         data.getReceiveSize().addData(bytesRead, msToReceive);
     296        //data.getReceiveSize().addData(bytesRead, msToReceive);
    283297    }
    284298   
  • router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java

    r5190b2d ra3b1c790  
    242242    public boolean peerSendsBadReplies(Hash peer) {
    243243        PeerProfile profile = getProfile(peer);
    244         if (profile != null) {
     244        if (profile != null && profile.getIsExpandedDB()) {
    245245            RateStat invalidReplyRateStat = profile.getDBHistory().getInvalidReplyRate();
    246246            Rate invalidReplyRate = invalidReplyRateStat.getRate(30*60*1000l);
  • router/java/src/net/i2p/router/peermanager/ProfilePersistenceHelper.java

    r5190b2d ra3b1c790  
    129129        out.write(buf.toString().getBytes());
    130130       
    131         profile.getTunnelHistory().store(out);
    132         profile.getDBHistory().store(out);
    133        
    134131        if (profile.getIsExpanded()) {
    135132            // only write out expanded data if, uh, we've got it
     133            profile.getTunnelHistory().store(out);
     134            //profile.getReceiveSize().store(out, "receiveSize");
     135            //profile.getSendSuccessSize().store(out, "sendSuccessSize");
     136            profile.getTunnelCreateResponseTime().store(out, "tunnelCreateResponseTime");
     137            profile.getTunnelTestResponseTime().store(out, "tunnelTestResponseTime");
     138        }
     139
     140        if (profile.getIsExpandedDB()) {
     141            profile.getDBHistory().store(out);
    136142            profile.getDbIntroduction().store(out, "dbIntroduction");
    137143            profile.getDbResponseTime().store(out, "dbResponseTime");
    138             profile.getReceiveSize().store(out, "receiveSize");
    139             profile.getSendSuccessSize().store(out, "sendSuccessSize");
    140             profile.getTunnelCreateResponseTime().store(out, "tunnelCreateResponseTime");
    141             profile.getTunnelTestResponseTime().store(out, "tunnelTestResponseTime");
    142144        }
    143145    }
     
    212214           
    213215            profile.getTunnelHistory().load(props);
    214             profile.getDBHistory().load(props);
    215            
    216             profile.getDbIntroduction().load(props, "dbIntroduction", true);
    217             profile.getDbResponseTime().load(props, "dbResponseTime", true);
    218             profile.getReceiveSize().load(props, "receiveSize", true);
    219             profile.getSendSuccessSize().load(props, "sendSuccessSize", true);
     216
     217            // In the interest of keeping the in-memory profiles small,
     218            // don't load the DB info at all unless there is something interesting there
     219            // (i.e. floodfills)
     220            // It seems like we do one or two lookups as a part of handshaking?
     221            // Not sure, to be researched.
     222            if (getLong(props, "dbHistory.successfulLookups") > 1 ||
     223                getLong(props, "dbHistory.failedlLokups") > 1) {
     224                profile.expandDBProfile();
     225                profile.getDBHistory().load(props);
     226                profile.getDbIntroduction().load(props, "dbIntroduction", true);
     227                profile.getDbResponseTime().load(props, "dbResponseTime", true);
     228            }
     229
     230            //profile.getReceiveSize().load(props, "receiveSize", true);
     231            //profile.getSendSuccessSize().load(props, "sendSuccessSize", true);
    220232            profile.getTunnelCreateResponseTime().load(props, "tunnelCreateResponseTime", true);
    221233            profile.getTunnelTestResponseTime().load(props, "tunnelTestResponseTime", true);
  • router/java/src/net/i2p/router/transport/UPnP.java

    r5190b2d ra3b1c790  
    637637
    638638                public void run() {
     639                        HashMap<ForwardPort, ForwardPortStatus> map = new HashMap(1);
    639640                        for(ForwardPort port : portsToForwardNow) {
    640641                                String proto = protoToString(port.protocol);
     642                                map.clear();
     643                                ForwardPortStatus fps;
    641644                                if (proto.length() <= 1) {
    642                                         HashMap<ForwardPort, ForwardPortStatus> map = new HashMap<ForwardPort, ForwardPortStatus>();
    643                                         map.put(port, new ForwardPortStatus(ForwardPortStatus.DEFINITE_FAILURE, "Protocol not supported", port.portNumber));
    644                                         forwardCallback.portForwardStatus(map);
    645                                         continue;
     645                                        fps = new ForwardPortStatus(ForwardPortStatus.DEFINITE_FAILURE, "Protocol not supported", port.portNumber);
     646                                } else if(tryAddMapping(proto, port.portNumber, port.name, port)) {
     647                                        fps = new ForwardPortStatus(ForwardPortStatus.MAYBE_SUCCESS, "Port apparently forwarded by UPnP", port.portNumber);
     648                                } else {
     649                                        fps = new ForwardPortStatus(ForwardPortStatus.PROBABLE_FAILURE, "UPnP port forwarding apparently failed", port.portNumber);
    646650                                }
    647                                 if(tryAddMapping(proto, port.portNumber, port.name, port)) {
    648                                         HashMap<ForwardPort, ForwardPortStatus> map = new HashMap<ForwardPort, ForwardPortStatus>();
    649                                         map.put(port, new ForwardPortStatus(ForwardPortStatus.MAYBE_SUCCESS, "Port apparently forwarded by UPnP", port.portNumber));
    650                                         forwardCallback.portForwardStatus(map);
    651                                         continue;
    652                                 } else {
    653                                         HashMap<ForwardPort, ForwardPortStatus> map = new HashMap<ForwardPort, ForwardPortStatus>();
    654                                         map.put(port, new ForwardPortStatus(ForwardPortStatus.PROBABLE_FAILURE, "UPnP port forwarding apparently failed", port.portNumber));
    655                                         forwardCallback.portForwardStatus(map);
    656                                         continue;
    657                                 }
     651                                map.put(port, fps);
     652                                forwardCallback.portForwardStatus(map);
    658653                        }
    659654                }
  • router/java/src/net/i2p/router/transport/udp/UDPEndpoint.java

    r5190b2d ra3b1c790  
    2323    private InetAddress _bindAddress;
    2424   
    25     public UDPEndpoint(RouterContext ctx, UDPTransport transport, int listenPort, InetAddress bindAddress) throws SocketException {
     25    /**
     26     *  @param listenPort -1 or the requested port, may not be honored
     27     *  @param bindAddress null ok
     28     */
     29    public UDPEndpoint(RouterContext ctx, UDPTransport transport, int listenPort, InetAddress bindAddress) {
    2630        _context = ctx;
    2731        _log = ctx.logManager().getLog(UDPEndpoint.class);
     
    3135    }
    3236   
     37    /** caller should call getListenPort() after this to get the actual bound port and determine success */
    3338    public void startup() {
    3439        if (_log.shouldLog(Log.DEBUG))
    3540            _log.debug("Starting up the UDP endpoint");
    3641        shutdown();
    37         try {
    38             if (_bindAddress == null)
    39                 _socket = new DatagramSocket(_listenPort);
    40             else
    41                 _socket = new DatagramSocket(_listenPort, _bindAddress);
    42             _sender = new UDPSender(_context, _socket, "UDPSender");
    43             _receiver = new UDPReceiver(_context, _transport, _socket, "UDPReceiver");
    44             _sender.startup();
    45             _receiver.startup();
    46         } catch (SocketException se) {
    47             _transport.setReachabilityStatus(CommSystemFacade.STATUS_HOSED);
    48             _log.log(Log.CRIT, "Unable to bind on port " + _listenPort, se);
     42        _socket = getSocket();
     43        if (_socket == null) {
     44            _log.log(Log.CRIT, "UDP Unable to open a port");
     45            return;
    4946        }
     47        _sender = new UDPSender(_context, _socket, "UDPSender");
     48        _receiver = new UDPReceiver(_context, _transport, _socket, "UDPReceiver");
     49        _sender.startup();
     50        _receiver.startup();
    5051    }
    5152   
     
    6162   
    6263    public void setListenPort(int newPort) { _listenPort = newPort; }
     64
     65/*******
    6366    public void updateListenPort(int newPort) {
    6467        if (newPort == _listenPort) return;
     
    7780        }
    7881    }
     82********/
    7983   
     84    /** 8998 is monotone, and 32000 is the wrapper, so let's stay between those */
     85    private static final int MIN_RANDOM_PORT = 9111;
     86    private static final int MAX_RANDOM_PORT = 31777;
     87    private static final int MAX_PORT_RETRIES = 20;
     88
     89    /**
     90     *  Open socket using requested port in _listenPort and  bind host in _bindAddress.
     91     *  If _listenPort <= 0, or requested port is busy, repeatedly try a new random port.
     92     *  @return null on failure
     93     *  Sets _listenPort to actual port or -1 on failure
     94     */
     95    private DatagramSocket getSocket() {
     96        DatagramSocket socket = null;
     97        int port = _listenPort;
     98
     99        for (int i = 0; i < MAX_PORT_RETRIES; i++) {
     100             if (port <= 0) {
     101                 // try random ports rather than just do new DatagramSocket()
     102                 // so we stay out of the way of other I2P stuff
     103                 port = MIN_RANDOM_PORT + _context.random().nextInt(MAX_RANDOM_PORT - MIN_RANDOM_PORT);
     104             }
     105             try {
     106                 if (_bindAddress == null)
     107                     socket = new DatagramSocket(port);
     108                 else
     109                     socket = new DatagramSocket(port, _bindAddress);
     110                 break;
     111             } catch (SocketException se) {
     112                 if (_log.shouldLog(Log.WARN))
     113                     _log.warn("Binding to port " + port + " failed: " + se);
     114             }
     115             port = -1;
     116        }
     117        if (socket == null) {
     118            _log.log(Log.CRIT, "SSU Unable to bind to a port on " + _bindAddress);
     119        } else if (port != _listenPort) {
     120            if (_listenPort > 0)
     121                _log.error("SSU Unable to bind to requested port " + _listenPort + ", using random port " + port);
     122            else
     123                _log.error("SSU selected random port " + port);
     124        }
     125        _listenPort = port;
     126        return socket;
     127    }
     128
     129    /** call after startup() to get actual port or -1 on startup failure */
    80130    public int getListenPort() { return _listenPort; }
    81131    public UDPSender getSender() { return _sender; }
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    r5190b2d ra3b1c790  
    101101    public static final String STYLE = "SSU";
    102102    public static final String PROP_INTERNAL_PORT = "i2np.udp.internalPort";
     103    /** now unused, we pick a random port */
    103104    public static final int DEFAULT_INTERNAL_PORT = 8887;
    104105    /** since fixed port defaults to true, this doesnt do anything at the moment.
     
    138139    /** do we allow direct SSU connections, sans introducers?  */
    139140    public static final String PROP_ALLOW_DIRECT = "i2np.udp.allowDirect";
     141    /** this is rarely if ever used, default is to bind to wildcard address */
    140142    public static final String PROP_BIND_INTERFACE = "i2np.udp.bindInterface";
    141143       
     
    227229       
    228230        rebuildExternalAddress();
    229        
    230         int port = -1;
     231
     232        // bind host
     233        String bindTo = _context.getProperty(PROP_BIND_INTERFACE);
     234        InetAddress bindToAddr = null;
     235        if (bindTo != null) {
     236            try {
     237                bindToAddr = InetAddress.getByName(bindTo);
     238            } catch (UnknownHostException uhe) {
     239                _log.log(Log.CRIT, "Invalid SSU bind interface specified [" + bindTo + "]", uhe);
     240                setReachabilityStatus(CommSystemFacade.STATUS_HOSED);
     241                return;
     242            }
     243        }
     244       
     245        // Requested bind port
     246        // This may be -1 or may not be honored if busy,
     247        // we will check below after starting up the endpoint.
     248        int port;
     249        int oldIPort = _context.getProperty(PROP_INTERNAL_PORT, -1);
     250        int oldEPort = _context.getProperty(PROP_EXTERNAL_PORT, -1);
    231251        if (_externalListenPort <= 0) {
    232252            // no explicit external port, so lets try an internal one
    233             port = _context.getProperty(PROP_INTERNAL_PORT, DEFAULT_INTERNAL_PORT);
     253            if (oldIPort > 0)
     254                port = oldIPort;
     255            else
     256                port = oldEPort;
     257        } else {
     258            port = _externalListenPort;
     259        }
     260        if (_log.shouldLog(Log.INFO))
     261            _log.info("Binding to the port: " + port);
     262        if (_endpoint == null) {
     263            _endpoint = new UDPEndpoint(_context, this, port, bindToAddr);
     264        } else {
     265            // todo, set bind address too
     266            _endpoint.setListenPort(port);
     267        }
     268       
     269        if (_establisher == null)
     270            _establisher = new EstablishmentManager(_context, this);
     271       
     272        if (_testManager == null)
     273            _testManager = new PeerTestManager(_context, this);
     274       
     275        if (_handler == null)
     276            _handler = new PacketHandler(_context, this, _endpoint, _establisher, _inboundFragments, _testManager, _introManager);
     277       
     278        if (_refiller == null)
     279            _refiller = new OutboundRefiller(_context, _fragments, _outboundMessages);
     280       
     281        if (_flooder == null)
     282            _flooder = new UDPFlooder(_context, this);
     283       
     284        // Startup the endpoint with the requested port, check the actual port, and
     285        // take action if it failed or was different than requested or it needs to be saved
     286        _endpoint.startup();
     287        int newPort = _endpoint.getListenPort();
     288        _externalListenPort = newPort;
     289        if (newPort <= 0) {
     290            _log.log(Log.CRIT, "Unable to open UDP port");
     291            setReachabilityStatus(CommSystemFacade.STATUS_HOSED);
     292            return;
     293        }
     294        if (newPort != port || newPort != oldIPort || newPort != oldEPort) {
    234295            // attempt to use it as our external port - this will be overridden by
    235296            // externalAddressReceived(...)
    236             _context.router().setConfigSetting(PROP_EXTERNAL_PORT, port+"");
     297            _context.router().setConfigSetting(PROP_INTERNAL_PORT, newPort+"");
     298            _context.router().setConfigSetting(PROP_EXTERNAL_PORT, newPort+"");
    237299            _context.router().saveConfig();
    238         } else {
    239             port = _externalListenPort;
    240             if (_log.shouldLog(Log.INFO))
    241                 _log.info("Binding to the explicitly specified external port: " + port);
    242         }
    243         if (_endpoint == null) {
    244             String bindTo = _context.getProperty(PROP_BIND_INTERFACE);
    245             InetAddress bindToAddr = null;
    246             if (bindTo != null) {
    247                 try {
    248                     bindToAddr = InetAddress.getByName(bindTo);
    249                 } catch (UnknownHostException uhe) {
    250                     if (_log.shouldLog(Log.ERROR))
    251                         _log.error("Invalid SSU bind interface specified [" + bindTo + "]", uhe);
    252                     bindToAddr = null;
    253                 }
    254             }
    255             try {
    256                 _endpoint = new UDPEndpoint(_context, this, port, bindToAddr);
    257             } catch (SocketException se) {
    258                 if (_log.shouldLog(Log.CRIT))
    259                     _log.log(Log.CRIT, "Unable to listen on the UDP port (" + port + ")", se);
    260                 return;
    261             }
    262         } else {
    263             _endpoint.setListenPort(port);
    264         }
    265        
    266         if (_establisher == null)
    267             _establisher = new EstablishmentManager(_context, this);
    268        
    269         if (_testManager == null)
    270             _testManager = new PeerTestManager(_context, this);
    271        
    272         if (_handler == null)
    273             _handler = new PacketHandler(_context, this, _endpoint, _establisher, _inboundFragments, _testManager, _introManager);
    274        
    275         if (_refiller == null)
    276             _refiller = new OutboundRefiller(_context, _fragments, _outboundMessages);
    277        
    278         if (_flooder == null)
    279             _flooder = new UDPFlooder(_context, this);
    280        
    281         _endpoint.startup();
     300        }
     301
    282302        _establisher.startup();
    283303        _handler.startup();
     
    322342    public InetAddress getLocalAddress() { return _externalListenHost; }
    323343    public int getExternalPort() { return _externalListenPort; }
     344
     345    /**
     346     *  _externalListenPort should always be set (by startup()) before this is called,
     347     *  so the returned value should be > 0
     348     */
    324349    @Override
    325350    public int getRequestedPort() {
    326351        if (_externalListenPort > 0)
    327352            return _externalListenPort;
    328         return _context.getProperty(PROP_INTERNAL_PORT, DEFAULT_INTERNAL_PORT);
     353        return _context.getProperty(PROP_INTERNAL_PORT, -1);
    329354    }
    330355
     
    20042029        buf.append("</b></td> <td align=\"center\"><b>").append(dupRecvTotal).append("</b></td>\n");
    20052030        buf.append(" </tr></table></div>\n");
     2031
     2032      /*****
    20062033        long bytesTransmitted = _context.bandwidthLimiter().getTotalAllocatedOutboundBytes();
    20072034        // NPE here early
     
    20132040        buf.append("<h3>Percentage of bytes retransmitted (lifetime): ").append(formatPct(bwResent));
    20142041        buf.append("</h3><i>(Includes retransmission required by packet loss)</i>\n");
     2042      *****/
     2043
    20152044        out.write(buf.toString());
    20162045        buf.setLength(0);
Note: See TracChangeset for help on using the changeset viewer.