Changeset 3834403


Ignore:
Timestamp:
Jul 19, 2011 9:18:14 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
6d06427
Parents:
d397eaa (diff), 56d8b72 (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:

propagate from branch 'i2p.i2p' (head e014bb054baa0d8e844e9a97ad6f5b04ed7c0e56)

to branch 'i2p.i2p.zzz.test' (head 1e0af137b9c4c873fea72d661f2ee351a640734f)

Files:
18 edited

Legend:

Unmodified
Added
Removed
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java

    rd397eaa r3834403  
    456456                                    pos2 = fragment.indexOf("=");
    457457                                    ahelperKey = fragment.substring(pos2 + 1);
    458 
    459458                                    // Key contains data, lets not ignore it
    460459                                    if (ahelperKey != null) {
     460                                        if(ahelperKey.endsWith(".b32.i2p")) {
     461                                            // allow i2paddresshelper=<b32>.b32.i2p syntax.
     462                                            Destination dest = _context.namingService().lookup(ahelperKey);
     463                                            if(dest==null)
     464                                                throw new RuntimeException("Could not find destination for "+ahelperKey);
     465                                            ahelperKey = dest.toBase64();
     466                                        }
    461467                                        ahelperPresent = true;
    462468                                        // ahelperKey will be validated later
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java

    rd397eaa r3834403  
    99 */
    1010
     11import java.io.File;
    1112import java.io.IOException;
    1213import java.util.ArrayList;
     
    3233import net.i2p.i2ptunnel.TunnelControllerGroup;
    3334import net.i2p.util.ConcurrentHashSet;
     35import net.i2p.util.FileUtil;
    3436import net.i2p.util.Log;
    3537
     
    4244 */
    4345public class IndexBean {
    44     protected I2PAppContext _context;
    45     protected Log _log;
    46     protected TunnelControllerGroup _group;
     46    protected final I2PAppContext _context;
     47    protected final Log _log;
     48    protected final TunnelControllerGroup _group;
    4749    private String _action;
    4850    private int _tunnel;
     
    7678    private boolean _privKeyGenerate;
    7779    private boolean _removeConfirmed;
    78     private Set<String> _booleanOptions;
    79     private Map<String, String> _otherOptions;
     80    private final Set<String> _booleanOptions;
     81    private final Map<String, String> _otherOptions;
    8082    private int _hashCashValue;
    8183    private int _certType;
     
    200202    private String stopAll() {
    201203        if (_group == null) return "";
    202         List msgs = _group.stopAllControllers();
     204        List<String> msgs = _group.stopAllControllers();
    203205        return getMessages(msgs);
    204206    }
    205207    private String startAll() {
    206208        if (_group == null) return "";
    207         List msgs = _group.startAllControllers();
     209        List<String> msgs = _group.startAllControllers();
    208210        return getMessages(msgs);
    209211    }
    210212    private String restartAll() {
    211213        if (_group == null) return "";
    212         List msgs = _group.restartAllControllers();
     214        List<String> msgs = _group.restartAllControllers();
    213215        return getMessages(msgs);
    214216    }
     
    318320    }
    319321
     322    /**
     323     *  Stop the tunnel, delete from config,
     324     *  rename the private key file if in the default directory
     325     */
    320326    private String deleteTunnel() {
    321327        if (!_removeConfirmed)
     
    326332            return "Invalid tunnel number";
    327333       
    328         List msgs = _group.removeController(cur);
     334        List<String> msgs = _group.removeController(cur);
    329335        msgs.addAll(doSave());
     336
     337        // Rename private key file if it was a default name in
     338        // the default directory, so it doesn't get reused when a new
     339        // tunnel is created.
     340        // Use configured file name if available, not the one from the form.
     341        String pk = cur.getPrivKeyFile();
     342        if (pk == null)
     343            pk = _privKeyFile;
     344        if (pk != null && pk.startsWith("i2ptunnel") && pk.endsWith("-privKeys.dat")) {
     345            File pkf = new File(_context.getConfigDir(), pk);
     346            if (pkf.exists()) {
     347                String name = cur.getName();
     348                if (name == null) {
     349                    name = cur.getDescription();
     350                    if (name == null) {
     351                        name = cur.getType();
     352                        if (name == null)
     353                            name = Long.toString(_context.clock().now());
     354                    }
     355                }
     356                name = "i2ptunnel-deleted-" + name.replace(' ', '_') + "-privkeys.dat";
     357                File to = new File(_context.getConfigDir(), name);
     358                if (to.exists())
     359                    to = new File(_context.getConfigDir(), name + '-' + _context.clock().now());
     360                boolean success = FileUtil.rename(pkf, to);
     361                if (success)
     362                    msgs.add("Private key file " + pkf.getAbsolutePath() +
     363                             " renamed to " + to.getAbsolutePath());
     364            }
     365        }
    330366        return getMessages(msgs);
    331367    }
  • apps/routerconsole/java/src/net/i2p/router/web/NewsFetcher.java

    rd397eaa r3834403  
    360360        long now = _context.clock().now();
    361361        if (_tempFile.exists()) {
    362             boolean copied = FileUtil.copy(_tempFile.getAbsolutePath(), _newsFile.getAbsolutePath(), true);
     362            boolean copied = FileUtil.copy(_tempFile, _newsFile, true, false);
    363363            if (copied) {
    364364                _lastUpdated = now;
  • apps/routerconsole/java/src/net/i2p/router/web/UnsignedUpdateHandler.java

    rd397eaa r3834403  
    9494                return;
    9595            }
    96             String to = (new File(_context.getRouterDir(), Router.UPDATE_FILE)).getAbsolutePath();
    97             boolean copied = FileUtil.copy(_updateFile, to, true);
     96            File to = new File(_context.getRouterDir(), Router.UPDATE_FILE);
     97            boolean copied = FileUtil.copy(updFile, to, true, false);
    9898            if (copied) {
    9999                updFile.delete();
     
    125125            } else {
    126126                _log.log(Log.CRIT, "Failed copy to " + to);
    127                 updateStatus("<b>" + _("Failed copy to {0}", to) + "</b>");
     127                updateStatus("<b>" + _("Failed copy to {0}", to.getAbsolutePath()) + "</b>");
    128128            }
    129129        }
  • apps/streaming/java/src/net/i2p/client/streaming/ConnectionManager.java

    rd397eaa r3834403  
    166166                              + _maxConcurrentStreams + " connections");
    167167                reject = true;
    168             } else if (shouldRejectConnection(synPacket)) {
     168            } else {
    169169                // this may not be right if more than one is enabled
    170                 String why;
    171                 if (_defaultOptions.isAccessListEnabled())
    172                     why = "not whitelisted: ";
    173                 else if (_defaultOptions.isBlacklistEnabled())
    174                     why = "blacklisted: ";
    175                 else
    176                     why = "throttled: ";
    177                 _log.error("Refusing connection since peer is " + why +
    178                            (synPacket.getOptionalFrom() == null ? "null from" : synPacket.getOptionalFrom().calculateHash().toBase64()));
    179                 reject = true;
    180             } else {
    181                 while (true) {
    182                     Connection oldCon = _connectionByInboundId.putIfAbsent(Long.valueOf(receiveId), con);
    183                     if (oldCon == null) {
    184                         break;
    185                     } else {
    186                         // receiveId already taken, try another
    187                         receiveId = _context.random().nextLong(Packet.MAX_STREAM_ID-1)+1;
     170                String why = shouldRejectConnection(synPacket);
     171                if (why != null) {
     172                    _log.logAlways(Log.WARN, "Refusing connection since peer is " + why +
     173                           (synPacket.getOptionalFrom() == null ? "" : ": " + synPacket.getOptionalFrom().calculateHash().toBase64()));
     174                    reject = true;
     175                } else {
     176                    while (true) {
     177                        Connection oldCon = _connectionByInboundId.putIfAbsent(Long.valueOf(receiveId), con);
     178                        if (oldCon == null) {
     179                            break;
     180                        } else {
     181                            // receiveId already taken, try another
     182                            receiveId = _context.random().nextLong(Packet.MAX_STREAM_ID-1)+1;
     183                        }
    188184                    }
    189185                }
     
    309305    }
    310306   
    311     private boolean shouldRejectConnection(Packet syn) {
     307    /**
     308     *  @return reason string or null if not rejected
     309     */
     310    private String shouldRejectConnection(Packet syn) {
    312311        // unfortunately we don't have access to the router client manager here,
    313312        // so we can't whitelist local access
    314313        Destination from = syn.getOptionalFrom();
    315314        if (from == null)
    316             return true;
     315            return "null";
    317316        Hash h = from.calculateHash();
    318         boolean throttled = false;
     317        String throttled = null;
    319318        // always call all 3 to increment all counters
    320319        if (_minuteThrottler != null && _minuteThrottler.shouldThrottle(h)) {
    321320            _context.statManager().addRateData("stream.con.throttledMinute", 1, 0);
    322             throttled = true;
     321            throttled = "throttled by per-peer limit of " + _defaultOptions.getMaxConnsPerMinute() +
     322                        " or total limit of " + _defaultOptions.getMaxTotalConnsPerMinute() +
     323                        " per minute";
    323324        }
    324325        if (_hourThrottler != null && _hourThrottler.shouldThrottle(h)) {
    325326            _context.statManager().addRateData("stream.con.throttledHour", 1, 0);
    326             throttled = true;
     327            throttled = "throttled by per-peer limit of " + _defaultOptions.getMaxConnsPerHour() +
     328                        " or total limit of " + _defaultOptions.getMaxTotalConnsPerHour() +
     329                        " per hour";
    327330        }
    328331        if (_dayThrottler != null && _dayThrottler.shouldThrottle(h)) {
    329332            _context.statManager().addRateData("stream.con.throttledDay", 1, 0);
    330             throttled = true;
    331         }
    332         if (throttled)
    333             return true;
     333            throttled = "throttled by per-peer limit of " + _defaultOptions.getMaxConnsPerDay() +
     334                        " or total limit of " + _defaultOptions.getMaxTotalConnsPerDay() +
     335                        " per day";
     336        }
     337        if (throttled != null)
     338            return throttled;
    334339        // if the sig is absent or bad it will be caught later (in CPH)
    335         if (_defaultOptions.isAccessListEnabled())
    336             return !_defaultOptions.getAccessList().contains(h);
    337         if (_defaultOptions.isBlacklistEnabled())
    338             return _defaultOptions.getBlacklist().contains(h);
    339         return false;
     340        if (_defaultOptions.isAccessListEnabled() &&
     341            !_defaultOptions.getAccessList().contains(h))
     342            return "not whitelisted";
     343        if (_defaultOptions.isBlacklistEnabled() &&
     344            _defaultOptions.getBlacklist().contains(h))
     345            return "blacklisted";
     346        return null;
    340347    }
    341348
  • core/java/src/freenet/support/CPUInformation/CPUID.java

    rd397eaa r3834403  
    403403        // copy to install dir, ignore failure
    404404        File newFile = new File(I2PAppContext.getGlobalContext().getBaseDir(), filename);
    405         FileUtil.copy(outFile.getAbsolutePath(), newFile.getAbsolutePath(), false, true);
     405        FileUtil.copy(outFile, newFile, false, true);
    406406        return true;
    407407    }
  • core/java/src/net/i2p/client/naming/SingleFileNamingService.java

    rd397eaa r3834403  
    194194            out.newLine();
    195195            out.close();
    196             boolean success = rename(tmp, _file);
     196            boolean success = FileUtil.rename(tmp, _file);
    197197            if (success) {
    198198                for (NamingServiceListener nsl : _listeners) {
     
    285285                return false;
    286286            }
    287             success = rename(tmp, _file);
     287            success = FileUtil.rename(tmp, _file);
    288288            if (success) {
    289289                for (NamingServiceListener nsl : _listeners) {
     
    441441            releaseWriteLock();
    442442        }
    443     }
    444 
    445     private static boolean rename(File from, File to) {
    446         boolean success = false;
    447         boolean isWindows = System.getProperty("os.name").startsWith("Win");
    448         // overwrite fails on windows
    449         if (!isWindows)
    450             success = from.renameTo(to);
    451         if (!success) {
    452             to.delete();
    453             success = from.renameTo(to);
    454             if (!success) {
    455                 // hard way
    456                 success = FileUtil.copy(from.getAbsolutePath(), to.getAbsolutePath(), true, true);
    457                 from.delete();
    458             }
    459         }
    460         return success;
    461443    }
    462444
  • core/java/src/net/i2p/data/Hash.java

    rd397eaa r3834403  
    2020 */
    2121public class Hash extends SimpleDataStructure {
    22     private volatile String _stringified;
    2322    private volatile String _base64ed;
    2423    private int _cachedHashCode;
     
    7271    public void setData(byte[] data) {
    7372        super.setData(data);
    74         _stringified = null;
    7573        _base64ed = null;
    7674        _cachedHashCode = super.hashCode();
     
    8078    public void readBytes(InputStream in) throws DataFormatException, IOException {
    8179        super.readBytes(in);
    82         _stringified = null;
    8380        _base64ed = null;
    8481        _cachedHashCode = super.hashCode();
  • core/java/src/net/i2p/util/FileUtil.java

    rd397eaa r3834403  
    401401        File src = new File(source);
    402402        File dst = new File(dest);
    403 
     403        return copy(src, dst, overwriteExisting, quiet);
     404    }
     405
     406    /**
     407      * @param quiet don't log fails to wrapper log if true
     408      * @return true if it was copied successfully
     409      * @since 0.8.8
     410      */
     411    public static boolean copy(File src, File dst, boolean overwriteExisting, boolean quiet) {
    404412        if (dst.exists() && dst.isDirectory())
    405413            dst = new File(dst, src.getName());
     
    430438    }
    431439   
     440    /**
     441     * Try to rename, if it doesn't work then copy and delete the old.
     442     * Always overwrites any existing "to" file.
     443     * Method moved from SingleFileNamingService.
     444     *
     445     * @return true if it was renamed / copied successfully
     446     * @since 0.8.8
     447     */
     448    public static boolean rename(File from, File to) {
     449        if (!from.exists())
     450            return false;
     451        boolean success = false;
     452        boolean isWindows = System.getProperty("os.name").startsWith("Win");
     453        // overwrite fails on windows
     454        if (!isWindows)
     455            success = from.renameTo(to);
     456        if (!success) {
     457            to.delete();
     458            success = from.renameTo(to);
     459            if (!success) {
     460                // hard way
     461                success = copy(from, to, true, true);
     462                if (success)
     463                    from.delete();
     464            }
     465        }
     466        return success;
     467    }
     468
    432469    /**
    433470     * Usage: FileUtil (delete path | copy source dest | unzip path.zip)
  • core/java/src/net/i2p/util/NativeBigInteger.java

    rd397eaa r3834403  
    607607        // copy to install dir, ignore failure
    608608        File newFile = new File(I2PAppContext.getGlobalContext().getBaseDir(), filename);
    609         FileUtil.copy(outFile.getAbsolutePath(), newFile.getAbsolutePath(), false, true);
     609        FileUtil.copy(outFile, newFile, false, true);
    610610        return true;
    611611    }
  • history.txt

    rd397eaa r3834403  
     12011-07-18 zzz
     2  * FileUtil: Add a rename method and a new copy method
     3  * I2PTunnel: Rename privkey file when deleting tunnel to prevent inadvertent reuse
     4  * Netdb: Update reseed lists
     5  * Streaming: Improve conn limit log message
     6  * UDP: Lower max port below 31000 since wrapper uses that
     7
    182011-07-15 zzz
    29  * Shutdown:
  • installer/resources/themes/console/light/console_ar.css

    rd397eaa r3834403  
    311311
    312312div.main {
    313      margin: 10px 10px 20px 207px;
    314      padding: 0 15px 15px 15px;
     313     margin: 10px 210px 0px 10px;
     314     padding: 7px 0px 30px 20px;
    315315     background: #ffe;
    316316     text-align: right;
     
    346346
    347347div.news {
    348      margin: 0px 10px 5px 207px;
    349      padding: 7px 20px 7px 20px;
     348     margin: 10px 210px 0px 10px;
     349     padding: 7px 0px 30px 20px;
    350350     border: 1px solid #447;
    351351     color: #224;
     
    712712     text-align: right;
    713713     color: #115;
    714      padding: 10px 15px;
    715      margin: 0 10px 10px 207px;
     714     margin: 10px 210px 0px 10px;
     715     padding: 7px 0px 30px 20px;
    716716     font: normal bold 16pt/120% "Lucida Sans Unicode", "Bitstream Vera Sans", Verdana, Tahoma, Helvetica, sans-serif;
    717717     letter-spacing: 0.15em;
  • router/java/src/net/i2p/router/RouterVersion.java

    rd397eaa r3834403  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 11;
     21    public final static long BUILD = 12;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java

    rd397eaa r3834403  
    5757     */
    5858    public static final String DEFAULT_SEED_URL =
    59               "http://a.netdb.i2p2.de/,http://c.netdb.i2p2.de/," +
    60               "http://reseed.i2p-projekt.de/,http://forum.i2p2.de/netdb/,http://www.i2pbote.net/netDb/,http://r31453.ovh.net/static_media/files/netDb/";
     59              "http://a.netdb.i2p2.de/," +
     60              "http://c.netdb.i2p2.de/," +
     61              "http://reseed.i2p-projekt.de/," +
     62              "http://forum.i2p2.de/netdb/," +
     63              "http://www.i2pbote.net/netDb/," +
     64              "http://r31453.ovh.net/static_media/files/netDb/," +
     65              "http://cowpuncher.drollette.com/netdb/";
    6166
    6267    /** @since 0.8.2 */
    6368    public static final String DEFAULT_SSL_SEED_URL =
    64               "https://a.netdb.i2p2.de/,https://c.netdb.i2p2.de/," +
    65               "https://forum.i2p2.de/netdb/,https://www.i2pbote.net/netDb/," +
    66               "https://r31453.ovh.net/static_media/files/netDb/";
     69         /*   "https://a.netdb.i2p2.de/," +   bad cert */
     70         /*   "https://c.netdb.i2p2.de/," +   no data */
     71              "https://forum.i2p2.de/netdb/," +
     72              "https://www.i2pbote.net/netDb/," +
     73              "https://r31453.ovh.net/static_media/files/netDb/," +
     74              "https://cowpuncher.drollette.com/netdb/";
    6775
    6876    private static final String PROP_INPROGRESS = "net.i2p.router.web.ReseedHandler.reseedInProgress";
  • router/java/src/net/i2p/router/transport/udp/UDPEndpoint.java

    rd397eaa r3834403  
    8181********/
    8282   
    83     /** 8998 is monotone, and 32000 is the wrapper, so let's stay between those */
     83    /** 8998 is monotone, and 31000 is the wrapper outbound, so let's stay between those */
    8484    public static final String PROP_MIN_PORT = "i2np.udp.minPort";
    8585    public static final String PROP_MAX_PORT = "i2np.udp.maxPort";
    8686    private static final int MIN_RANDOM_PORT = 9111;
    87     private static final int MAX_RANDOM_PORT = 31777;
     87    private static final int MAX_RANDOM_PORT = 30777;
    8888    private static final int MAX_PORT_RETRIES = 20;
    8989
  • router/java/src/net/i2p/router/tunnel/pool/TestJob.java

    rd397eaa r3834403  
    2424import net.i2p.util.Log;
    2525
     26/**
     27 *  Repeatedly test a single tunnel for its entire lifetime,
     28 *  or until the pool is shut down or removed from the client manager.
     29 */
    2630class TestJob extends JobImpl {
    2731    private final Log _log;
     
    3640   
    3741    /** base to randomize the test delay on */
    38     private static final int TEST_DELAY = 30*1000;
     42    private static final int TEST_DELAY = 40*1000;
    3943   
    4044    public TestJob(RouterContext ctx, PooledTunnelCreatorConfig cfg, TunnelPool pool) {
     
    5559
    5660    public void runJob() {
    57         if (_pool == null)
     61        if (_pool == null || !_pool.isAlive())
    5862            return;
    5963        long lag = getContext().jobQueue().getMaxLag();
     
    156160   
    157161    public void testSuccessful(int ms) {
     162        if (_pool == null || !_pool.isAlive())
     163            return;
    158164        getContext().statManager().addRateData("tunnel.testSuccessLength", _cfg.getLength(), 0);
    159165        getContext().statManager().addRateData("tunnel.testSuccessTime", ms, 0);
     
    183189   
    184190    private void testFailed(long timeToFail) {
     191        if (_pool == null || !_pool.isAlive())
     192            return;
    185193        if (_found) {
    186194            // ok, not really a /success/, but we did find it, even though slowly
     
    209217   
    210218    /** randomized time we should wait before testing */
    211     private int getDelay() { return TEST_DELAY + getContext().random().nextInt(TEST_DELAY); }
     219    private int getDelay() { return TEST_DELAY + getContext().random().nextInt(TEST_DELAY / 3); }
    212220
    213221    /** how long we allow tests to run for before failing them */
     
    235243    private void scheduleRetest() { scheduleRetest(false); }
    236244    private void scheduleRetest(boolean asap) {
     245        if (_pool == null || !_pool.isAlive())
     246            return;
    237247        if (asap) {
    238             requeue(getContext().random().nextInt(TEST_DELAY));
     248            if (_cfg.getExpiration() > getContext().clock().now() + (60 * 1000))
     249                requeue((TEST_DELAY / 4) + getContext().random().nextInt(TEST_DELAY / 4));
    239250        } else {
    240251            int delay = getDelay();
  • router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java

    rd397eaa r3834403  
    2424/**
    2525 *  A group of tunnels for the router or a particular client, in a single direction.
     26 *  Public only for TunnelRenderer in router console.
    2627 */
    2728public class TunnelPool {
     
    4445    private static final int TUNNEL_LIFETIME = 10*60*1000;
    4546   
    46     public TunnelPool(RouterContext ctx, TunnelPoolManager mgr, TunnelPoolSettings settings, TunnelPeerSelector sel) {
     47    TunnelPool(RouterContext ctx, TunnelPoolManager mgr, TunnelPoolSettings settings, TunnelPeerSelector sel) {
    4748        _context = ctx;
    4849        _log = ctx.logManager().getLog(TunnelPool.class);
     
    6061    }
    6162   
    62     public void startup() {
     63    /**
     64     *  Warning, this may be called more than once
     65     *  (without an intervening shutdown()) if the
     66     *  tunnel is stopped and then restarted by the client manager with the same
     67     *  Destination (i.e. for servers or clients w/ persistent key)
     68     */
     69    void startup() {
    6370        synchronized (_inProgress) {
    6471            _inProgress.clear();
    6572        }
     73        if (_log.shouldLog(Log.WARN))
     74            _log.warn(toString() + ": Startup() called, was already alive? " + _alive, new Exception());
    6675        _alive = true;
    6776        _started = System.currentTimeMillis();
     
    8594    }
    8695   
    87     public void shutdown() {
     96    void shutdown() {
     97        if (_log.shouldLog(Log.WARN))
     98            _log.warn(toString() + ": Shutdown called", new Exception());
    8899        _alive = false;
    89100        _lastSelectionPeriod = 0;
     
    133144     *
    134145     */
    135     public TunnelInfo selectTunnel() { return selectTunnel(true); }
     146    TunnelInfo selectTunnel() { return selectTunnel(true); }
     147
    136148    private TunnelInfo selectTunnel(boolean allowRecurseOnFail) {
    137149        boolean avoidZeroHop = ((getSettings().getLength() + getSettings().getLengthVariance()) > 0);
     
    240252     * Used to prevent a zillion of them
    241253     */
    242     public boolean needFallback() {
     254    boolean needFallback() {
    243255        int needed = _settings.getBackupQuantity() + _settings.getQuantity();
    244256        int fallbacks = 0;
     
    260272   
    261273    public TunnelPoolSettings getSettings() { return _settings; }
    262     public void setSettings(TunnelPoolSettings settings) {
     274
     275    void setSettings(TunnelPoolSettings settings) {
    263276        _settings = settings;
    264277        if (_settings != null) {
     
    268281        }
    269282    }
    270     public TunnelPeerSelector getSelector() { return _peerSelector; }
    271     public boolean isAlive() { return _alive; }
     283
     284    /**
     285     *  Is this pool running AND either exploratory, or tracked by the client manager?
     286     *  A pool will be alive but not tracked after the client manager removes it
     287     *  but before all the tunnels have expired.
     288     */
     289    public boolean isAlive() {
     290        return _alive &&
     291               (_settings.isExploratory() ||
     292                (_settings.getDestination() != null &&
     293                 _context.clientManager().isLocal(_settings.getDestination())));
     294    }
     295
    272296    /** duplicate of getTunnelCount(), let's pick one */
    273297    public int size() {
     
    337361        }
    338362   
    339         boolean connected = true;
    340         if ( (_settings.getDestination() != null) && (!_context.clientManager().isLocal(_settings.getDestination())) )
    341             connected = false;
    342         if ( (getTunnelCount() <= 0) && (!connected) ) {
     363        if (getTunnelCount() <= 0 && !isAlive()) {
     364            // this calls both our shutdown() and the other one (inbound/outbound)
    343365            _manager.removeTunnels(_settings.getDestination());
    344             return;
    345366        }
    346367    }
    347368
    348369    /** This may be called multiple times from TestJob */
    349     public void tunnelFailed(PooledTunnelCreatorConfig cfg) {
     370    void tunnelFailed(PooledTunnelCreatorConfig cfg) {
    350371        if (_log.shouldLog(Log.WARN))
    351372            _log.warn(toString() + ": Tunnel failed: " + cfg);
     
    575596     *
    576597     */
    577     public int countHowManyToBuild() {
    578         if (_settings.getDestination() != null) {
    579             if (!_context.clientManager().isLocal(_settings.getDestination()))
     598    int countHowManyToBuild() {
     599        if (!isAlive()) {
    580600                return 0;
    581601        }
  • router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java

    rd397eaa r3834403  
    277277     */
    278278    public void buildTunnels(Destination client, ClientTunnelSettings settings) {
     279        Hash dest = client.calculateHash();
    279280        if (_log.shouldLog(Log.DEBUG))
    280             _log.debug("Building tunnels for the client " + client.calculateHash().toBase64() + ": " + settings);
    281         Hash dest = client.calculateHash();
     281            _log.debug("Building tunnels for the client " + dest + ": " + settings);
    282282        settings.getInboundSettings().setDestination(dest);
    283283        settings.getOutboundSettings().setDestination(dest);
     
    312312   
    313313    private static class DelayedStartup implements SimpleTimer.TimedEvent {
    314         private TunnelPool pool;
     314        private final TunnelPool pool;
    315315
    316316        public DelayedStartup(TunnelPool p) {
     
    323323    }
    324324
    325     /** synch with buildTunnels() above */
     325    /**
     326     *  This will be called twice, once by the inbound and once by the outbound pool.
     327     *  Synched with buildTunnels() above.
     328     */
    326329    public synchronized void removeTunnels(Hash destination) {
    327330        if (destination == null) return;
     331        if (_log.shouldLog(Log.DEBUG))
     332            _log.debug("Removing tunnels for the client " + destination);
    328333        if (_context.clientManager().isLocal(destination)) {
    329334            if (_log.shouldLog(Log.CRIT))
Note: See TracChangeset for help on using the changeset viewer.