Changeset 50710f8


Ignore:
Timestamp:
Apr 27, 2018 5:41:47 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
16c5252
Parents:
10c6c428
Message:

Tunnels: Fix and consolidate allow-zero-hop logic,
prevent zero-hop client tunnels even when no active peers
Remove buildRequestZeroHopTime stat

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    r10c6c428 r50710f8  
     12018-04-27 zzz
     2  * Tunnels: Fix and consolidate allow-zero-hop logic,
     3    prevent zero-hop client tunnels when no active peers
     4
    152018-04-24 meeh
    26  * Mac OS X launcher is still WIP, but:
     
    610  * Added new entries to mtn-ignore so we avoid any PEBCAK with commiting build directories
    711  * Added an SBT AutoPlugin named IconHelper to generate valid ICNS images for Mac OS X
     12
     132018-04-23 zzz
     14 * Clock: Fix early NPE via DoH
     15 * EepGet: Handle HTTP response line with no status text
    816
    9172018-04-23 meeh
  • router/java/src/net/i2p/router/RouterVersion.java

    r10c6c428 r50710f8  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 6;
     21    public final static long BUILD = 7;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/TunnelPoolSettings.java

    r10c6c428 r50710f8  
    8080    //private static final int    DEFAULT_OB_EXPL_LENGTH_VARIANCE = isSlow ? 0 : 1;
    8181
    82     public static final boolean DEFAULT_ALLOW_ZERO_HOP = true;
     82    public static final boolean DEFAULT_ALLOW_ZERO_HOP = false;
    8383    public static final int     DEFAULT_IP_RESTRICTION = 2;    // class B (/16)
    8484    private static final int MIN_PRIORITY = -25;
     
    162162    /**
    163163     * If there are no tunnels to build with, will this pool allow 0 hop tunnels?
     164     *
    164165     * Always true for exploratory.
    165      * Generally true for client, but should probably be ignored...
    166      * use getLength() + getLengthVariance() &gt; 0 instead.
    167      */
    168     public boolean getAllowZeroHop() { return _allowZeroHop; }
     166     * Prior to 0.9.35, generally true for client.
     167     * As of 0.9.35, generally false for client, but true if
     168     * getLength() + Math.min(getLengthVariance(), 0) &lt;= 0,
     169     * OR if getLengthOverride() == 0
     170     * OR if setAllowZeroHop(true) was called or set in properties.
     171     */
     172    public boolean getAllowZeroHop() {
     173        return _allowZeroHop ||
     174               _length + Math.min(_lengthVariance, 0) <= 0 ||
     175               _lengthOverride == 0;
     176    }
    169177
    170178    /**
    171179     * If there are no tunnels to build with, will this pool allow 0 hop tunnels?
    172180     * No effect on exploratory (always true)
    173      */
     181     *
     182     * @param ok if true, getAllowZeroHop() will always return true
     183     *           if false, getAllowZeroHop will return as documented.
     184     * @deprecated unused
     185     */
     186    @Deprecated
    174187    public void setAllowZeroHop(boolean ok) {
    175188        if (!_isExploratory)
  • router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java

    r10c6c428 r50710f8  
    6767        _context.statManager().createRequiredRateStat("tunnel.buildRequestTime", "Time to build a tunnel request (ms)", "Tunnels", new long[] { 60*1000, 10*60*1000 });
    6868        _context.statManager().createRateStat("tunnel.buildConfigTime", "Time to build a tunnel request (ms)", "Tunnels", new long[] { 60*1000, 10*60*1000 });
    69         _context.statManager().createRateStat("tunnel.buildRequestZeroHopTime", "How long it takes to build a zero hop tunnel", "Tunnels", new long[] { 60*1000, 10*60*1000 });
     69        //_context.statManager().createRateStat("tunnel.buildRequestZeroHopTime", "How long it takes to build a zero hop tunnel", "Tunnels", new long[] { 60*1000, 10*60*1000 });
    7070        //_context.statManager().createRateStat("tunnel.pendingRemaining", "How many inbound requests are pending after a pass (period is how long the pass takes)?", "Tunnels", new long[] { 60*1000, 10*60*1000 });
    7171        _context.statManager().createRateStat("tunnel.buildFailFirstHop", "How often we fail to build a OB tunnel because we can't contact the first hop", "Tunnels", new long[] { 60*1000, 10*60*1000 });
     
    536536        if (!ok)
    537537            return;
    538         long buildTime = System.currentTimeMillis() - beforeBuild;
    539         if (cfg.getLength() <= 1)
    540             _context.statManager().addRateData("tunnel.buildRequestZeroHopTime", buildTime, 0);
    541         else
     538        if (cfg.getLength() > 1) {
     539            long buildTime = System.currentTimeMillis() - beforeBuild;
    542540            _context.statManager().addRateData("tunnel.buildRequestTime", buildTime, 0);
     541        }
    543542        long id = cfg.getReplyMessageId();
    544543        if (id > 0) {
  • router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java

    r10c6c428 r50710f8  
    177177
    178178    private TunnelInfo selectTunnel(boolean allowRecurseOnFail) {
    179         boolean avoidZeroHop = getSettings().getLength() > 0 &&
    180                                getSettings().getLength() + getSettings().getLengthVariance() > 0;
     179        boolean avoidZeroHop = !_settings.getAllowZeroHop();
    181180       
    182181        long period = curPeriod();
     
    244243        }
    245244       
    246         if (_alive && _settings.getAllowZeroHop())
     245        if (_alive && !avoidZeroHop)
    247246            buildFallback();
    248247        if (allowRecurseOnFail)
     
    265264     */
    266265    TunnelInfo selectTunnel(Hash closestTo) {
    267         boolean avoidZeroHop = getSettings().getLength() > 0 &&
    268                                getSettings().getLength() + getSettings().getLengthVariance() > 0;
     266        boolean avoidZeroHop = !_settings.getAllowZeroHop();
    269267        TunnelInfo rv = null;
    270268        synchronized (_tunnels) {
     
    660658
    661659        if (_settings.getAllowZeroHop()) {
    662             if ( (_settings.getLength() + _settings.getLengthVariance() > 0) &&
    663                  (!_settings.isExploratory()) &&
    664                  (_context.profileOrganizer().countActivePeers() > 0) ) {
    665                 // if it is a client tunnel pool and our variance doesn't allow 0 hop, prefer failure to
    666                 // 0 hop operation (unless our router is offline)
    667                 return false;
    668             }
    669660            if (_log.shouldLog(Log.INFO))
    670661                _log.info(toString() + ": building a fallback tunnel (usable: " + usable + " needed: " + quantity + ")");
     
    848839        int wanted = getAdjustedTotalQuantity();
    849840       
    850         boolean allowZeroHop = ((getSettings().getLength() + getSettings().getLengthVariance()) <= 0);
     841        boolean allowZeroHop = _settings.getAllowZeroHop();
    851842         
    852843        /**
Note: See TracChangeset for help on using the changeset viewer.