Changeset 6c361679


Ignore:
Timestamp:
Aug 28, 2009 3:16:12 AM (11 years ago)
Author:
z3d <z3d@…>
Branches:
master
Children:
f1f97e8
Parents:
ae89d2f (diff), 8053fb5 (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 '1b1c377c45e8746e4e04afc47cde55a03b859f32'

and '6869519b0cd38f4bc366d0277c5dc4e924348e66'

Files:
2 added
46 edited

Legend:

Unmodified
Added
Removed
  • android/res/raw/router_config

    rae89d2f r6c361679  
    44i2p.dir.pid=/data/data/net.i2p.router/files/tmp
    55# save memory
    6 router.prng.buffers=2
     6prng.buffers=2
    77router.decayingBloomFilterM=20
    88stat.full=false
  • apps/i2psnark/java/src/org/klomp/snark/I2PSnarkUtil.java

    rae89d2f r6c361679  
    1818import net.i2p.client.streaming.I2PServerSocket;
    1919import net.i2p.client.streaming.I2PSocket;
     20import net.i2p.client.streaming.I2PSocketEepGet;
    2021import net.i2p.client.streaming.I2PSocketManager;
    2122import net.i2p.client.streaming.I2PSocketManagerFactory;
     
    232233            fetchURL = rewriteAnnounce(url);
    233234        //_log.debug("Rewritten url [" + fetchURL + "]");
    234         EepGet get = new EepGet(_context, _shouldProxy, _proxyHost, _proxyPort, retries, out.getAbsolutePath(), fetchURL);
     235        //EepGet get = new EepGet(_context, _shouldProxy, _proxyHost, _proxyPort, retries, out.getAbsolutePath(), fetchURL);
     236        // Use our tunnel for announces and .torrent fetches too! Make sure we're connected first...
     237        if (!connected()) {
     238            if (!connect())
     239                return null;
     240        }
     241        EepGet get = new I2PSocketEepGet(_context, _manager, retries, out.getAbsolutePath(), fetchURL);
    235242        if (get.fetch()) {
    236243            _log.debug("Fetch successful [" + url + "]: size=" + out.length());
  • apps/i2psnark/java/src/org/klomp/snark/TrackerClient.java

    rae89d2f r6c361679  
    314314          {
    315315            // try to contact everybody we can
    316             // We don't need I2CP connection for eepget
    317             // if (!verifyConnected()) return;
     316            // Don't try to restart I2CP connection just to say goodbye
    318317            for (Iterator iter = trackers.iterator(); iter.hasNext(); ) {
     318              if (!verifyConnected()) return;
    319319              Tracker tr = (Tracker)iter.next();
    320320              if (tr.started && (!tr.stop) && tr.trackerProblems == null)
  • apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java

    rae89d2f r6c361679  
    752752
    753753        //out.write("\n");
    754         out.write("EepProxy host: <input type=\"text\" name=\"eepHost\" value=\""
    755                   + _manager.util().getEepProxyHost() + "\" size=\"15\" /> ");
    756         out.write("port: <input type=\"text\" name=\"eepPort\" value=\""
    757                   + _manager.util().getEepProxyPort() + "\" size=\"5\" maxlength=\"5\" /><br>\n");
     754        //out.write("EepProxy host: <input type=\"text\" name=\"eepHost\" value=\""
     755        //          + _manager.util().getEepProxyHost() + "\" size=\"15\" /> ");
     756        //out.write("port: <input type=\"text\" name=\"eepPort\" value=\""
     757        //          + _manager.util().getEepProxyPort() + "\" size=\"5\" maxlength=\"5\" /><br>\n");
    758758        out.write("I2CP host: <input type=\"text\" name=\"i2cpHost\" value=\""
    759759                  + _manager.util().getI2CPHost() + "\" size=\"15\" /> ");
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java

    rae89d2f r6c361679  
    3838 *   $method $path $protocolVersion\nHost: $site
    3939 * or
    40  *   $method http://i2p/$site/$path $protocolVersion
     40 *   $method http://i2p/$b64key/$path $protocolVersion
    4141 * or
    4242 *   $method /$site/$path $protocolVersion
  • apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java

    rae89d2f r6c361679  
    1313import net.i2p.router.RouterContext;
    1414import net.i2p.util.FileUtil;
    15 import net.i2p.util.I2PThread;
     15import net.i2p.util.I2PAppThread;
    1616
    1717import org.mortbay.http.DigestAuthenticator;
     
    161161
    162162        NewsFetcher fetcher = NewsFetcher.getInstance(I2PAppContext.getGlobalContext());
    163         I2PThread t = new I2PThread(fetcher, "NewsFetcher");
     163        Thread t = new I2PAppThread(fetcher, "NewsFetcher");
    164164        t.setDaemon(true);
    165165        t.start();
    166166       
    167         I2PThread st = new I2PThread(new StatSummarizer(), "StatSummarizer");
     167        Thread st = new I2PAppThread(new StatSummarizer(), "StatSummarizer");
    168168        st.setDaemon(true);
    169169        st.start();
  • apps/routerconsole/jsp/css.jsp

    rae89d2f r6c361679  
    2323%>
    2424<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    25 <link rel="shortcut icon" href="favicon.ico">
     25<link rel="shortcut icon" href="/themes/console/images/favicon.ico">
    2626<jsp:useBean class="net.i2p.router.web.CSSHelper" id="cssHelper" scope="request" />
    2727<jsp:setProperty name="cssHelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
  • apps/routerconsole/jsp/error.jsp

    rae89d2f r6c361679  
    1515<html><head><title>I2P Router Console - Page Not Found</title>
    1616<%@include file="css.jsp" %>
    17 <link rel="shortcut icon" href="favicon.ico" /></head><body>
     17</head><body>
    1818<%
    1919if (System.getProperty("router.consoleNonce") == null) {
  • apps/streaming/java/src/net/i2p/client/streaming/ConnectionOptions.java

    rae89d2f r6c361679  
    267267            setSlowStartGrowthRateFactor(getInt(opts, PROP_SLOW_START_GROWTH_RATE_FACTOR, 2));
    268268        if (opts.containsKey(PROP_CONNECT_TIMEOUT))
     269            // wow 5 minutes!!! FIXME!!
    269270            setConnectTimeout(getInt(opts, PROP_CONNECT_TIMEOUT, Connection.DISCONNECT_TIMEOUT));
    270271        if (opts.containsKey(PROP_ANSWER_PINGS))
  • checklist.txt

    rae89d2f r6c361679  
    7474        Sync with mtn.i2p2.i2p
    7575
    76 Announce on #i2p, forum.i2p
     76Announce on #i2p, forum.i2p, freshmeat.net, launchpad.net
  • core/java/src/gnu/crypto/prng/AsyncFortunaStandalone.java

    rae89d2f r6c361679  
    1313 */
    1414public class AsyncFortunaStandalone extends FortunaStandalone implements Runnable {
    15     private static final int DEFAULT_BUFFERS = 16;
     15    /**
     16     * This is set to 2 to minimize memory usage for standalone apps.
     17     * The router must override this via the prng.buffers property in the router context.
     18     */
     19    private static final int DEFAULT_BUFFERS = 2;
    1620    private static final int BUFSIZE = 256*1024;
    1721    private int _bufferCount;
     
    2933    public AsyncFortunaStandalone(I2PAppContext context) {
    3034        super();
    31         _bufferCount = context.getProperty("router.prng.buffers", DEFAULT_BUFFERS);
     35        _bufferCount = Math.max(context.getProperty("prng.buffers", DEFAULT_BUFFERS), 2);
    3236        asyncBuffers = new byte[_bufferCount][BUFSIZE];
    3337        status = new int[_bufferCount];
  • core/java/src/net/i2p/client/I2PSessionImpl.java

    rae89d2f r6c361679  
    284284            sendMessage(new GetDateMessage());
    285285            if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "After getDate / begin waiting for a response");
     286            int waitcount = 0;
    286287            while (!_dateReceived) {
     288                if (waitcount++ > 30)
     289                    throw new IOException("no date handshake");
    287290                try {
    288291                    synchronized (_dateReceivedLock) {
     
    299302
    300303            // wait until we have created a lease set
     304            waitcount = 0;
    301305            while (_leaseSet == null) {
     306                if (waitcount++ > 5*60)
     307                    throw new IOException("no leaseset");
    302308                synchronized (_leaseSetWait) {
    303309                    try {
  • core/java/src/net/i2p/client/I2PSessionImpl2.java

    rae89d2f r6c361679  
    9292     *  and P2P apps (with generally uncompressible data) should
    9393     *  set to false.
     94     *
     95     *  Todo: don't compress if destination is local?
    9496     */
    9597    private static final int DONT_COMPRESS_SIZE = 66;
  • core/java/src/net/i2p/data/DataHelper.java

    rae89d2f r6c361679  
    799799     */
    800800    public static int hashCode(byte b[]) {
     801        // Java 5 now has its own method, and the old way
     802        // is horrible for arrays smaller than 32.
     803        // otoh, for sizes >> 32, java's method may be too slow
    801804        int rv = 0;
    802805        if (b != null) {
    803             for (int i = 0; i < b.length && i < 32; i++)
    804                 rv += (b[i] << i);
     806            if (b.length <= 32) {
     807                rv = Arrays.hashCode(b);
     808            } else {
     809                for (int i = 0; i < b.length && i < 32; i++)
     810                    rv ^= (b[i] << i);  // xor better than + in tests
     811            }
    805812        }
    806813        return rv;
     814
    807815    }
    808816
  • core/java/src/net/i2p/data/Destination.java

    rae89d2f r6c361679  
    138138    }
    139139   
     140    /** the public key has enough randomness in it to use it by itself for speed */
    140141    @Override
    141142    public int hashCode() {
    142         return DataHelper.hashCode(getCertificate()) + DataHelper.hashCode(getSigningPublicKey())
    143                + DataHelper.hashCode(getPublicKey());
     143        if (_publicKey == null)
     144            return 0;
     145        return _publicKey.hashCode();
    144146    }
    145147   
  • core/java/src/net/i2p/data/Hash.java

    rae89d2f r6c361679  
    148148    }
    149149   
     150    /** a Hash is a hash, so just use the first 4 bytes for speed */
    150151    @Override
    151152    public int hashCode() {
    152         return DataHelper.hashCode(_data);
     153        int rv = 0;
     154        if (_data != null) {
     155            for (int i = 0; i < 4; i++)
     156                rv ^= (_data[i] << (i*8));
     157        }
     158        return rv;
    153159    }
    154160   
  • core/java/src/net/i2p/data/LeaseSet.java

    rae89d2f r6c361679  
    346346    }
    347347   
     348    /** the destination has enough randomness in it to use it by itself for speed */
    348349    @Override
    349350    public int hashCode() {
    350         return DataHelper.hashCode(getEncryptionKey()) +
    351         //(int)_version +
    352                DataHelper.hashCode(_leases) + DataHelper.hashCode(getSignature())
    353                + DataHelper.hashCode(getSigningKey()) + DataHelper.hashCode(getDestination());
     351        if (_destination == null)
     352            return 0;
     353        return _destination.hashCode();
    354354    }
    355355   
  • core/java/src/net/i2p/data/PrivateKey.java

    rae89d2f r6c361679  
    7171    }
    7272   
     73    /** the key has enough randomness in it, use the first 4 bytes for speed */
    7374    @Override
    7475    public int hashCode() {
    75         return DataHelper.hashCode(_data);
     76        int rv = 0;
     77        if (_data != null) {
     78            for (int i = 0; i < 4; i++)
     79                rv ^= (_data[i] << (i*8));
     80        }
     81        return rv;
    7682    }
    7783   
  • core/java/src/net/i2p/data/PublicKey.java

    rae89d2f r6c361679  
    7373    }
    7474   
     75    /** the key has enough randomness in it, use the first 4 bytes for speed */
    7576    @Override
    7677    public int hashCode() {
    77         return DataHelper.hashCode(_data);
     78        int rv = 0;
     79        if (_data != null) {
     80            for (int i = 0; i < 4; i++)
     81                rv ^= (_data[i] << (i*8));
     82        }
     83        return rv;
    7884    }
    7985   
  • core/java/src/net/i2p/data/RouterAddress.java

    rae89d2f r6c361679  
    131131    }
    132132   
     133    /** the style should be sufficient, for speed */
    133134    @Override
    134135    public int hashCode() {
    135         return getCost() + DataHelper.hashCode(getTransportStyle()) + DataHelper.hashCode(getExpiration())
    136                + DataHelper.hashCode(getOptions());
     136        return DataHelper.hashCode(getTransportStyle());
    137137    }
    138138   
  • core/java/src/net/i2p/data/RouterIdentity.java

    rae89d2f r6c361679  
    102102    }
    103103   
     104    /** the public key has enough randomness in it to use it by itself for speed */
    104105    @Override
    105106    public int hashCode() {
    106         return DataHelper.hashCode(getCertificate()) + DataHelper.hashCode(getSigningPublicKey())
    107                + DataHelper.hashCode(getPublicKey());
     107        if (_publicKey == null)
     108            return 0;
     109        return _publicKey.hashCode();
    108110    }
    109111   
  • core/java/src/net/i2p/data/SessionKey.java

    rae89d2f r6c361679  
    7777    }
    7878   
     79    /** the key has enough randomness in it, use the first 4 bytes for speed */
    7980    @Override
    8081    public int hashCode() {
    81         return DataHelper.hashCode(_data);
     82        int rv = 0;
     83        if (_data != null) {
     84            for (int i = 0; i < 4; i++)
     85                rv ^= (_data[i] << (i*8));
     86        }
     87        return rv;
    8288    }
    8389
  • core/java/src/net/i2p/data/Signature.java

    rae89d2f r6c361679  
    6363    }
    6464   
     65    /** the sig has enough randomness in it, use the first 4 bytes for speed */
    6566    @Override
    6667    public int hashCode() {
    67         return DataHelper.hashCode(_data);
     68        int rv = 0;
     69        if (_data != null) {
     70            for (int i = 0; i < 4; i++)
     71                rv ^= (_data[i] << (i*8));
     72        }
     73        return rv;
    6874    }
    6975
  • core/java/src/net/i2p/data/SigningPrivateKey.java

    rae89d2f r6c361679  
    6969    }
    7070   
     71    /** the key has enough randomness in it, use the first 4 bytes for speed */
    7172    @Override
    7273    public int hashCode() {
    73         return DataHelper.hashCode(_data);
     74        int rv = 0;
     75        if (_data != null) {
     76            for (int i = 0; i < 4; i++)
     77                rv ^= (_data[i] << (i*8));
     78        }
     79        return rv;
    7480    }
    7581
  • core/java/src/net/i2p/data/SigningPublicKey.java

    rae89d2f r6c361679  
    6868    }
    6969
     70    /** the key has enough randomness in it, use the first 4 bytes for speed */
    7071    @Override
    7172    public int hashCode() {
    72         return DataHelper.hashCode(_data);
     73        int rv = 0;
     74        if (_data != null) {
     75            for (int i = 0; i < 4; i++)
     76                rv ^= (_data[i] << (i*8));
     77        }
     78        return rv;
    7379    }
    7480
  • core/java/src/net/i2p/util/DecayingBloomFilter.java

    rae89d2f r6c361679  
    1515 * this may be refactored to allow tighter control of the size necessary for the
    1616 * contained bloom filters, but a fixed 2MB overhead isn't that bad.
     17 *
     18 * NOTE: At 1MBps, the tunnel IVV will see an unacceptable false positive rate
     19 * of almost 0.1% with the current m and k values; however using DHS instead will use 30MB.
     20 * Further analysis and tweaking for the tunnel IVV may be required.
    1721 */
    1822public class DecayingBloomFilter {
     
    2731    private byte _longToEntry[];
    2832    private long _longToEntryMask;
    29     private long _currentDuplicates;
     33    protected long _currentDuplicates;
    3034    private boolean _keepDecaying;
    3135    private DecayEvent _decayEvent;
     36    /** just for logging */
     37    private String _name;
    3238   
    3339    private static final int DEFAULT_M = 23;
    3440    private static final boolean ALWAYS_MISS = false;
    3541   
     42    /** noop for DHS */
     43    public DecayingBloomFilter() {}
     44
    3645    /**
    3746     * Create a bloom filter that will decay its entries over time. 
     
    4352     */
    4453    public DecayingBloomFilter(I2PAppContext context, int durationMs, int entryBytes) {
     54        this(context, durationMs, entryBytes, "DBF");
     55    }
     56
     57    /** @param name just for logging / debugging / stats */
     58    public DecayingBloomFilter(I2PAppContext context, int durationMs, int entryBytes, String name) {
    4559        _context = context;
    4660        _log = context.logManager().getLog(DecayingBloomFilter.class);
    4761        _entryBytes = entryBytes;
     62        _name = name;
    4863        // this is instantiated in four different places, they may have different
    4964        // requirements, but for now use this as a gross method of memory reduction.
     
    6883        _keepDecaying = true;
    6984        SimpleTimer.getInstance().addEvent(_decayEvent, _durationMs);
     85        if (_log.shouldLog(Log.WARN))
     86           _log.warn("New DBF " + name + " m = " + m + " entryBytes = " + entryBytes +
     87                     " numExtenders = " + numExtenders + " cycle (s) = " + (durationMs / 1000));
     88        // try to get a handle on memory usage vs. false positives
     89        context.statManager().createRateStat("router.decayingBloomFilter." + name + ".size",
     90             "Size", "Router", new long[] { Math.max(60*1000, durationMs) });
     91        context.statManager().createRateStat("router.decayingBloomFilter." + name + ".dups",
     92             "1000000 * Duplicates/Size", "Router", new long[] { Math.max(60*1000, durationMs) });
     93        context.statManager().createRateStat("router.decayingBloomFilter." + name + ".log10(falsePos)",
     94             "log10 of the false positive rate (must have net.i2p.util.DecayingBloomFilter=DEBUG)",
     95             "Router", new long[] { Math.max(60*1000, durationMs) });
    7096    }
    7197   
     
    197223        int currentCount = 0;
    198224        long dups = 0;
     225        double fpr = 0d;
    199226        synchronized (this) {
    200227            BloomSHA1 tmp = _previous;
    201228            currentCount = _current.size();
     229            if (_log.shouldLog(Log.DEBUG) && currentCount > 0)
     230                fpr = _current.falsePositives();
    202231            _previous = _current;
    203232            _current = tmp;
     
    207236        }
    208237        if (_log.shouldLog(Log.DEBUG))
    209             _log.debug("Decaying the filter after inserting " + currentCount
    210                        + " elements and " + dups + " false positives");
     238            _log.debug("Decaying the filter " + _name + " after inserting " + currentCount
     239                       + " elements and " + dups + " false positives with FPR = " + fpr);
     240        _context.statManager().addRateData("router.decayingBloomFilter." + _name + ".size",
     241                                           currentCount, 0);
     242        if (currentCount > 0)
     243            _context.statManager().addRateData("router.decayingBloomFilter." + _name + ".dups",
     244                                               1000l*1000*dups/currentCount, 0);
     245        if (fpr > 0d) {
     246            // only if log.shouldLog(Log.DEBUG) ...
     247            long exponent = (long) Math.log10(fpr);
     248            _context.statManager().addRateData("router.decayingBloomFilter." + _name + ".log10(falsePos)",
     249                                               exponent, 0);
     250        }
    211251    }
    212252   
     
    220260    }
    221261   
     262    /**
     263     *  Theoretical false positive rate for   16 KBps: 1.17E-21
     264     *  Theoretical false positive rate for   24 KBps: 9.81E-20
     265     *  Theoretical false positive rate for   32 KBps: 2.24E-18
     266     *  Theoretical false positive rate for  256 KBps: 7.45E-9
     267     *  Theoretical false positive rate for  512 KBps: 5.32E-6
     268     *  Theoretical false positive rate for 1024 KBps: 1.48E-3
     269     */
    222270    public static void main(String args[]) {
    223271        int kbps = 256;
    224         int iterations = 100;
     272        int iterations = 10;
    225273        testByLong(kbps, iterations);
    226274        testByBytes(kbps, iterations);
    227275    }
    228     public static void testByLong(int kbps, int numRuns) {
     276    private static void testByLong(int kbps, int numRuns) {
    229277        int messages = 60 * 10 * kbps;
    230278        Random r = new Random();
     
    232280        int falsePositives = 0;
    233281        long totalTime = 0;
     282        double fpr = 0d;
    234283        for (int j = 0; j < numRuns; j++) {
    235284            long start = System.currentTimeMillis();
     
    241290            }
    242291            totalTime += System.currentTimeMillis() - start;
     292            fpr = filter.getFalsePositiveRate();
    243293            filter.clear();
    244294        }
    245295        filter.stopDecaying();
     296        System.out.println("False postive rate should be " + fpr);
    246297        System.out.println("After " + numRuns + " runs pushing " + messages + " entries in "
    247298                           + DataHelper.formatDuration(totalTime/numRuns) + " per run, there were "
     
    249300
    250301    }
    251     public static void testByBytes(int kbps, int numRuns) {
     302    private static void testByBytes(int kbps, int numRuns) {
    252303        byte iv[][] = new byte[60*10*kbps][16];
    253304        Random r = new Random();
     
    258309        int falsePositives = 0;
    259310        long totalTime = 0;
     311        double fpr = 0d;
    260312        for (int j = 0; j < numRuns; j++) {
    261313            long start = System.currentTimeMillis();
     
    263315                if (filter.add(iv[i])) {
    264316                    falsePositives++;
    265                     System.out.println("False positive " + falsePositives + " (testByLong j=" + j + " i=" + i + ")");
     317                    System.out.println("False positive " + falsePositives + " (testByBytes j=" + j + " i=" + i + ")");
    266318                }
    267319            }
    268320            totalTime += System.currentTimeMillis() - start;
     321            fpr = filter.getFalsePositiveRate();
    269322            filter.clear();
    270323        }
    271324        filter.stopDecaying();
     325        System.out.println("False postive rate should be " + fpr);
    272326        System.out.println("After " + numRuns + " runs pushing " + iv.length + " entries in "
    273327                           + DataHelper.formatDuration(totalTime/numRuns) + " per run, there were "
  • core/java/src/net/i2p/util/EepGet.java

    rae89d2f r6c361679  
    2828 */
    2929public class EepGet {
    30     private I2PAppContext _context;
     30    protected I2PAppContext _context;
    3131    protected Log _log;
    3232    protected boolean _shouldProxy;
     
    3636    private long _minSize; // minimum and maximum acceptable response size, -1 signifies unlimited,
    3737    private long _maxSize; // applied both against whole responses and chunks
    38     private String _outputFile;
    39     private OutputStream _outputStream;
     38    protected String _outputFile;
     39    protected OutputStream _outputStream;
    4040    /** url we were asked to fetch */
    4141    protected String _url;
     
    4848    private boolean _keepFetching;
    4949    private Socket _proxy;
    50     private OutputStream _proxyOut;
    51     private InputStream _proxyIn;
     50    protected OutputStream _proxyOut;
     51    protected InputStream _proxyIn;
    5252    protected OutputStream _out;
    53     private long _alreadyTransferred;
     53    protected long _alreadyTransferred;
    5454    private long _bytesTransferred;
    5555    protected long _bytesRemaining;
     
    6868    protected int _redirects;
    6969    protected String _redirectLocation;
     70    /** this will be replaced by the HTTP Proxy if we are using it */
     71    protected static final String USER_AGENT = "Wget/1.11.4";
     72    protected static final long CONNECT_TIMEOUT = 45*1000;
     73    protected static final long INACTIVITY_TIMEOUT = 60*1000;
    7074   
    7175    public EepGet(I2PAppContext ctx, String proxyHost, int proxyPort, int numRetries, String outputFile, String url) {
     
    119123        _headersRead = false;
    120124        _aborted = false;
    121         _fetchHeaderTimeout = 45*1000;
     125        _fetchHeaderTimeout = CONNECT_TIMEOUT;
    122126        _listeners = new ArrayList(1);
    123127        _etag = etag;
     
    135139        int markSize = 1024;
    136140        int lineLen = 40;
    137         int inactivityTimeout = 60*1000;
     141        long inactivityTimeout = INACTIVITY_TIMEOUT;
    138142        String etag = null;
    139143        String saveAs = null;
     
    184188        EepGet get = new EepGet(I2PAppContext.getGlobalContext(), true, proxyHost, proxyPort, numRetries, saveAs, url, true, etag);
    185189        get.addStatusListener(get.new CLIStatusListener(markSize, lineLen));
    186         get.fetch(45*1000, -1, inactivityTimeout);
     190        get.fetch(CONNECT_TIMEOUT, -1, inactivityTimeout);
    187191    }
    188192   
     
    217221    }
    218222   
    219     protected static void usage() {
     223    private static void usage() {
    220224        System.err.println("EepGet [-p 127.0.0.1:4444] [-n #retries] [-o outputFile] [-m markSize lineLen] [-t timeout] url");
    221225    }
     
    248252        public void attempting(String url);
    249253    }
    250     private class CLIStatusListener implements StatusListener {
     254    protected class CLIStatusListener implements StatusListener {
    251255        private int _markSize;
    252256        private int _lineSize;
     
    498502            timeout.setInactivityTimeout(_fetchInactivityTimeout);
    499503        else
    500             timeout.setInactivityTimeout(60*1000);
     504            timeout.setInactivityTimeout(INACTIVITY_TIMEOUT);
    501505       
    502506        if (_redirectLocation != null) {
     
    830834    }
    831835
    832     private void increment(byte[] lookahead, int cur) {
     836    private static void increment(byte[] lookahead, int cur) {
    833837        lookahead[0] = lookahead[1];
    834838        lookahead[1] = lookahead[2];
    835839        lookahead[2] = (byte)cur;
    836840    }
    837     private boolean isEndOfHeaders(byte lookahead[]) {
     841    private static boolean isEndOfHeaders(byte lookahead[]) {
    838842        byte first = lookahead[0];
    839843        byte second = lookahead[1];
     
    845849    /** we ignore any potential \r, since we trim it on write anyway */
    846850    private static final byte NL = '\n';
    847     private boolean isNL(byte b) { return (b == NL); }
     851    private static boolean isNL(byte b) { return (b == NL); }
    848852
    849853    protected void sendRequest(SocketTimeout timeout) throws IOException {
     
    896900   
    897901    protected String getRequest() throws IOException {
    898         StringBuilder buf = new StringBuilder(512);
     902        StringBuilder buf = new StringBuilder(2048);
    899903        boolean post = false;
    900904        if ( (_postData != null) && (_postData.length() > 0) )
     
    907911        String query = url.getQuery();
    908912        if (query != null)
    909             path = path + "?" + query;
     913            path = path + '?' + query;
    910914        if (!path.startsWith("/"))
    911915            path = "/" + path;
     
    924928            buf.append("-\r\n");
    925929        }
    926         buf.append("Accept-Encoding: \r\n");
    927930        if (_shouldProxy)
    928931            buf.append("X-Accept-Encoding: x-i2p-gzip;q=1.0, identity;q=0.5, deflate;q=0, gzip;q=0, *;q=0\r\n");
    929932        if (!_allowCaching) {
    930             buf.append("Cache-control: no-cache\r\n");
    931             buf.append("Pragma: no-cache\r\n");
     933            buf.append("Cache-control: no-cache\r\n" +
     934                       "Pragma: no-cache\r\n");
    932935        }
    933936        if ((_etag != null) && (_alreadyTransferred <= 0)) {
     
    943946        if (post)
    944947            buf.append("Content-length: ").append(_postData.length()).append("\r\n");
    945         buf.append("Connection: close\r\n\r\n");
     948        // This will be replaced if we are going through I2PTunnelHTTPClient
     949        buf.append("User-Agent: " + USER_AGENT + "\r\n" +
     950                   "Accept-Encoding: \r\n" +
     951                   "Connection: close\r\n\r\n");
    946952        if (post)
    947953            buf.append(_postData);
  • core/java/src/net/i2p/util/EepGetScheduler.java

    rae89d2f r6c361679  
    88
    99/**
    10  *
     10 *  @deprecated unused a webapp version would be nice though
    1111 */
    1212public class EepGetScheduler implements EepGet.StatusListener {
  • core/java/src/net/i2p/util/EepHead.java

    rae89d2f r6c361679  
    9494    }
    9595   
    96     protected static void usage() {
     96    private static void usage() {
    9797        System.err.println("EepHead [-p 127.0.0.1:4444] [-n #retries] [-t timeout] url");
    9898    }
     
    192192        if (_shouldProxy)
    193193            buf.append("X-Accept-Encoding: x-i2p-gzip;q=1.0, identity;q=0.5, deflate;q=0, gzip;q=0, *;q=0\r\n");
     194        // This will be replaced if we are going through I2PTunnelHTTPClient
     195        buf.append("User-Agent: " + USER_AGENT + "\r\n");
    194196        buf.append("Connection: close\r\n\r\n");
    195197        if (_log.shouldLog(Log.DEBUG))
  • core/java/src/net/i2p/util/SocketTimeout.java

    rae89d2f r6c361679  
    66import java.util.Date;
    77
     8/**
     9 *  This should be deprecated.
     10 *  It is only used by EepGet, and it uses the inefficient SimpleTimer.
     11 *  The only advantage seems to be a total timeout period, which is the second
     12 *  argument to EepGet.fetch(headerTimeout, totalTimeout, inactivityTimeout),
     13 *  which is most likely always set to -1.
     14 *
     15 *  Use socket.setsotimeout instead?
     16 */
    817public class SocketTimeout implements SimpleTimer.TimedEvent {
    918    private Socket _targetSocket;
  • history.txt

    rae89d2f r6c361679  
     12009-08-28 zzz
     2    * Client: Fail if no date handshake after 30s or no leaseset
     3      after 5m, rather than hanging forever.
     4    * Console:
     5      - Prevent OOMs in NewsFetcher or StatsSummarizer from
     6        killing the router
     7      - Fix favicon (-17)
     8    * Data: Speed up many hashcodes
     9    * DataHelper: Fix byte array hashcode for small arrays
     10    * DecayingBloomFilter:
     11      - Replace with new DecayingHashSet for 3 of 4 uses,
     12        and also in the 4th if the router is low-bandwidth.
     13        Saves 8 MB heap.
     14    * EepGet, I2PSnark:
     15      - New I2PSocketEepGet fetches through existing tunnels
     16        rather than through the proxy
     17      - Use new eepget for i2psnark
     18      - Add a fake user agent for non-proxied fetches
     19      - Cleanups
     20    * NetDb:
     21      - oops, store leaseset locally even when shutting down
     22        (fix -16)
     23      - Java 5 cleanups
     24    * PRNG:
     25      - Rename config option to prng.buffers (was router.prng.buffers)
     26      - Change the default from 16 to 2 for I2PAppContext (saves 3.5MB)
     27    * Tunnel:
     28      - Adjust the random drop probability for the message size
     29      - Concurrentify HashSetIVValidator
     30    * TunnelPool:
     31      - Don't test tunnels when shutting down
     32      - Less rates
     33      - Java 5 cleanups
     34
    1352009-08-24 zzz
    236    * ClientManager:
  • router/java/src/net/i2p/router/MessageValidator.java

    rae89d2f r6c361679  
    22
    33import net.i2p.util.DecayingBloomFilter;
     4import net.i2p.util.DecayingHashSet;
    45import net.i2p.util.Log;
    56
     
    9697   
    9798    public void startup() {
    98         _filter = new DecayingBloomFilter(_context, (int)Router.CLOCK_FUDGE_FACTOR * 2, 8);
     99        _filter = new DecayingHashSet(_context, (int)Router.CLOCK_FUDGE_FACTOR * 2, 8, "RouterMV");
    99100    }
    100101   
  • router/java/src/net/i2p/router/Router.java

    rae89d2f r6c361679  
    331331       
    332332        // let the timestamper get us sync'ed
     333        // this will block for quite a while on a disconnected machine
    333334        long before = System.currentTimeMillis();
    334335        _context.clock().getTimestamper().waitForInitialization();
  • router/java/src/net/i2p/router/RouterContext.java

    rae89d2f r6c361679  
    7676        _contexts.add(this);
    7777    }
    78     /**
     78
     79    /**
     80     * Set properties where the defaults must be different from those
     81     * in I2PAppContext.
     82     *
    7983     * Unless we are explicitly disabling the timestamper, we want to use it.
    8084     * We need this now as the new timestamper default is disabled (so we don't
    8185     * have each I2PAppContext creating their own SNTP queries all the time)
    8286     *
    83      */
    84     static final Properties filterProps(Properties envProps) {
     87     * Set more PRNG buffers, as the default is now small for the I2PAppContext.
     88     *
     89     */
     90    private static final Properties filterProps(Properties envProps) {
    8591        if (envProps == null)
    8692            envProps = new Properties();
    8793        if (envProps.getProperty("time.disabled") == null)
    8894            envProps.setProperty("time.disabled", "false");
     95        if (envProps.getProperty("prng.buffers") == null)
     96            envProps.setProperty("prng.buffers", "16");
    8997        return envProps;
    9098    }
     99
    91100    public void initAll() {
    92101        if ("false".equals(getProperty("i2p.dummyClientFacade", "false")))
  • router/java/src/net/i2p/router/RouterVersion.java

    rae89d2f r6c361679  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 17;
     21    public final static long BUILD = 18;
    2222    /** for example "-test" */
    2323    public final static String EXTRA = "";
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    rae89d2f r6c361679  
    5757    /** where the data store is pushing the data */
    5858    private String _dbDir;
    59     private final Set _exploreKeys = new HashSet(64); // set of Hash objects that we should search on (to fill up a bucket, not to get data)
     59    private final Set<Hash> _exploreKeys = new HashSet(64); // set of Hash objects that we should search on (to fill up a bucket, not to get data)
    6060    private boolean _initialized;
    6161    /** Clock independent time of when we started up */
     
    7373     *
    7474     */
    75     private final Map _publishingLeaseSets;
     75    private final Map<Hash, RepublishLeaseSetJob> _publishingLeaseSets;
    7676   
    7777    /**
     
    8181     *
    8282     */
    83     private final Map _activeRequests;
     83    private final Map<Hash, SearchJob> _activeRequests;
    8484   
    8585    /**
     
    161161    }
    162162   
    163     public Set getExploreKeys() {
     163    public Set<Hash> getExploreKeys() {
    164164        if (!_initialized) return null;
    165165        synchronized (_exploreKeys) {
     
    303303     * Get the routers closest to that key in response to a remote lookup
    304304     */
    305     public Set findNearestRouters(Hash key, int maxNumRouters, Set peersToIgnore) {
     305    public Set<RouterInfo> findNearestRouters(Hash key, int maxNumRouters, Set peersToIgnore) {
    306306        if (!_initialized) return null;
    307307        return getRouters(_peerSelector.selectNearest(key, maxNumRouters, peersToIgnore, _kb));
    308308    }
    309309   
    310     private Set getRouters(Collection hashes) {
     310    private Set<RouterInfo> getRouters(Collection hashes) {
    311311        if (!_initialized) return null;
    312312        Set rv = new HashSet(hashes.size());
     
    482482    public void publish(LeaseSet localLeaseSet) {
    483483        if (!_initialized) return;
    484         if (_context.router().gracefulShutdownInProgress())
    485             return;
    486484        Hash h = localLeaseSet.getDestination().calculateHash();
    487485        try {
     
    493491        if (!_context.clientManager().shouldPublishLeaseSet(h))
    494492            return;
     493        // If we're exiting, don't publish.
     494        // If we're restarting, keep publishing to minimize the downtime.
     495        if (_context.router().gracefulShutdownInProgress()) {
     496            int code = _context.router().scheduledGracefulExitCode();
     497            if (code == Router.EXIT_GRACEFUL || code == Router.EXIT_HARD)
     498                return;
     499        }
    495500       
    496501        RepublishLeaseSetJob j = null;
     
    856861        return leases;
    857862    }
    858     private Set getRouters() {
     863    private Set<RouterInfo> getRouters() {
    859864        if (!_initialized) return null;
    860865        Set routers = new HashSet();
  • router/java/src/net/i2p/router/transport/udp/InboundMessageFragments.java

    rae89d2f r6c361679  
    66import net.i2p.router.RouterContext;
    77import net.i2p.util.DecayingBloomFilter;
     8import net.i2p.util.DecayingHashSet;
    89import net.i2p.util.Log;
    910
     
    5354        // array size (currently its tuned for 10 minute rates for the
    5455        // messageValidator)
    55         _recentlyCompletedMessages = new DecayingBloomFilter(_context, DECAY_PERIOD, 4);
     56        _recentlyCompletedMessages = new DecayingHashSet(_context, DECAY_PERIOD, 4, "UDPIMF");
    5657        _ackSender.startup();
    5758        _messageReceiver.startup();
  • router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java

    rae89d2f r6c361679  
    11package net.i2p.router.tunnel;
    22
    3 import net.i2p.I2PAppContext;
    43import net.i2p.data.ByteArray;
    54import net.i2p.data.DataHelper;
     5import net.i2p.router.RouterContext;
    66import net.i2p.util.ByteCache;
    77import net.i2p.util.DecayingBloomFilter;
     8import net.i2p.util.DecayingHashSet;
    89
    910/**
     
    1314 */
    1415public class BloomFilterIVValidator implements IVValidator {
    15     private I2PAppContext _context;
     16    private RouterContext _context;
    1617    private DecayingBloomFilter _filter;
    1718    private ByteCache _ivXorCache = ByteCache.getInstance(32, HopProcessor.IV_LENGTH);
     
    2425     */
    2526    private static final int HALFLIFE_MS = 10*60*1000;
    26     public BloomFilterIVValidator(I2PAppContext ctx, int KBps) {
     27    private static final int MIN_SHARE_KBPS_TO_USE_BLOOM = 64;
     28
     29    public BloomFilterIVValidator(RouterContext ctx, int KBps) {
    2730        _context = ctx;
    28         _filter = new DecayingBloomFilter(ctx, HALFLIFE_MS, 16);
     31        // Select the filter based on share bandwidth.
     32        // Note that at rates approaching 1MB, we need to do something else,
     33        // as the Bloom filter false positive rates approach 0.1%. FIXME
     34        if (getShareBandwidth(ctx) < MIN_SHARE_KBPS_TO_USE_BLOOM)
     35            _filter = new DecayingHashSet(ctx, HALFLIFE_MS, 16, "TunnelIVV"); // appx. 4MB max
     36        else
     37            _filter = new DecayingBloomFilter(ctx, HALFLIFE_MS, 16, "TunnelIVV");  // 2MB fixed
    2938        ctx.statManager().createRateStat("tunnel.duplicateIV", "Note that a duplicate IV was received", "Tunnels",
    3039                                         new long[] { 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     
    4049    }
    4150    public void destroy() { _filter.stopDecaying(); }
     51
     52    private static int getShareBandwidth(RouterContext ctx) {
     53        int irateKBps = ctx.bandwidthLimiter().getInboundKBytesPerSecond();
     54        int orateKBps = ctx.bandwidthLimiter().getOutboundKBytesPerSecond();
     55        double pct = ctx.router().getSharePercentage();
     56        return (int) (pct * Math.min(irateKBps, orateKBps));
     57    }
    4258}
  • router/java/src/net/i2p/router/tunnel/BuildMessageProcessor.java

    rae89d2f r6c361679  
    1111import net.i2p.data.i2np.TunnelBuildMessage;
    1212import net.i2p.util.DecayingBloomFilter;
     13import net.i2p.util.DecayingHashSet;
    1314import net.i2p.util.Log;
    1415
     
    2324   
    2425    public BuildMessageProcessor(I2PAppContext ctx) {
    25         _filter = new DecayingBloomFilter(ctx, 60*1000, 32);
     26        _filter = new DecayingHashSet(ctx, 60*1000, 32, "TunnelBMP");
    2627        ctx.statManager().createRateStat("tunnel.buildRequestDup", "How frequently we get dup build request messages", "Tunnels", new long[] { 60*1000, 10*60*1000 });
    2728    }
  • router/java/src/net/i2p/router/tunnel/HashSetIVValidator.java

    rae89d2f r6c361679  
    11package net.i2p.router.tunnel;
    22
    3 import java.util.HashSet;
     3import java.util.Set;
    44
    55import net.i2p.data.ByteArray;
    66import net.i2p.data.DataHelper;
     7import net.i2p.util.ConcurrentHashSet;
    78
    89/**
     
    1011 */
    1112class HashSetIVValidator implements IVValidator {
    12     private final HashSet _received;
     13    private final Set<ByteArray> _received;
    1314   
    1415    public HashSetIVValidator() {
    15         _received = new HashSet();
     16        _received = new ConcurrentHashSet();
    1617    }
    1718   
     
    2223        DataHelper.xor(ivData, ivOffset, payload, payloadOffset, iv, 0, HopProcessor.IV_LENGTH);
    2324        ByteArray ba = new ByteArray(iv);
    24         boolean isNew = false;
    25         synchronized (_received) {
    26             isNew = _received.add(ba);
    27         }
     25        boolean isNew = _received.add(ba);
    2826        return isNew;
    2927    }
  • router/java/src/net/i2p/router/tunnel/InboundGatewayReceiver.java

    rae89d2f r6c361679  
    3636        }
    3737       
    38         if (_context.tunnelDispatcher().shouldDropParticipatingMessage())
     38        if (_context.tunnelDispatcher().shouldDropParticipatingMessage("IBGW", encrypted.length))
    3939            return -1;
    4040        _config.incrementSentMessages();
  • router/java/src/net/i2p/router/tunnel/OutboundTunnelEndpoint.java

    rae89d2f r6c361679  
    4444            // don't drop it if we are the target
    4545            if ((!_context.routerHash().equals(toRouter)) &&
    46                 _context.tunnelDispatcher().shouldDropParticipatingMessage())
     46                _context.tunnelDispatcher().shouldDropParticipatingMessage("OBEP " + msg.getType(), msg.getMessageSize()))
    4747                return;
    4848            _config.incrementSentMessages();
  • router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java

    rae89d2f r6c361679  
    541541     * We drop in proportion to how far over the limit we are.
    542542     * Perhaps an exponential function would be better?
    543      */
    544     public boolean shouldDropParticipatingMessage() {
     543     *
     544     * The drop probability is adjusted for the size of the message.
     545     * At this stage, participants and IBGWs see a standard 1024 byte message.
     546     * OBEPs however may see a wide variety of sizes.
     547     *
     548     * Network-wise, it's most efficient to drop OBEP messages, because they
     549     * are unfragmented and we know their size. Therefore we drop the big ones
     550     * and we drop a single wrapped I2CP message, not a fragment of one or more messages.
     551     * Also, the OBEP is the earliest identifiable hop in the message's path
     552     * (a plain participant could be earlier or later, but on average is later)
     553     *
     554     * @param type message hop location and type
     555     * @param length the length of the message
     556     */
     557    public boolean shouldDropParticipatingMessage(String type, int length) {
     558        if (length <= 0)
     559            return false;
    545560        RateStat rs = _context.statManager().getRate("tunnel.participatingBandwidth");
    546561        if (rs == null)
     
    575590        if (pctDrop <= 0)
    576591            return false;
     592        // increase the drop probability for OBEP,
     593        // and lower it for IBGW, for network efficiency
     594        double len = length;
     595        if (type.startsWith("OBEP"))
     596            len *= 1.5;
     597        else if (type.startsWith("IBGW"))
     598            len /= 1.5;
     599        // drop in proportion to size w.r.t. a standard 1024-byte message
     600        // this is a little expensive but we want to adjust the curve between 0 and 1
     601        // Most messages are 1024, only at the OBEP do we see other sizes
     602        if (len != 1024d)
     603            pctDrop = (float) Math.pow(pctDrop, 1024d / len);
    577604        float rand = _context.random().nextFloat();
    578605        boolean reject = rand <= pctDrop;
     
    581608                int availBps = (int) (((maxKBps*1024)*share) - used);
    582609                _log.warn("Drop part. msg. avail/max/used " + availBps + "/" + (int) maxBps + "/"
    583                           + used + " %Drop = " + pctDrop);
     610                          + used + " %Drop = " + pctDrop
     611                          + ' ' + type + ' ' + length);
    584612            }
    585613            _context.statManager().addRateData("tunnel.participatingMessageDropped", 1, 0);
  • router/java/src/net/i2p/router/tunnel/TunnelParticipant.java

    rae89d2f r6c361679  
    151151
    152152    private void send(HopConfig config, TunnelDataMessage msg, RouterInfo ri) {
    153         if (_context.tunnelDispatcher().shouldDropParticipatingMessage())
     153        if (_context.tunnelDispatcher().shouldDropParticipatingMessage("TDM", 1024))
    154154            return;
    155155        _config.incrementSentMessages();
  • router/java/src/net/i2p/router/tunnel/pool/TestJob.java

    rae89d2f r6c361679  
    3232    /** base to randomize the test delay on */
    3333    private static final int TEST_DELAY = 30*1000;
     34    private static final long[] RATES = { 60*1000, 10*60*1000l, 60*60*1000l };
    3435   
    3536    public TestJob(RouterContext ctx, PooledTunnelCreatorConfig cfg, TunnelPool pool) {
     
    4445        getTiming().setStartAfter(getDelay() + ctx.clock().now());
    4546        ctx.statManager().createRateStat("tunnel.testFailedTime", "How long did the failure take (max of 60s for full timeout)?", "Tunnels",
    46                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     47                                         RATES);
    4748        ctx.statManager().createRateStat("tunnel.testExploratoryFailedTime", "How long did the failure of an exploratory tunnel take (max of 60s for full timeout)?", "Tunnels",
    48                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     49                                         RATES);
    4950        ctx.statManager().createRateStat("tunnel.testFailedCompletelyTime", "How long did the complete failure take (max of 60s for full timeout)?", "Tunnels",
    50                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     51                                         RATES);
    5152        ctx.statManager().createRateStat("tunnel.testExploratoryFailedCompletelyTime", "How long did the complete failure of an exploratory tunnel take (max of 60s for full timeout)?", "Tunnels",
    52                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     53                                         RATES);
    5354        ctx.statManager().createRateStat("tunnel.testSuccessLength", "How long were the tunnels that passed the test?", "Tunnels",
    54                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     55                                         RATES);
    5556        ctx.statManager().createRateStat("tunnel.testSuccessTime", "How long did tunnel testing take?", "Tunnels",
    56                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     57                                         RATES);
    5758        ctx.statManager().createRateStat("tunnel.testAborted", "Tunnel test could not occur, since there weren't any tunnels to test with", "Tunnels",
    58                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     59                                         RATES);
    5960    }
    6061    public String getName() { return "Test tunnel"; }
     
    7071            return;
    7172        }
     73        if (getContext().router().gracefulShutdownInProgress())
     74            return;   // don't reschedule
    7275        _found = false;
    7376        // note: testing with exploratory tunnels always, even if the tested tunnel
  • router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java

    rae89d2f r6c361679  
    3838    private Log _log;
    3939    /** Hash (destination) to TunnelPool */
    40     private final Map _clientInboundPools;
     40    private final Map<Hash, TunnelPool> _clientInboundPools;
    4141    /** Hash (destination) to TunnelPool */
    42     private final Map _clientOutboundPools;
     42    private final Map<Hash, TunnelPool> _clientOutboundPools;
    4343    private TunnelPool _inboundExploratory;
    4444    private TunnelPool _outboundExploratory;
     
    9191        TunnelPool pool = null;
    9292        synchronized (_clientInboundPools) {
    93             pool = (TunnelPool)_clientInboundPools.get(destination);
     93            pool = _clientInboundPools.get(destination);
    9494        }
    9595        if (pool != null) {
     
    120120        TunnelPool pool = null;
    121121        synchronized (_clientOutboundPools) {
    122             pool = (TunnelPool)_clientOutboundPools.get(destination);
     122            pool = _clientOutboundPools.get(destination);
    123123        }
    124124        if (pool != null) {
     
    131131        TunnelInfo info = null;
    132132        synchronized (_clientInboundPools) {
    133             for (Iterator iter = _clientInboundPools.values().iterator(); iter.hasNext(); ) {
    134                 TunnelPool pool = (TunnelPool)iter.next();
     133            for (Iterator<TunnelPool> iter = _clientInboundPools.values().iterator(); iter.hasNext(); ) {
     134                TunnelPool pool = iter.next();
    135135                info = pool.getTunnel(id);
    136136                if (info != null)
     
    167167            TunnelPool pool = null;
    168168            synchronized (_clientInboundPools) {
    169                 pool = (TunnelPool)_clientInboundPools.get(client);
     169                pool = _clientInboundPools.get(client);
    170170            }
    171171            count += pool.listTunnels().size();
     
    183183            TunnelPool pool = null;
    184184            synchronized (_clientOutboundPools) {
    185                 pool = (TunnelPool)_clientOutboundPools.get(client);
     185                pool = _clientOutboundPools.get(client);
    186186            }
    187187            count += pool.listTunnels().size();
     
    197197        TunnelPool pool;
    198198        if (tunnel.isInbound())
    199             pool = (TunnelPool)_clientInboundPools.get(client);
     199            pool = _clientInboundPools.get(client);
    200200        else
    201             pool = (TunnelPool)_clientOutboundPools.get(client);
     201            pool = _clientOutboundPools.get(client);
    202202        if (pool == null)
    203203            return false;
     
    212212        TunnelPool pool = null;
    213213        synchronized (_clientInboundPools) {
    214             pool = (TunnelPool)_clientInboundPools.get(client);
     214            pool = _clientInboundPools.get(client);
    215215        }
    216216        if (pool != null)
     
    222222        TunnelPool pool = null;
    223223        synchronized (_clientOutboundPools) {
    224             pool = (TunnelPool)_clientOutboundPools.get(client);
     224            pool = _clientOutboundPools.get(client);
    225225        }
    226226        if (pool != null)
     
    235235        setSettings(_clientOutboundPools, client, settings);
    236236    }
    237     private void setSettings(Map pools, Hash client, TunnelPoolSettings settings) {
     237    private void setSettings(Map<Hash, TunnelPool> pools, Hash client, TunnelPoolSettings settings) {
    238238        TunnelPool pool = null;
    239239        synchronized (pools) {
    240             pool = (TunnelPool)pools.get(client);
     240            pool = pools.get(client);
    241241        }
    242242        if (pool != null) {
     
    261261        // should we share the clientPeerSelector across both inbound and outbound?
    262262        synchronized (_clientInboundPools) {
    263             inbound = (TunnelPool)_clientInboundPools.get(dest);
     263            inbound = _clientInboundPools.get(dest);
    264264            if (inbound == null) {
    265265                inbound = new TunnelPool(_context, this, settings.getInboundSettings(),
     
    271271        }
    272272        synchronized (_clientOutboundPools) {
    273             outbound = (TunnelPool)_clientOutboundPools.get(dest);
     273            outbound = _clientOutboundPools.get(dest);
    274274            if (outbound == null) {
    275275                outbound = new TunnelPool(_context, this, settings.getOutboundSettings(),
     
    295295        TunnelPool outbound = null;
    296296        synchronized (_clientInboundPools) {
    297             inbound = (TunnelPool)_clientInboundPools.remove(destination);
     297            inbound = _clientInboundPools.remove(destination);
    298298        }
    299299        synchronized (_clientOutboundPools) {
    300             outbound = (TunnelPool)_clientOutboundPools.remove(destination);
     300            outbound = _clientOutboundPools.remove(destination);
    301301        }
    302302        if (inbound != null)
     
    306306    }
    307307   
     308    /** queue a recurring test job if appropriate */
    308309    void buildComplete(PooledTunnelCreatorConfig cfg) {
    309         buildComplete();
    310         if (cfg.getLength() > 1) {
     310        //buildComplete();
     311        if (cfg.getLength() > 1 &&
     312            !_context.router().gracefulShutdownInProgress()) {
    311313            TunnelPool pool = cfg.getTunnelPool();
    312314            if (pool == null) {
     315                // never seen this before, do we reallly need to bother
     316                // trying so hard to find his pool?
    313317                _log.error("How does this not have a pool?  " + cfg, new Exception("baf"));
    314318                if (cfg.getDestination() != null) {
    315319                    if (cfg.isInbound()) {
    316320                        synchronized (_clientInboundPools) {
    317                             pool = (TunnelPool)_clientInboundPools.get(cfg.getDestination());
     321                            pool = _clientInboundPools.get(cfg.getDestination());
    318322                        }
    319323                    } else {
    320324                        synchronized (_clientOutboundPools) {
    321                             pool = (TunnelPool)_clientOutboundPools.get(cfg.getDestination());
     325                            pool = _clientOutboundPools.get(cfg.getDestination());
    322326                        }
    323327                    }
     
    334338        }
    335339    }
     340
     341    /** ?? */
    336342    void buildComplete() {}
    337343   
     
    385391   
    386392    /** list of TunnelPool instances currently in play */
    387     void listPools(List out) {
     393    void listPools(List<TunnelPool> out) {
    388394        synchronized (_clientInboundPools) {
    389395            out.addAll(_clientInboundPools.values());
     
    408414        renderPool(out, _inboundExploratory, _outboundExploratory);
    409415       
    410         List destinations = null;
     416        List<Hash> destinations = null;
    411417        synchronized (_clientInboundPools) {
    412418            destinations = new ArrayList(_clientInboundPools.keySet());
    413419        }
    414420        for (int i = 0; i < destinations.size(); i++) {
    415             Hash client = (Hash)destinations.get(i);
     421            Hash client = destinations.get(i);
    416422            TunnelPool in = null;
    417423            TunnelPool outPool = null;
    418424            synchronized (_clientInboundPools) {
    419                 in = (TunnelPool)_clientInboundPools.get(client);
     425                in = _clientInboundPools.get(client);
    420426            }
    421427            synchronized (_clientOutboundPools) {
    422                 outPool = (TunnelPool)_clientOutboundPools.get(client);
     428                outPool = _clientOutboundPools.get(client);
    423429            }
    424430            String name = (in != null ? in.getSettings().getDestinationNickname() : null);
     
    506512
    507513    private void renderPool(Writer out, TunnelPool in, TunnelPool outPool) throws IOException {
    508         List tunnels = null;
     514        List<TunnelInfo> tunnels = null;
    509515        if (in == null)
    510516            tunnels = new ArrayList();
     
    520526        int maxLength = 1;
    521527        for (int i = 0; i < tunnels.size(); i++) {
    522             TunnelInfo info = (TunnelInfo)tunnels.get(i);
     528            TunnelInfo info = tunnels.get(i);
    523529            if (info.getLength() > maxLength)
    524530                maxLength = info.getLength();
     
    537543        out.write("</tr>\n");
    538544        for (int i = 0; i < tunnels.size(); i++) {
    539             TunnelInfo info = (TunnelInfo)tunnels.get(i);
     545            TunnelInfo info = tunnels.get(i);
    540546            long timeLeft = info.getExpiration()-_context.clock().now();
    541547            if (timeLeft <= 0)
Note: See TracChangeset for help on using the changeset viewer.