Changes in / [5ca2f306:d868f7c0]


Ignore:
Files:
4 added
65 edited

Legend:

Unmodified
Added
Removed
  • android/res/raw/router_config

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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
     
    844844                if (filename.endsWith(".css"))
    845845                    type = "text/css";
     846                else if (filename.endsWith(".ico"))
     847                    type = "image/x-icon";
    846848                else if (filename.endsWith(".png"))
    847849                    type = "image/png";
  • apps/i2ptunnel/jsp/edit.jsp

    r5ca2f306 rd868f7c0  
     1<%@page pageEncoding="UTF-8"%>
    12<%@page contentType="text/html" import="net.i2p.i2ptunnel.web.EditBean" %><%
    23String tun = request.getParameter("tunnel");
  • apps/i2ptunnel/jsp/index.jsp

    r5ca2f306 rd868f7c0  
     1<%
     2    // http://www.crazysquirrel.com/computing/general/form-encoding.jspx
     3    if (request.getCharacterEncoding() == null)
     4        request.setCharacterEncoding("UTF-8");
     5%>
     6<%@page pageEncoding="UTF-8"%>
    17<%@page contentType="text/html" import="net.i2p.i2ptunnel.web.IndexBean"%><?xml version="1.0" encoding="UTF-8"?>
    28<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     
    713    <title>I2P Tunnel Manager - List</title>
    814   
    9     <meta htt
    10 p-equiv="Content-Type" content="text/html; charset=UTF-8" />
     15    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    1116    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
     17    <link href="/themes/console/images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
    1218   
    1319    <% if (indexBean.allowCSS()) {
    14   %><link href="/themes/console/images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
    15     <link href="<%=indexBean.getTheme()%>default.css" rel="stylesheet" type="text/css" />
     20  %><link href="<%=indexBean.getTheme()%>default.css" rel="stylesheet" type="text/css" />
    1621    <link href="<%=indexBean.getTheme()%>i2ptunnel.css" rel="stylesheet" type="text/css" />
    1722    <% }
  • apps/ministreaming/java/build.xml

    r5ca2f306 rd868f7c0  
    2424        <mkdir dir="./build" />
    2525        <mkdir dir="./build/obj" />
    26         <javac srcdir="./src" debug="true" deprecation="on" source="1.5" target="1.5" destdir="./build/obj" classpath="../../../core/java/build/i2p.jar" >
     26        <!-- half of this is deprecated classes so turn deprecation off -->
     27        <javac srcdir="./src" debug="true" deprecation="off" source="1.5" target="1.5" destdir="./build/obj" classpath="../../../core/java/build/i2p.jar" >
    2728            <compilerarg line="${javac.compilerargs}" />
    2829        </javac>
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigTunnelsHelper.java

    r5ca2f306 rd868f7c0  
    155155
    156156        // custom options
    157         buf.append("<tr><td align=\"right\" class=\"mediumtags\">Inbound options:</td>\n");
    158         buf.append("<td colspan=\"2\" align=\"center\"><input name=\"").append(index);
    159         buf.append(".inboundOptions\" type=\"text\" size=\"32\" ");
    160         buf.append("value=\"");
     157        // There is no facility to set these, either in ConfigTunnelsHandler or
     158        // TunnelPoolOptions, so make the boxes readonly.
     159        // And let's not display them at all unless they have contents, which should be rare.
    161160        Properties props = in.getUnknownOptions();
    162         for (Iterator iter = props.keySet().iterator(); iter.hasNext(); ) {
    163             String prop = (String)iter.next();
    164             String val = (String)props.getProperty(prop);
    165             buf.append(prop).append("=").append(val).append(" ");
    166         }
    167         buf.append("\"/></td></tr>\n");
    168         buf.append("<tr><td align=\"right\" class=\"mediumtags\">Outbound options:</td>\n");
    169         buf.append("<td colspan=\"2\" align=\"center\"><input name=\"").append(index);
    170         buf.append(".outboundOptions\" type=\"text\" size=\"32\" ");
    171         buf.append("value=\"");
    172         props = in.getUnknownOptions();
    173         for (Iterator iter = props.keySet().iterator(); iter.hasNext(); ) {
    174             String prop = (String)iter.next();
    175             String val = (String)props.getProperty(prop);
    176             buf.append(prop).append("=").append(val).append(" ");
    177         }
    178         buf.append("\"/></td></tr>\n");
     161        if (props.size() > 0) {
     162            buf.append("<tr><td align=\"right\" class=\"mediumtags\">Inbound options:</td>\n" +
     163                       "<td colspan=\"2\" align=\"center\"><input name=\"").append(index);
     164            buf.append(".inboundOptions\" type=\"text\" size=\"32\" disabled=\"true\" " +
     165                       "value=\"");
     166            for (Iterator iter = props.keySet().iterator(); iter.hasNext(); ) {
     167                String prop = (String)iter.next();
     168                String val = (String)props.getProperty(prop);
     169                buf.append(prop).append('=').append(val).append(' ');
     170            }
     171            buf.append("\"></td></tr>\n");
     172        }
     173        props = out.getUnknownOptions();
     174        if (props.size() > 0) {
     175            buf.append("<tr><td align=\"right\" class=\"mediumtags\">Outbound options:</td>\n" +
     176                       "<td colspan=\"2\" align=\"center\"><input name=\"").append(index);
     177            buf.append(".outboundOptions\" type=\"text\" size=\"32\" disabled=\"true\" " +
     178                       "value=\"");
     179            for (Iterator iter = props.keySet().iterator(); iter.hasNext(); ) {
     180                String prop = (String)iter.next();
     181                String val = (String)props.getProperty(prop);
     182                buf.append(prop).append('=').append(val).append(' ');
     183            }
     184            buf.append("\"></td></tr>\n");
     185        }
    179186//        buf.append("<tr><td colspan=\"3\"><br></td></tr>\n");
    180187    }
  • apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    33    * This should be included inside <head>...</head>,
    44    * as it sets the stylesheet.
     5    *
     6    * This is included almost 30 times, so keep whitespace etc. to a minimum.
    57    */
     8
     9   // http://www.crazysquirrel.com/computing/general/form-encoding.jspx
     10   if (request.getCharacterEncoding() == null)
     11       request.setCharacterEncoding("UTF-8");
    612
    713   response.setHeader("Pragma", "no-cache");
     
    1622   }
    1723%>
     24<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     25<link rel="shortcut icon" href="/themes/console/images/favicon.ico">
    1826<jsp:useBean class="net.i2p.router.web.CSSHelper" id="cssHelper" scope="request" />
    1927<jsp:setProperty name="cssHelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
  • apps/routerconsole/jsp/debug.jsp

    r5ca2f306 rd868f7c0  
    22<%@page pageEncoding="UTF-8"%>
    33<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    4 <html><head><title>DEBUG</title>
     4<html><head><title>I2P Router Console - Debug</title>
    55<%@include file="css.jsp" %>
    66</head><body>
    77<%@include file="summary.jsp" %>
     8<h1>Router SKM</h1>
    89<div class="main" id="main">
    910<%
     
    1617     *  Print out the status for all the SessionKeyManagers
    1718     */
    18     out.print("<h1>Router SKM</h1>");
     19
    1920    ctx.sessionKeyManager().renderStatusHTML(out);
    2021    java.util.Set<net.i2p.data.Destination> clients = ctx.clientManager().listClients();
  • apps/routerconsole/jsp/error.jsp

    r5ca2f306 rd868f7c0  
    1313    // If it can't find the iframe or viewtheme.jsp I wonder if the whole thing blows up...
    1414%>
    15 <html><head><title>I2P Router Console</title>
    16 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
     15<html><head><title>I2P Router Console - Page Not Found</title>
    1716<%@include file="css.jsp" %>
    18 <link rel="shortcut icon" href="favicon.ico" /></head><body>
     17</head><body>
    1918<%
    2019if (System.getProperty("router.consoleNonce") == null) {
     
    2423<%@include file="summary.jsp" %>
    2524<h1><%=ERROR_CODE%> <%=ERROR_MESSAGE%></h1>
    26 <div class="warning" id="warning">
    27 The Router Console page <%=ERROR_URI%> was not found.
     25<div class="sorry" id="warning">
     26Sorry! You appear to be requesting a non-existent Router Console page or resource.<hr>
     27Error 404: <%=ERROR_URI%> not found.
    2828</div></body></html>
  • apps/routerconsole/jsp/flags.jsp

    r5ca2f306 rd868f7c0  
    2626        cout.close();
    2727}
     28/*
     29 *  Send a 403 instead of a 404, because the server sends error.jsp
     30 *  for 404 errors, complete with the summary bar, which would be
     31 *  a huge load for a page full of flags if the user didn't have the
     32 *  flags directory for some reason.
     33 */
    2834if (!rendered)
    29     response.sendError(404, "Not found");
     35    response.sendError(403, "Flag not found");
    3036%>
  • apps/routerconsole/jsp/help.jsp

    r5ca2f306 rd868f7c0  
    177177 <p>A more complete list of changes can be found
    178178 in the history.txt file in your i2p directory.
    179  </p><br></div></body></html>
     179 </p><hr></div></body></html>
  • apps/routerconsole/jsp/index.jsp

    r5ca2f306 rd868f7c0  
    66<%@include file="css.jsp" %>
    77<title>I2P Router Console - home</title>
    8 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    9 <link rel="shortcut icon" href="/themes/console/images/favicon.ico" />
    108</head><body>
    119<%
  • apps/routerconsole/jsp/summaryframe.jsp

    r5ca2f306 rd868f7c0  
    1111<%@include file="css.jsp" %>
    1212<title>Summary Bar</title>
    13 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    1413<%
    1514    // try hard to avoid an error page in the iframe after shutdown
  • apps/routerconsole/jsp/viewstat.jsp

    r5ca2f306 rd868f7c0  
    6464  } catch (NumberFormatException nfe) {}
    6565}
     66/*
     67 *  Send a 403 instead of a 404, because the server sends error.jsp
     68 *  for 404 errors, complete with the summary bar, which would be
     69 *  a huge load for a page full of graphs if there's a problem
     70 */
    6671if (!rendered) {
    67   response.sendError(404, "That stat is not available");
     72  response.sendError(403, "That stat is not available");
    6873}
    6974%>
  • apps/streaming/java/src/net/i2p/client/streaming/ConnectionOptions.java

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    106106    public static void writeProperties(OutputStream rawStream, Properties props)
    107107            throws DataFormatException, IOException {
     108        writeProperties(rawStream, props, false);
     109    }
     110
     111    /**
     112     * jrandom disabled UTF-8 in mid-2004, for performance reasons,
     113     * i.e. slow foo.getBytes("UTF-8")
     114     * Re-enable it so we can pass UTF-8 tunnel names through the I2CP SessionConfig.
     115     *
     116     * Use utf8 = false for RouterAddress (fast, non UTF-8)
     117     * Use utf8 = true for SessionConfig (slow, UTF-8)
     118     */
     119    public static void writeProperties(OutputStream rawStream, Properties props, boolean utf8)
     120            throws DataFormatException, IOException {
    108121        if (props != null) {
    109122            OrderedProperties p = new OrderedProperties();
     
    113126                String key = (String) iter.next();
    114127                String val = p.getProperty(key);
    115                 // now make sure they're in UTF-8
    116                 //key = new String(key.getBytes(), "UTF-8");
    117                 //val = new String(val.getBytes(), "UTF-8");
    118                 writeString(baos, key);
     128                if (utf8)
     129                    writeStringUTF8(baos, key);
     130                else
     131                    writeString(baos, key);
    119132                baos.write(_equalBytes);
    120                 writeString(baos, val);
     133                if (utf8)
     134                    writeStringUTF8(baos, val);
     135                else
     136                    writeString(baos, val);
    121137                baos.write(_semicolonBytes);
    122138            }
     
    487503     * A string is 1 or more bytes where the first byte is the number of bytes (not characters!)
    488504     * in the string and the remaining 0-255 bytes are the non-null terminated UTF-8 encoded character array.
     505     *
    489506     * @param in stream to read from
    490507     * @throws DataFormatException if the stream doesn't contain a validly formatted string
     
    497514        int read = read(in, raw);
    498515        if (read != size) throw new DataFormatException("Not enough bytes to read the string");
    499         return new String(raw);
     516        // the following constructor throws an UnsupportedEncodingException which is an IOException,
     517        // but that's only if UTF-8 is not supported. Other encoding errors are not thrown.
     518        return new String(raw, "UTF-8");
    500519    }
    501520
    502521    /** Write out a string to the stream as specified by the I2P data structure spec.  Note that the max
    503522     * size for a string allowed by the spec is 255 bytes.
     523     *
     524     * WARNING - this method destroys the encoding, and therefore violates
     525     * the data structure spec.
    504526     *
    505527     * @param out stream to write string
     
    517539            if (len > 255)
    518540                throw new DataFormatException("The I2P data spec limits strings to 255 bytes or less, but this is "
    519                                               + string.length() + " [" + string + "]");
     541                                              + len + " [" + string + "]");
    520542            writeLong(out, 1, len);
    521543            for (int i = 0; i < len; i++)
    522544                out.write((byte)(string.charAt(i) & 0xFF));
     545        }
     546    }
     547
     548    /** Write out a string to the stream as specified by the I2P data structure spec.  Note that the max
     549     * size for a string allowed by the spec is 255 bytes.
     550     *
     551     * This method correctly uses UTF-8
     552     *
     553     * @param out stream to write string
     554     * @param string UTF-8 string to write out: null strings are perfectly valid, but strings of excess length will
     555     *               cause a DataFormatException to be thrown
     556     * @throws DataFormatException if the string is not valid
     557     * @throws IOException if there is an IO error writing the string
     558     */
     559    private static void writeStringUTF8(OutputStream out, String string)
     560        throws DataFormatException, IOException {
     561        if (string == null) {
     562            writeLong(out, 1, 0);
     563        } else {
     564            // the following method throws an UnsupportedEncodingException which is an IOException,
     565            // but that's only if UTF-8 is not supported. Other encoding errors are not thrown.
     566            byte[] raw = string.getBytes("UTF-8");
     567            int len = raw.length;
     568            if (len > 255)
     569                throw new DataFormatException("The I2P data spec limits strings to 255 bytes or less, but this is "
     570                                              + len + " [" + string + "]");
     571            writeLong(out, 1, len);
     572            out.write(raw);
    523573        }
    524574    }
     
    749799     */
    750800    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
    751804        int rv = 0;
    752805        if (b != null) {
    753             for (int i = 0; i < b.length && i < 32; i++)
    754                 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            }
    755812        }
    756813        return rv;
     814
    757815    }
    758816
  • core/java/src/net/i2p/data/Destination.java

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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/data/i2cp/SessionConfig.java

    r5ca2f306 rd868f7c0  
    174174            _log.debug("SigningKey size for destination: " + _destination.getSigningPublicKey().getData().length);
    175175            _destination.writeBytes(out);
    176             DataHelper.writeProperties(out, _options);
     176            DataHelper.writeProperties(out, _options, true);  // UTF-8
    177177            DataHelper.writeDate(out, _creationDate);
    178178        } catch (IOException ioe) {
     
    199199            throw new DataFormatException("Not enough data to create the session config");
    200200        _destination.writeBytes(out);
    201         DataHelper.writeProperties(out, _options);
     201        DataHelper.writeProperties(out, _options, true);  // UTF-8
    202202        DataHelper.writeDate(out, _creationDate);
    203203        _signature.writeBytes(out);
  • core/java/src/net/i2p/util/DecayingBloomFilter.java

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
     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
     352009-08-24 zzz
     36    * ClientManager:
     37      - Prevent client destination theft by rejecting duplicates
     38      - Java 5 cleanups
     39    * Console:
     40      - Put favicon on every page
     41      - Make every page UTF-8, ☃ safe for snowmen
     42      - Remove options boxes on configtunnels.jsp
     43      - Fix UTF-8 form submission (i2ptunnel too)
     44      - Throw 403 instead of 404 from flags.jsp and viewstat.jsp
     45        so we don't render error.jsp
     46    * I2CP: Fix the SessionConfig serializer in DataHelper,
     47      so that UTF-8 tunnel names are not corrupted by
     48      I2CP and can be displayed on the console
     49    * Message: Move 2 unused classes out of the router lib (~15KB)
     50      (more SKM prep)
     51    * Message, I2PSession, SessionKeyManager, Console:
     52      Prep for SessionKeyManager work in the router -
     53      Fix up SKM renderStatusHTML(); add debug.jsp to see it;
     54      Redefine getClientSessionKeyManager();
     55      More cleanups
     56    * Ministreaming: Kill deprecation warnings
     57    * profiles.jsp: Bulletproofing, less memory usage
     58    * Streaming, I2PSession:
     59      Prep for SessionKeyManager work in the router -
     60      Comment out, deprecate, and javadoc for unused keys and tags,
     61      they are vestiges of end-to-end crypto
     62    * Updates: Verify zip at startup before extracting
     63    * Wrapper: Take a couple fields out of the log so it's narrower
     64
    1652009-08-20 zzz
    266    * Config files:
  • installer/resources/themes/console/classic/console.css

    r5ca2f306 rd868f7c0  
    104104}
    105105
     106/* console error messages */
     107
     108div.sorry {
     109     padding: 20px;
     110     background: #ddf;
     111     margin: -2px 1px 0 195px;
     112     border: 5px solid #bbf;
     113     text-align: justify;
     114     -moz-box-shadow: inset 0px 0px 0px 1px #d00;
     115     word-wrap: break-word;
     116     font-weight: bold;
     117     color: #001;
     118}
     119
     120div.sorry hr {
     121     color: #001;
     122     background: #001;
     123     height: 1px;
     124     border: 1px solid #001;
     125     margin: 10px 0;
     126}
     127
    106128div.toolbar {
    107129     margin: 0em 0em 2em 0em;
     
    124146     color: inherit;
    125147     margin: 0;
    126      padding: 7px 1px;
     148     padding: 10px 1px 7px 1px;
    127149     text-align: center !important;
    128150     border: 5px solid #bbf;
  • installer/resources/themes/console/dark/console.css

    r5ca2f306 rd868f7c0  
    223223     word-wrap: break-word;
    224224}
     225
     226/* console error messages */
     227
     228div.sorry {
     229     margin: 5px 15px 10px 220px;
     230     padding: 20px 20px 20px 75px;
     231     background: #005;
     232     border: 1px solid #99f;
     233     -moz-border-radius: 4px;
     234     -khtml-border-radius: 4px;
     235     border-radius: 4px;
     236     text-align: justify;
     237     background-image:url("images/errortriangle.png");
     238     background-position:15px center;
     239     background-repeat:no-repeat;
     240     -moz-box-shadow: inset 0px 0px 0px 1px #d00;
     241     word-wrap: break-word;
     242     font-weight: bold;
     243     color: #eef;
     244}
     245
     246div.sorry hr {
     247     color: #eef;
     248     background: #eef;
     249     height: 1px;
     250     border: 1px solid #eef;
     251     margin: 10px 0;
     252}     
    225253
    226254div.main {
  • installer/resources/themes/console/light/console.css

    r5ca2f306 rd868f7c0  
    22
    33body {
    4      margin: 15px 0px 0 5px;
     4     margin: 15px 0 0 10px;
    55     padding: 0em;
    66     text-align: center;
     
    2424     font: 8pt "Lucida Console", "DejaVu Sans Mono", Courier, mono;
    2525     color: #333;
     26     margin: 10px;
    2627}
    2728
     
    184185}
    185186
    186 
    187187div.routersummary tr:nth-child(even) {
    188188     background-color: #f60;
     
    194194     background-image: none !important;
    195195}
     196
     197/* proxy error messages */
    196198
    197199div.warning {
     
    212214     word-wrap: break-word;
    213215}
     216
     217/* console error messages */
     218
     219div.sorry {
     220     margin: 5px 15px 10px 220px;
     221     padding: 20px 20px 20px 75px;
     222     background: #ffb;
     223     border: 1px solid #002;
     224     -moz-border-radius: 4px;
     225     -khtml-border-radius: 4px;
     226     border-radius: 4px;
     227     text-align: justify;
     228     background-image: url("images/errortriangle.png");
     229     background-position: 15px center;
     230     background-repeat: no-repeat;
     231     -moz-box-shadow: inset 0px 0px 0px 1px #d00;
     232     word-wrap: break-word;
     233     font-weight: bold;
     234     color: #331;
     235}
     236
     237div.sorry hr {
     238     color: #552;
     239     background: #552;
     240     height: 1px;
     241     border: 1px solid #552;
     242     margin: 10px 0;
     243}     
    214244
    215245div.main {
     
    409439     width: 100%;
    410440     border: 1px solid #000022;
    411      margin: 0px -15px 5px 0px;
     441     margin: 10px -15px 5px 0px;
    412442     cell-padding: 1px;
    413443     font-size: 7pt;
     
    566596     -moz-border-radius: 4px;
    567597     -khtml-border-radius: 4px;
    568      margin: 15px 0px 15px 0 !important;
     598     margin: 15px 0px 10px 0 !important;
    569599     -moz-box-shadow: inset 0px 0px 1px 0px #002;
    570600     word-wrap: break-word;
  • installer/resources/wrapper.config

    r5ca2f306 rd868f7c0  
    118118#wrapper.logfile=$INSTALL_PATH/wrapper.log
    119119
    120 # Format of output for the log file.  (See docs for formats)
    121 wrapper.logfile.format=LPTM
     120# Format of output for the log file.
     121# The format consists of the tokens 'L' for log level, 'P' for prefix, 'D' for thread,
     122# 'T' for time, 'Z' for millisecond time, and 'M' for message
     123# Unfortunately the log timezone cannot be changed, see
     124# http://www.nabble.com/Log-message-timezone-td23651317.html
     125wrapper.logfile.format=TM
    122126
    123127# Log Level for log file output.  (See docs for log levels)
  • router/java/src/net/i2p/router/MessageValidator.java

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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();
     
    11101111            }
    11111112            System.out.println("INFO: Update file exists [" + UPDATE_FILE + "] - installing");
    1112             boolean ok = FileUtil.extractZip(updateFile, _context.getBaseDir());
     1113            // verify the whole thing first
     1114            // we could remember this fails, and not bother restarting, but who cares...
     1115            boolean ok = FileUtil.verifyZip(updateFile);
     1116            if (ok)
     1117                ok = FileUtil.extractZip(updateFile, _context.getBaseDir());
    11131118            if (ok)
    11141119                System.out.println("INFO: Update installed");
     
    11331138                }
    11341139            }
     1140            // exit whether ok or not
    11351141            if (System.getProperty("wrapper.version") != null)
    11361142                System.out.println("INFO: Restarting after update");
  • router/java/src/net/i2p/router/RouterContext.java

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 16;
     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

    r5ca2f306 rd868f7c0  
    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();
     
    9991004        out.write("<h2>Network Database Contents (<a href=\"netdb.jsp?l=1\">View LeaseSets</a>)</h2>\n");
    10001005        if (!_initialized) {
    1001             buf.append("<i>Not initialized</i>\n");
     1006            buf.append("Not initialized\n");
    10021007            out.write(buf.toString());
    10031008            out.flush();
     
    10481053            for (String routerVersion : versionList) {
    10491054                int num = versions.count(routerVersion);
    1050                 buf.append("<tr><td>").append(DataHelper.stripHTML(routerVersion));
    1051                 buf.append("</td><td align=\"right\">").append(num).append("</td></tr>\n");
     1055                buf.append("<tr><td align=\"center\">").append(DataHelper.stripHTML(routerVersion));
     1056                buf.append("</td><td align=\"center\">").append(num).append("</td></tr>\n");
    10521057            }
    10531058            buf.append("</table>\n");
     
    10671072                buf.append(" src=\"/flags.jsp?c=").append(country).append("\"> ");
    10681073                buf.append(_context.commSystem().getCountryName(country));
    1069                 buf.append("</td><td align=\"right\">").append(num).append("</td></tr>\n");
     1074                buf.append("</td><td align=\"center\">").append(num).append("</td></tr>\n");
    10701075            }
    10711076            buf.append("</table>\n");
     
    10821087    private void renderRouterInfo(StringBuilder buf, RouterInfo info, boolean isUs, boolean full) {
    10831088        String hash = info.getIdentity().getHash().toBase64();
    1084         buf.append("<a name=\"").append(hash.substring(0, 6)).append("\" ></a>");
     1089        buf.append("<table><tr><th><a name=\"").append(hash.substring(0, 6)).append("\" ></a>");
    10851090        if (isUs) {
    1086             buf.append("<a name=\"our-info\" ></a><b>Our info: ").append(hash).append("</b><br>\n");
     1091            buf.append("<a name=\"our-info\" ></a><b>Our info: ").append(hash).append("</b></th></tr><tr><td>\n");
    10871092        } else {
    1088             buf.append("<b>Peer info for:</b> ").append(hash).append("<br>\n");
     1093            buf.append("<b>Peer info for:</b> ").append(hash).append("\n");
     1094            buf.append("[<a href=\"netdb.jsp?r=").append(hash.substring(0, 6)).append("\" >Full entry</a>]</th></tr><td>\n");
    10891095        }
    10901096       
    10911097        long age = _context.clock().now() - info.getPublished();
    10921098        if (isUs && _context.router().isHidden())
    1093             buf.append("Hidden, Updated: <i>").append(DataHelper.formatDuration(age)).append(" ago</i><br>\n");
     1099            buf.append("<b>Hidden, Updated:</b> ").append(DataHelper.formatDuration(age)).append(" ago<br>\n");
    10941100        else if (age > 0)
    1095             buf.append("Published: <i>").append(DataHelper.formatDuration(age)).append(" ago</i><br>\n");
     1101            buf.append("<b>Published:</b> ").append(DataHelper.formatDuration(age)).append(" ago<br>\n");
    10961102        else
    1097             buf.append("Published: <i>in ").append(DataHelper.formatDuration(0-age)).append("???</i><br>\n");
    1098         buf.append("Address(es): <i>");
     1103            buf.append("<b>Published:</b> in ").append(DataHelper.formatDuration(0-age)).append("???<br>\n");
     1104        buf.append("<b>Address(es):</b> ");
    10991105        String country = _context.commSystem().getCountry(info.getIdentity().getHash());
    11001106        if(country != null) {
     
    11111117            }
    11121118        }
    1113         buf.append("</i><br>\n");
     1119        buf.append("</td></tr>\n");
    11141120        if (full) {
    1115             buf.append("Stats: <br><i><code>\n");
     1121            buf.append("<tr><td>Stats: <br><code>\n");
    11161122            for (Iterator iter = info.getOptions().keySet().iterator(); iter.hasNext(); ) {
    11171123                String key = (String)iter.next();
     
    11191125                buf.append(DataHelper.stripHTML(key)).append(" = ").append(DataHelper.stripHTML(val)).append("<br>\n");
    11201126            }
    1121             buf.append("</code></i>\n");
     1127            buf.append("</code></td></tr>\n");
    11221128        } else {
    1123             buf.append("<a href=\"netdb.jsp?r=").append(hash.substring(0, 6)).append("\" >Full entry</a>\n");
    1124         }
    1125         buf.append("<hr>\n");
    1126     }
    1127    
     1129        }
     1130        buf.append("</td></tr>\n");
     1131    }
     1132
    11281133}
  • router/java/src/net/i2p/router/peermanager/ProfileOrganizerRenderer.java

    r5ca2f306 rd868f7c0  
    112112            RouterInfo info = _context.netDb().lookupRouterInfoLocally(peer);
    113113            if (info != null) {
    114                 buf.append(" (").append(info.getCapabilities());
     114                // prevent HTML injection in the caps and version
     115                buf.append(" (").append(DataHelper.stripHTML(info.getCapabilities()));
    115116                String v = info.getOption("router.version");
    116117                if (v != null)
    117                     buf.append(' ').append(v);
     118                    buf.append(' ').append(DataHelper.stripHTML(v));
    118119                buf.append(')');
    119120            }
     
    154155            buf.append("&nbsp;<a href=\"configpeer.jsp?peer=").append(peer.toBase64()).append("\">+-</a></td>\n");
    155156            buf.append("</tr>");
     157            // let's not build the whole page in memory (~500 bytes per peer)
     158            out.write(buf.toString());
     159            buf.setLength(0);
    156160        }
    157161        buf.append("</table>");
     
    190194            RouterInfo info = _context.netDb().lookupRouterInfoLocally(peer);
    191195            if (info != null)
    192                 buf.append("<td align=\"center\">" + info.getCapabilities() + "</td>");
     196                buf.append("<td align=\"center\">").append(DataHelper.stripHTML(info.getCapabilities())).append("</td>");
    193197            else
    194198                buf.append("<td>&nbsp;</td>");
  • router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java

    r5ca2f306 rd868f7c0  
    646646        buf.append(". Limit: ").append(getMaxConnections());
    647647        buf.append(". Timeout: ").append(DataHelper.formatDuration(_pumper.getIdleTimeout()));
    648         buf.append(".</b></h3>\n");
    649         buf.append("<div class=\"wideload\"><table>\n");
    650         buf.append("<tr><th><a href=\"#def.peer\">Peer</a></th>");
    651         buf.append("<th>Dir</th>");
    652         buf.append("<th align=\"right\"><a href=\"#def.idle\">Idle</a></th>");
    653         buf.append("<th align=\"right\"><a href=\"#def.rate\">In/Out</a></th>");
    654         buf.append("<th align=\"right\"><a href=\"#def.up\">Up</a></th>");
    655         buf.append("<th align=\"right\"><a href=\"#def.skew\">Skew</a></th>");
    656         buf.append("<th align=\"right\"><a href=\"#def.send\">TX</a></th>");
    657         buf.append("<th align=\"right\"><a href=\"#def.recv\">RX</a></th>");
    658         buf.append("<th>Out queue</th>");
    659         buf.append("<th>Backlogged?</th>");
    660         buf.append("<th>Reading?</th>");
    661         buf.append(" </tr>\n");
     648        buf.append(".</b></h3>\n" +
     649                   "<div class=\"wideload\"><table>\n" +
     650                   "<tr><th><a href=\"#def.peer\">Peer</a></th>" +
     651                   "<th>Dir</th>" +
     652                   "<th align=\"right\"><a href=\"#def.idle\">Idle</a></th>" +
     653                   "<th align=\"right\"><a href=\"#def.rate\">In/Out</a></th>" +
     654                   "<th align=\"right\"><a href=\"#def.up\">Up</a></th>" +
     655                   "<th align=\"right\"><a href=\"#def.skew\">Skew</a></th>" +
     656                   "<th align=\"right\"><a href=\"#def.send\">TX</a></th>" +
     657                   "<th align=\"right\"><a href=\"#def.recv\">RX</a></th>" +
     658                   "<th>Out queue</th>" +
     659                   "<th>Backlogged?</th>" +
     660                   "<th>Reading?</th>" +
     661                   " </tr>\n");
    662662        out.write(buf.toString());
    663663        buf.setLength(0);
     
    727727            buf.append("</b></td> <td align=\"center\"><b>").append(peers.size() > 0 ? DataHelper.formatDuration(offsetTotal*1000/peers.size()) : "0ms");
    728728            buf.append("</b></td> <td align=\"center\"><b>").append(totalSend).append("</b></td> <td align=\"center\"><b>").append(totalRecv);
    729             buf.append("</b></td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;");
    730             buf.append("</td></tr>\n");
     729            buf.append("</b></td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;" +
     730                       "</td></tr>\n");
    731731        }
    732732
  • router/java/src/net/i2p/router/transport/udp/InboundMessageFragments.java

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    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

    r5ca2f306 rd868f7c0  
    3434    /** base to randomize the test delay on */
    3535    private static final int TEST_DELAY = 30*1000;
     36    private static final long[] RATES = { 60*1000, 10*60*1000l, 60*60*1000l };
    3637   
    3738    public TestJob(RouterContext ctx, PooledTunnelCreatorConfig cfg, TunnelPool pool) {
     
    4647        getTiming().setStartAfter(getDelay() + ctx.clock().now());
    4748        ctx.statManager().createRateStat("tunnel.testFailedTime", "How long did the failure 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.testExploratoryFailedTime", "How long did the failure of an exploratory tunnel 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.testFailedCompletelyTime", "How long did the complete failure 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.testExploratoryFailedCompletelyTime", "How long did the complete failure of an exploratory tunnel take (max of 60s for full timeout)?", "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.testSuccessLength", "How long were the tunnels that passed the test?", "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.testSuccessTime", "How long did tunnel testing take?", "Tunnels",
    58                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     59                                         RATES);
    5960        ctx.statManager().createRateStat("tunnel.testAborted", "Tunnel test could not occur, since there weren't any tunnels to test with", "Tunnels",
    60                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     61                                         RATES);
    6162    }
    6263    public String getName() { return "Test tunnel"; }
     
    7273            return;
    7374        }
     75        if (getContext().router().gracefulShutdownInProgress())
     76            return;   // don't reschedule
    7477        _found = false;
    7578        // note: testing with exploratory tunnels always, even if the tested tunnel
  • router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java

    r5ca2f306 rd868f7c0  
    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.