Changeset 11579b9


Ignore:
Timestamp:
Nov 20, 2016 6:08:40 AM (4 years ago)
Author:
str4d <str4d@…>
Branches:
master
Children:
97af7d0
Parents:
01cfb7b (diff), b0bba18 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge of '8bf9850eb3fe4fcfb63053838a188969b7ba9c5b'

and 'a40ea9b5f7545281195f00a80e31ae879197e76b'

Files:
2 added
80 edited

Legend:

Unmodified
Added
Removed
  • LICENSE.txt

    r01cfb7b r11579b9  
    284284      See licenses/LICENSE-LGPLv2.1.txt
    285285
    286    Tomcat 6.0.47:
     286   Tomcat 6.0.48:
    287287   Copyright 1999-2016 The Apache Software Foundation
    288288   See licenses/LICENSE-Apache2.0.txt
  • apps/addressbook/build.xml

    r01cfb7b r11579b9  
    8787                                <attribute name="Base-Revision" value="${workspace.version}" />
    8888                                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     89                                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     90                                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    8991                        </manifest>
    9092                </jar>
     
    107109                                <attribute name="Base-Revision" value="${workspace.version}" />
    108110                                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     111                                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     112                                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    109113                        </manifest>
    110114                </war>
  • apps/desktopgui/build.xml

    r01cfb7b r11579b9  
    8484                                <attribute name="Base-Revision" value="${workspace.version}" />
    8585                                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     86                                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     87                                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    8688                        </manifest>
    8789                </jar>
  • apps/i2psnark/java/build.xml

    r01cfb7b r11579b9  
    8585                <attribute name="Base-Revision" value="${workspace.version}" />
    8686                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     87                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     88                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    8789            </manifest>
    8890        </jar>
     
    131133                <attribute name="Base-Revision" value="${workspace.version}" />
    132134                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     135                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     136                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    133137            </manifest>
    134138        </war>
  • apps/i2psnark/java/src/org/klomp/snark/dht/KRPC.java

    r01cfb7b r11579b9  
    124124    private final AtomicLong _txBytes = new AtomicLong();
    125125    private long _started;
     126    private long _nodesLastSaved;
    126127
    127128    /** all-zero NID used for pings */
     
    157158    private static final long EXPLORE_TIME = 877*1000;
    158159    private static final long BLACKLIST_CLEAN_TIME = 17*60*1000;
     160    private static final long NODES_SAVE_TIME = 3*60*60*1000;
    159161    public static final String DHT_FILE_SUFFIX = ".dht.dat";
    160162
     
    636638        _rxBytes.set(0);
    637639        _started = _context.clock().now();
     640        _nodesLastSaved = _started;
    638641    }
    639642
     
    16761679                    iter.remove();
    16771680            }
     1681            if (now - _nodesLastSaved > NODES_SAVE_TIME) {
     1682                PersistDHT.saveDHT(_knownNodes, false, _dhtFile);
     1683                _nodesLastSaved = now;
     1684            }
    16781685            // TODO sent queries?
    16791686            if (_log.shouldLog(Log.DEBUG))
  • apps/i2ptunnel/java/build.xml

    r01cfb7b r11579b9  
    7373                <attribute name="Base-Revision" value="${workspace.version}" />
    7474                <attribute name="Workspace-Changes" value="${workspace.changes.j.tr}" />
     75                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     76                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    7577            </manifest>
    7678        </jar>
     
    104106                <attribute name="Base-Revision" value="${workspace.version}" />
    105107                <attribute name="Workspace-Changes" value="${workspace.changes.j.tr}" />
     108                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     109                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    106110            </manifest>
    107111        </jar>
     
    242246                <attribute name="Base-Revision" value="${workspace.version}" />
    243247                <attribute name="Workspace-Changes" value="${workspace.changes.w.tr}" />
     248                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     249                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    244250            </manifest>
    245251        </war>
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java

    r01cfb7b r11579b9  
    305305                        }
    306306                    }
    307                     _log.logAlways(Log.WARN, "PROXY AUTH FAILURE: user " + user);
     307                    _log.logAlways(Log.WARN, "HTTP proxy authentication failed, user: " + user);
    308308                } catch (UnsupportedEncodingException uee) {
    309309                    _log.error(getPrefix(requestId) + "No UTF-8 support? B64: " + authorization, uee);
     
    364364                                                                PROP_PROXY_DIGEST_SUFFIX);
    365365        if (ha1 == null) {
    366             _log.logAlways(Log.WARN, "PROXY AUTH FAILURE: user " + user);
     366            _log.logAlways(Log.WARN, "HTTP proxy authentication failed, user: " + user);
    367367            return AuthResult.AUTH_BAD;
    368368        }
     
    374374        String hkd = PasswordManager.md5Hex(kd);
    375375        if (!response.equals(hkd)) {
    376             _log.logAlways(Log.WARN, "PROXY AUTH FAILURE: user " + user);
     376            _log.logAlways(Log.WARN, "HTTP proxy authentication failed, user: " + user);
    377377            if (_log.shouldLog(Log.INFO))
    378378                _log.info("Bad digest auth: " + DataHelper.toString(args));
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKS5Server.java

    r01cfb7b r11579b9  
    132132    private void verifyPassword(DataInputStream in, DataOutputStream out) throws IOException, SOCKSException {
    133133        int c = in.readUnsignedByte();
    134         if (c != AUTH_VERSION)
     134        if (c != AUTH_VERSION) {
     135            _log.logAlways(Log.WARN, "SOCKS proxy authentication failed");
    135136            throw new SOCKSException("Unsupported authentication version");
     137        }
    136138        c = in.readUnsignedByte();
    137         if (c <= 0)
     139        if (c <= 0) {
     140            _log.logAlways(Log.WARN, "SOCKS proxy authentication failed");
    138141            throw new SOCKSException("Bad authentication");
     142        }
    139143        byte[] user = new byte[c];
     144        String u = new String(user, "UTF-8");
    140145        in.readFully(user);
    141146        c = in.readUnsignedByte();
    142         if (c <= 0)
     147        if (c <= 0) {
     148            _log.logAlways(Log.WARN, "SOCKS proxy authentication failed, user: " + u);
    143149            throw new SOCKSException("Bad authentication");
     150        }
    144151        byte[] pw = new byte[c];
    145152        in.readFully(pw);
    146153        // Hopefully these are in UTF-8, since that's what our config file is in
    147154        // these throw UnsupportedEncodingException which is an IOE
    148         String u = new String(user, "UTF-8");
    149155        String p = new String(pw, "UTF-8");
    150156        String configUser =  props.getProperty(I2PTunnelHTTPClientBase.PROP_USER);
    151157        String configPW = props.getProperty(I2PTunnelHTTPClientBase.PROP_PW);
    152158        if ((!u.equals(configUser)) || (!p.equals(configPW))) {
    153             _log.error("SOCKS authorization failure");
     159            _log.logAlways(Log.WARN, "SOCKS proxy authentication failed, user: " + u);
    154160            sendAuthReply(AUTH_FAILURE, out);
    155161            throw new SOCKSException("SOCKS authorization failure");
     
    592598        } catch (IOException e) {
    593599            try { destSock.close(); } catch (IOException ioe) {}
     600            if (in != null) try { in.close(); } catch (IOException ioe) {}
     601            if (out != null) try { out.close(); } catch (IOException ioe) {}
    594602            throw e;
    595603        } catch (SOCKSException e) {
    596604            try { destSock.close(); } catch (IOException ioe) {}
     605            if (in != null) try { in.close(); } catch (IOException ioe) {}
     606            if (out != null) try { out.close(); } catch (IOException ioe) {}
    597607            throw e;
    598608        }
     
    602612
    603613    // This isn't really the right place for this, we can't stop the tunnel once it starts.
    604     static SOCKSUDPTunnel _tunnel;
    605     static final Object _startLock = new Object();
    606     static byte[] dummyIP = new byte[4];
     614    private static SOCKSUDPTunnel _tunnel;
     615    private static final Object _startLock = new Object();
     616    private static final byte[] dummyIP = new byte[4];
     617
    607618    /**
    608619     * We got a UDP associate command.
  • apps/imagegen/identicon/build.xml

    r01cfb7b r11579b9  
    7272                <attribute name="Base-Revision" value="${workspace.version}" />
    7373                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     74                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     75                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    7476            </manifest>
    7577        </jar>
  • apps/imagegen/imagegen/build.xml

    r01cfb7b r11579b9  
    7676                <attribute name="Base-Revision" value="${workspace.version}" />
    7777                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     78                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     79                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    7880            </manifest>
    7981        </war>
  • apps/imagegen/zxing/build.xml

    r01cfb7b r11579b9  
    1818
    1919    <!-- only used if not set by a higher build.xml -->
     20    <property name="javac.version" value="1.7" />
    2021    <property name="javac.compilerargs7" value="" />
    2122
     
    4041        <javac
    4142            srcdir="./test/junit"
    42             debug="true" deprecation="on" source="1.7" target="1.7"
     43            debug="true" deprecation="on" source="${javac.version}" target="${javac.version}"
    4344            includeAntRuntime="false"
    4445            destdir="./buildTest/obj"
     
    7677                <attribute name="Base-Revision" value="${workspace.version}" />
    7778                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     79                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     80                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    7881            </manifest>
    7982        </jar>
  • apps/jetty/apache-tomcat-deployer/README-i2p.txt

    r01cfb7b r11579b9  
    33
    44Retrieved from the file
    5         apache-tomcat-6.0.44-deployer.tar.gz
     5        apache-tomcat-6.0.48-deployer.tar.gz
    66
    77minus the following files and directores:
  • apps/jetty/apache-tomcat/README-i2p.txt

    r01cfb7b r11579b9  
    22
    33Retrieved from the file
    4         apache-tomcat-6.0.44.tar.gz
     4        apache-tomcat-6.0.48.tar.gz
    55
    66containing only a small subset of lib/tomcat-coyote.jar.
  • apps/jetty/build.xml

    r01cfb7b r11579b9  
    2323    <property name="javac.version" value="1.7" />
    2424    <property name="tomcat.lib" value="apache-tomcat-deployer/lib" />
    25     <property name="tomcat.ver" value="6.0.47" />
     25    <property name="tomcat.ver" value="6.0.48" />
    2626    <property name="tomcat2.lib" value="apache-tomcat-${tomcat.ver}/lib" />
    2727    <property name="tomcat2.lib.small" value="apache-tomcat/lib" />
     
    341341                <attribute name="Class-Path" value="jetty-deploy.jar jetty-xml.jar" />
    342342                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     343                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     344                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    343345            </manifest>
    344346        </jar>
  • apps/jrobin/java/build.xml

    r01cfb7b r11579b9  
    1414            srcdir="./src"
    1515            destdir="./build/obj" >
     16            <classpath>
     17                <pathelement location="../../../core/java/build/i2p.jar" />
     18            </classpath>
    1619        </depend>
    1720    </target>
     
    3336            includes="**/*.java" >
    3437            <compilerarg line="${javac.compilerargs}" />
     38            <classpath>
     39                <pathelement location="../../../core/java/build/i2p.jar" />
     40            </classpath>
    3541        </javac>
    3642    </target>
     
    5561        <jar destfile="./build/jrobin.jar" basedir="./build/obj" includes="**/*.class">
    5662            <manifest>
     63                <attribute name="Class-Path" value="i2p.jar" />
    5764                <attribute name="Implementation-Version" value="1.6.0-1" />
    5865                <attribute name="Built-By" value="${build.built-by}" />
  • apps/jrobin/java/src/engine/misc/DeallocationHelper.java

    r01cfb7b r11579b9  
    3232import java.util.Map.Entry;
    3333import java.util.Set;
    34 import java.util.logging.Level;
    35 import java.util.logging.Logger;
     34
     35import net.i2p.I2PAppContext;
     36import net.i2p.util.Log;
     37
    3638
    3739/**
     
    5759public class DeallocationHelper {
    5860
     61    private final Log logger = I2PAppContext.getGlobalContext().logManager().getLog(DeallocationHelper.class);
     62
    5963    /**
    6064     * tool responsible for releasing the native memory of a deallocatable byte
     
    6266     */
    6367    public static abstract class Deallocator {
     68
     69        protected final Log logger = I2PAppContext.getGlobalContext().logManager().getLog(DeallocationHelper.class);
    6470
    6571        public Deallocator() {
     
    102108                }
    103109            } catch (ClassNotFoundException | NoSuchMethodException e) {
    104                 logger.log(Level.WARNING,
     110                logger.warn(
    105111                        "The initialization of the deallocator for Oracle Java, Sun Java and OpenJDK has failed", e);
    106112            }
     
    123129                    }
    124130                } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
    125                     logger.log(Level.WARNING, "The deallocation of a direct NIO buffer has failed", e);
     131                    logger.warn("The deallocation of a direct NIO buffer has failed", e);
    126132                } finally {
    127133                    directByteBufferCleanerMethod.setAccessible(directByteBufferCleanerMethodWasAccessible);
     
    143149                directByteBufferFreeMethod = directByteBufferClass.getDeclaredMethod("free");
    144150            } catch (ClassNotFoundException | NoSuchMethodException e) {
    145                 logger.log(Level.WARNING, "The initialization of the deallocator for Android has failed", e);
     151                logger.warn("The initialization of the deallocator for Android has failed", e);
    146152            }
    147153        }
     
    157163                    success = true;
    158164                } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
    159                     logger.log(Level.WARNING, "The deallocation of a direct NIO buffer has failed", e);
     165                    logger.warn("The deallocation of a direct NIO buffer has failed", e);
    160166                } finally {
    161167                    directByteBufferFreeMethod.setAccessible(directByteBufferFreeMethodWasAccessible);
     
    181187                bufferAddressField = Buffer.class.getDeclaredField("address");
    182188            } catch (ClassNotFoundException | NoSuchMethodException | NoSuchFieldException e) {
    183                 logger.log(Level.WARNING, "The initialization of the deallocator for GNU Classpath has failed", e);
     189                logger.warn("The initialization of the deallocator for GNU Classpath has failed", e);
    184190            }
    185191        }
     
    200206                    }
    201207                } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
    202                     logger.log(Level.WARNING, "The deallocation of a direct NIO buffer has failed", e);
     208                    logger.warn("The deallocation of a direct NIO buffer has failed", e);
    203209                } finally {
    204210                    bufferAddressField.setAccessible(bufferAddressFieldWasAccessible);
     
    220226                directByteBufferFreeMethod = directByteBufferClass.getDeclaredMethod("free");
    221227            } catch (ClassNotFoundException | NoSuchMethodException e) {
    222                 logger.log(Level.WARNING, "The initialization of the deallocator for Apache Harmony has failed", e);
     228                logger.warn("The initialization of the deallocator for Apache Harmony has failed", e);
    223229            }
    224230        }
     
    234240                    success = true;
    235241                } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
    236                     logger.log(Level.WARNING, "The deallocation of a direct NIO buffer has failed", e);
     242                    logger.warn("The deallocation of a direct NIO buffer has failed", e);
    237243                } finally {
    238244                    directByteBufferFreeMethod.setAccessible(directByteBufferFreeMethodWasAccessible);
     
    242248        }
    243249    }
    244 
    245     private static final Logger logger = Logger.getLogger(DeallocationHelper.class.getName());
    246250
    247251    private Map<Class<?>, Field> attachmentOrByteBufferFieldMap;
     
    432436                            superClassesMsg = builder.toString();
    433437                        }
    434                         logger.warning("The field " + fieldname + " hasn't been found in the class " + classname
     438                        logger.warn("The field " + fieldname + " hasn't been found in the class " + classname
    435439                                + superClassesMsg);
    436440                    } else {// the field has been found, stores it into the map
     
    450454                            + " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
    451455                            + " Java version: " + javaVersion;
    452                     logger.log(Level.WARNING, msg, cnfe);
     456                    logger.warn(msg, cnfe);
    453457                }
    454458            }
     
    568572                                }
    569573                            } catch (IllegalAccessException iae) {
    570                                 logger.log(Level.WARNING, "Cannot access the field " + field.getName()
     574                                logger.warn("Cannot access the field " + field.getName()
    571575                                        + " of the class " + bufferIntermediaryClass.getName(), iae);
    572576                            } finally {
     
    595599                        + " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
    596600                        + " Java version: " + javaVersion;
    597                 logger.log(Level.WARNING, msg, cnfe);
     601                logger.warn(msg, cnfe);
    598602            }
    599603            if (directByteBufferClass != null)
     
    608612                        + " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
    609613                        + " Java version: " + javaVersion;
    610                 logger.log(Level.WARNING, msg, cnfe);
     614                logger.warn(msg, cnfe);
    611615            }
    612616            if (readOnlyDirectByteBufferClass != null)
     
    620624                        + " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
    621625                        + " Java version: " + javaVersion;
    622                 logger.log(Level.WARNING, msg, cnfe);
     626                logger.warn(msg, cnfe);
    623627            }
    624628            if (readWriteDirectByteBufferClass != null)
     
    633637                        + " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
    634638                        + " Java version: " + javaVersion;
    635                 logger.log(Level.WARNING, msg, cnfe);
     639                logger.warn(msg, cnfe);
    636640            }
    637641            if (readOnlyDirectByteBufferClass != null)
     
    645649                        + " hasn't been found while initializing the deallocator. Java vendor: " + javaVendor
    646650                        + " Java version: " + javaVersion;
    647                 logger.log(Level.WARNING, msg, cnfe);
     651                logger.warn(msg, cnfe);
    648652            }
    649653            if (readWriteDirectByteBufferClass != null)
     
    731735                    deallocatableDirectByteBuffer = null;
    732736                    final String bufferClassName = bufferClass.getName();
    733                     logger.warning("No deallocatable buffer has been found for an instance of the class "
     737                    logger.warn("No deallocatable buffer has been found for an instance of the class "
    734738                            + bufferClassName + " whereas it is a direct NIO buffer");
    735739                }
  • apps/jrobin/java/src/org/jrobin/core/jrrd/RRDFile.java

    r01cfb7b r11579b9  
    189189                        System.out.println(value);
    190190                }
    191                 return (int)value;
     191                return value;
    192192        }
    193193
  • apps/ministreaming/java/build.xml

    r01cfb7b r11579b9  
    8787                <attribute name="Base-Revision" value="${workspace.version}" />
    8888                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     89                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     90                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    8991            </manifest>
    9092        </jar>
  • apps/routerconsole/java/build.xml

    r01cfb7b r11579b9  
    131131                <attribute name="Base-Revision" value="${workspace.version}" />
    132132                <attribute name="Workspace-Changes" value="${workspace.changes.j.tr}" />
     133                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     134                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    133135            </manifest>
    134136        </jar>
     
    303305                <attribute name="Base-Revision" value="${workspace.version}" />
    304306                <attribute name="Workspace-Changes" value="${workspace.changes.w.tr}" />
     307                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     308                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    305309            </manifest>
    306310        </war>
  • apps/routerconsole/java/src/net/i2p/router/news/NewsManager.java

    r01cfb7b r11579b9  
    171171            return Collections.emptyList();
    172172        return parseNews(newsContent, false);
     173    }
     174
     175    /**
     176     *  The initial (welcome to i2p) news
     177     *
     178     *  @return entry with first-installed date stamp, or null
     179     *  @since 0.9.28
     180     */
     181    public NewsEntry getInitialNews() {
     182        List<NewsEntry> list = parseInitialNews();
     183        if (list.isEmpty())
     184            return null;
     185        NewsEntry rv = list.get(0);
     186        long installed = _context.getProperty("router.firstInstalled", 0L);
     187        if (installed > 0)
     188            rv.updated = installed;
     189        return rv;
    173190    }
    174191
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHandler.java

    r01cfb7b r11579b9  
    5353    private String _ipv6Mode;
    5454    private boolean _ipv4Firewalled;
     55    private boolean _ipv6Firewalled;
    5556    private final Map<String, String> changes = new HashMap<String, String>();
    5657    private static final String PROP_HIDDEN = Router.PROP_HIDDEN_HIDDEN; // see Router for other choice
     
    8889    /** @since 0.9.20 */
    8990    public void setIPv4Firewalled(String moo) { _ipv4Firewalled = true; }
     91
     92    /** @since 0.9.28 */
     93    public void setIPv6Firewalled(String moo) { _ipv6Firewalled = true; }
    9094   
    9195    public void setHostname(String hostname) {
     
    367371            changes.put(TransportUtil.PROP_IPV4_FIREWALLED, "" + _ipv4Firewalled);
    368372
     373            if (Boolean.parseBoolean(_context.getProperty(TransportUtil.PROP_IPV6_FIREWALLED)) !=
     374                _ipv6Firewalled) {
     375                if (_ipv6Firewalled)
     376                    addFormNotice(_t("Disabling inbound IPv6"));
     377                else
     378                    addFormNotice(_t("Enabling inbound IPv6"));
     379                restartRequired = true;
     380            }
     381            changes.put(TransportUtil.PROP_IPV6_FIREWALLED, "" + _ipv6Firewalled);
     382
    369383            if (_context.getBooleanPropertyDefaultTrue(TransportManager.PROP_ENABLE_UDP) !=
    370384                !_udpDisabled) {
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigNetHelper.java

    r01cfb7b r11579b9  
    9191    }
    9292
     93    /** @since 0.9.28 */
     94    public String getIPv6FirewalledChecked() {
     95        return getChecked(TransportUtil.PROP_IPV6_FIREWALLED);
     96    }
     97
    9398    public String getTcpAutoPortChecked(int mode) {
    9499        String port = _context.getProperty(PROP_I2NP_NTCP_PORT);
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHandler.java

    r01cfb7b r11579b9  
    3232    @Override
    3333    protected void processForm() {
    34         saveChanges();
     34        if (_action != null && _action.equals("foo")) {
     35            saveChanges();
     36        }
    3537    }
    3638   
  • apps/routerconsole/java/src/net/i2p/router/web/HomeHelper.java

    r01cfb7b r11579b9  
    5151        _x("Forum") + S + _x("Community forum") + S + "http://forum.i2p/" + S + I + "group.png" + S +
    5252        _x("Anonymous Git Hosting") + S + _x("A public anonymous Git hosting site - supports pulling via Git and HTTP and pushing via SSH") + S + "http://git.repo.i2p/" + S + I + "git-logo.png" + S +
    53         "hiddengate.i2p" + S + _x("HiddenGate") + S + "http://hiddengate.i2p/" + S + I + "hglogo32.png" + S +
     53        //"hiddengate.i2p" + S + _x("HiddenGate") + S + "http://hiddengate.i2p/" + S + I + "hglogo32.png" + S +
    5454        _x("I2P Wiki") + S + _x("Anonymous wiki - share the knowledge") + S + "http://i2pwiki.i2p/" + S + I + "i2pwiki_logo.png" + S +
    55         "Ident " + _x("Microblog") + S + _x("Your premier microblogging service on I2P") + S + "http://id3nt.i2p/" + S + I + "ident_icon_blue.png" + S +
     55        //"Ident " + _x("Microblog") + S + _x("Your premier microblogging service on I2P") + S + "http://id3nt.i2p/" + S + I + "ident_icon_blue.png" + S +
    5656        //_x("Javadocs") + S + _x("Technical documentation") + S + "http://i2p-javadocs.i2p/" + S + I + "education.png" + S +
    5757        //"jisko.i2p" + S + _x("Simple and fast microblogging website") + S + "http://jisko.i2p/" + S + I + "jisko_console_icon.png" + S +
     
    6464        _x("Postman's Tracker") + S + _x("Bittorrent tracker") + S + "http://tracker2.postman.i2p/" + S + I + "magnet.png" + S +
    6565        _x("Project Website") + S + _x("I2P home page") + S + "http://i2p-projekt.i2p/" + S + I + "info_rhombus.png" + S +
    66         _x("Russian News Feed") + S + "lenta.i2p" + S + "http://lenta.i2p/" + S + I + "lenta_main_logo.png" + S +
     66        //_x("Russian News Feed") + S + "lenta.i2p" + S + "http://lenta.i2p/" + S + I + "lenta_main_logo.png" + S +
    6767        //"Salt" + S + "salt.i2p" + S + "http://salt.i2p/" + S + I + "salt_console.png" + S +
    6868        "stats.i2p" + S + _x("I2P Network Statistics") + S + "http://stats.i2p/cgi-bin/dashboard.cgi" + S + I + "chart_line.png" + S +
     
    7171        _x("Trac Wiki") + S + S + "http://trac.i2p2.i2p/" + S + I + "billiard_marker.png" + S +
    7272        //_x("Ugha's Wiki") + S + S + "http://ugha.i2p/" + S + I + "billiard_marker.png" + S +
    73         _x("Sponge's main site") + S + _x("Seedless and the Robert BitTorrent applications") + S + "http://sponge.i2p/" + S + I + "user_astronaut.png" + S +
     73        //_x("Sponge's main site") + S + _x("Seedless and the Robert BitTorrent applications") + S + "http://sponge.i2p/" + S + I + "user_astronaut.png" + S +
    7474        "";
    7575
  • apps/routerconsole/java/src/net/i2p/router/web/NetDbHelper.java

    r01cfb7b r11579b9  
    88    private String _version;
    99    private String _country;
     10    private String _family;
    1011    private int _full;
    1112    private boolean _lease;
     
    5051    }
    5152
     53    /** @since 0.9.28 */
     54    public void setFamily(String c) {
     55        if (c != null)
     56            _family = DataHelper.stripHTML(c);  // XSS
     57    }
     58
    5259    public void setFull(String f) {
    5360        try {
     
    7683        try {
    7784            renderNavBar();
    78             if (_routerPrefix != null || _version != null || _country != null)
    79                 renderer.renderRouterInfoHTML(_out, _routerPrefix, _version, _country);
     85            if (_routerPrefix != null || _version != null || _country != null || _family != null)
     86                renderer.renderRouterInfoHTML(_out, _routerPrefix, _version, _country, _family);
    8087            else if (_lease)
    8188                renderer.renderLeaseSetHTML(_out, _debug);
  • apps/routerconsole/java/src/net/i2p/router/web/NetDbRenderer.java

    r01cfb7b r11579b9  
    8686     *  @param version may be null
    8787     *  @param country may be null
    88      */
    89     public void renderRouterInfoHTML(Writer out, String routerPrefix, String version, String country) throws IOException {
     88     *  @param family may be null
     89     */
     90    public void renderRouterInfoHTML(Writer out, String routerPrefix, String version,
     91                                     String country, String family) throws IOException {
    9092        StringBuilder buf = new StringBuilder(4*1024);
    9193        if (".".equals(routerPrefix)) {
     
    98100                if ((routerPrefix != null && key.toBase64().startsWith(routerPrefix)) ||
    99101                    (version != null && version.equals(ri.getVersion())) ||
    100                     (country != null && country.equals(_context.commSystem().getCountry(key)))) {
     102                    (country != null && country.equals(_context.commSystem().getCountry(key))) ||
     103                    (family != null && family.equals(ri.getOption("family")))) {
    101104                    renderRouterInfo(buf, ri, false, true);
    102105                    notFound = false;
     
    111114                else if (country != null)
    112115                    buf.append(country);
     116                else if (family != null)
     117                    buf.append(_t("Family")).append(' ').append(family);
    113118                buf.append(' ').append(_t("not found in network database"));
    114119            }
  • apps/routerconsole/java/src/net/i2p/router/web/NewsFeedHelper.java

    r01cfb7b r11579b9  
    5151        if (cmgr != null) {
    5252            NewsManager nmgr = (NewsManager) cmgr.getRegisteredApp(NewsManager.APP_NAME);
    53             if (nmgr != null)
     53            if (nmgr != null) {
    5454                entries = nmgr.getEntries();
     55                NewsEntry init = nmgr.getInitialNews();
     56                if (init != null) {
     57                    // crude check to see if it's already in there
     58                    if (entries.size() != 1 || !DataHelper.eq(entries.get(0).title, init.title))
     59                        if (entries.isEmpty())
     60                            entries = Collections.singletonList(init);  // in case it was an emtpyList
     61                        else
     62                            entries.add(init);
     63                }
     64            }
    5565        }
    5666        if (!entries.isEmpty()) {
  • apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java

    r01cfb7b r11579b9  
    4949import org.eclipse.jetty.server.NCSARequestLog;
    5050import org.eclipse.jetty.server.Server;
     51import org.eclipse.jetty.server.UserIdentity;
    5152import org.eclipse.jetty.server.bio.SocketConnector;
    5253import org.eclipse.jetty.server.handler.ContextHandlerCollection;
     
    849850                ctx.router().saveConfig(PROP_CONSOLE_PW, "false");
    850851            } else {
    851                 HashLoginService realm = new HashLoginService(JETTY_REALM);
     852                HashLoginService realm = new CustomHashLoginService(JETTY_REALM, context.getContextPath(),
     853                                                                    ctx.logManager().getLog(RouterConsoleRunner.class));
    852854                sec.setLoginService(realm);
    853855                sec.setAuthenticator(authenticator);
     
    933935    }
    934936   
     937    /**
     938     * For logging authentication failures
     939     * @since 0.9.28
     940     */
     941    private static class CustomHashLoginService extends HashLoginService {
     942        private final String _webapp;
     943        private final net.i2p.util.Log _log;
     944
     945        public CustomHashLoginService(String realm, String webapp, net.i2p.util.Log log) {
     946            super(realm);
     947            _webapp = webapp;
     948            _log = log;
     949        }
     950
     951        @Override
     952        public UserIdentity login(String username, Object credentials) {
     953            UserIdentity rv = super.login(username, credentials);
     954            if (rv == null)
     955                //_log.logAlways(net.i2p.util.Log.WARN, "Console authentication failed, webapp: " + _webapp + ", user: " + username);
     956                _log.logAlways(net.i2p.util.Log.WARN, "Console authentication failed, user: " + username);
     957            return rv;
     958        }
     959    }
     960   
    935961    /** @since 0.8.8 */
    936962    private class ServerShutdown implements Runnable {
  • apps/routerconsole/java/src/net/i2p/router/web/SybilRenderer.java

    r01cfb7b r11579b9  
    55import java.io.Writer;
    66import java.math.BigInteger;
     7import java.text.Collator;
    78import java.text.DecimalFormat;
    89import java.util.ArrayList;
     
    2526import net.i2p.router.RouterContext;
    2627import net.i2p.router.TunnelPoolSettings;
     28import net.i2p.router.crypto.FamilyKeyCrypto;
    2729import net.i2p.router.peermanager.DBHistory;
    2830import net.i2p.router.peermanager.PeerProfile;
     
    6264    private static final double POINTS_US16 = 10.0;
    6365    private static final double POINTS_FAMILY = -2.0;
     66    private static final double POINTS_BAD_OUR_FAMILY = 100.0;
     67    private static final double POINTS_OUR_FAMILY = -100.0;
    6468    private static final double MIN_CLOSE = 242.0;
    6569    private static final double PAIR_DISTANCE_FACTOR = 2.0;
     
    371375    private static class FoofComparator implements Comparator<String>, Serializable {
    372376         private final ObjectCounter<String> _o;
     377         private final Collator _comp = Collator.getInstance();
    373378         public FoofComparator(ObjectCounter<String> o) { _o = o;}
    374379         public int compare(String l, String r) {
     
    378383                 return rv;
    379384             // foward by name
    380              return l.compareTo(r);
     385             return _comp.compare(l, r);
    381386        }
    382387    }
     
    579584        List<String> foo = new ArrayList<String>(oc.objects());
    580585        Collections.sort(foo, new FoofComparator(oc));
     586        FamilyKeyCrypto fkc = _context.router().getFamilyKeyCrypto();
     587        String ourFamily = fkc != null ? fkc.getOurFamilyName() : null;
    581588        boolean found = false;
    582589        for (String s : foo) {
    583590            int count = oc.count(s);
    584             buf.append("<p><b>").append(count).append(" floodfills in declared family \"").append(DataHelper.escapeHTML(s) + '"')
    585                .append("</b></p>");
     591            String ss = DataHelper.escapeHTML(s);
     592            buf.append("<p><b>").append(count).append(" floodfills in declared family \"<a href=\"/netdb?fam=")
     593               .append(ss).append("\">").append(ss).append("</a>\"</b></p>");
    586594            for (RouterInfo info : ris) {
    587595                String fam = info.getOption("family");
     
    594602                //renderRouterInfo(buf, info, null, false, false);
    595603                double point = POINTS_FAMILY;
    596                 if (count > 1)
     604                if (fkc != null && s.equals(ourFamily)) {
     605                    if (fkc.verifyOurFamily(info))
     606                        addPoints(points, info.getHash(), POINTS_OUR_FAMILY, "Our family \"" + DataHelper.escapeHTML(s) + "\" with " + (count - 1) + " other" + (( count > 2) ? "s" : ""));
     607                    else
     608                        addPoints(points, info.getHash(), POINTS_BAD_OUR_FAMILY, "Spoofed our family \"" + DataHelper.escapeHTML(s) + "\" with " + (count - 1) + " other" + (( count > 2) ? "s" : ""));
     609                } else if (count > 1) {
    597610                    addPoints(points, info.getHash(), point, "Same declared family \"" + DataHelper.escapeHTML(s) + "\" with " + (count - 1) + " other" + (( count > 2) ? "s" : ""));
    598                 else
     611                } else {
    599612                    addPoints(points, info.getHash(), point, "Declared family \"" + DataHelper.escapeHTML(s) + '"');
     613                }
    600614            }
    601615        }
  • apps/routerconsole/jsp/confignet.jsp

    r01cfb7b r11579b9  
    5757 </p><p>
    5858 <%=intl._t("IPv6 Configuration")%>:<br>
     59    <input type="checkbox" class="optbox" name="IPv6Firewalled" value="true" <jsp:getProperty name="nethelper" property="IPv6FirewalledChecked" /> >
     60    <%=intl._t("Disable inbound (Firewalled by Carrier-grade NAT or DS-Lite)")%><br>
    5961    <input type="radio" class="optbox" name="ipv6" value="false" <%=nethelper.getIPv6Checked("false") %> >
    6062    <%=intl._t("Disable IPv6")%><br>
  • apps/routerconsole/jsp/netdb.jsp

    r01cfb7b r11579b9  
    2626 <jsp:setProperty name="netdbHelper" property="version" value="<%=request.getParameter(\"v\")%>" />
    2727 <jsp:setProperty name="netdbHelper" property="country" value="<%=request.getParameter(\"c\")%>" />
     28 <jsp:setProperty name="netdbHelper" property="family" value="<%=request.getParameter(\"fam\")%>" />
    2829 <jsp:getProperty name="netdbHelper" property="netDbSummary" />
    2930</div></div></body></html>
  • apps/sam/java/build.xml

    r01cfb7b r11579b9  
    7878                <attribute name="Base-Revision" value="${workspace.version}" />
    7979                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     80                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     81                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    8082            </manifest>
    8183        </jar>
  • apps/sam/java/src/net/i2p/sam/SAMHandlerFactory.java

    r01cfb7b r11579b9  
    9292            String user = props.getProperty("USER");
    9393            String pw = props.getProperty("PASSWORD");
    94             if (user == null || pw == null)
     94            if (user == null || pw == null) {
     95                if (user == null)
     96                    log.logAlways(Log.WARN, "SAM authentication failed");
     97                else
     98                    log.logAlways(Log.WARN, "SAM authentication failed, user: " + user);
    9599                throw new SAMException("USER and PASSWORD required");
     100            }
    96101            String savedPW = i2cpProps.getProperty(SAMBridge.PROP_PW_PREFIX + user + SAMBridge.PROP_PW_SUFFIX);
    97             if (savedPW == null)
     102            if (savedPW == null) {
     103                log.logAlways(Log.WARN, "SAM authentication failed, user: " + user);
    98104                throw new SAMException("Authorization failed");
     105            }
    99106            PasswordManager pm = new PasswordManager(I2PAppContext.getGlobalContext());
    100             if (!pm.checkHash(savedPW, pw))
     107            if (!pm.checkHash(savedPW, pw)) {
     108                log.logAlways(Log.WARN, "SAM authentication failed, user: " + user);
    101109                throw new SAMException("Authorization failed");
     110            }
    102111        }
    103112
  • apps/streaming/java/build.xml

    r01cfb7b r11579b9  
    214214                <attribute name="Base-Revision" value="${workspace.version}" />
    215215                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     216                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     217                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    216218            </manifest>
    217219        </jar>
  • apps/susidns/src/build.xml

    r01cfb7b r11579b9  
    118118                <attribute name="Base-Revision" value="${workspace.version}" />
    119119                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     120                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     121                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    120122            </manifest>
    121123        </war>
  • apps/susimail/build.xml

    r01cfb7b r11579b9  
    8282                <attribute name="Base-Revision" value="${workspace.version}" />
    8383                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     84                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     85                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    8486            </manifest>
    8587        </war>
  • apps/susimail/src/src/i2p/susi/webmail/WebMail.java

    r01cfb7b r11579b9  
    8888       
    8989        private static final long serialVersionUID = 1L;
     90        private static final String LOGIN_NONCE = Long.toString(I2PAppContext.getGlobalContext().random().nextLong());
    9091       
    9192        private static final String DEFAULT_HOST = "127.0.0.1";
     
    467468                /** @since 0.9.27 */
    468469                public boolean isValidNonce(String nonce) {
     470                        if (state == STATE_AUTH && LOGIN_NONCE.equals(nonce))
     471                                return true;
    469472                        synchronized(nonces) {
    470473                                return nonces.contains(nonce);
     
    857860                        sessionObject.info += _t("User logged out.") + '\n';
    858861                        sessionObject.state = STATE_AUTH;
    859                 } else if( sessionObject.mailbox == null ) {
     862                } else if( sessionObject.mailbox == null  && !buttonPressed(request, CANCEL)) {
    860863                        sessionObject.error += _t("Internal error, lost connection.") + '\n';
    861864                        sessionObject.state = STATE_AUTH;
     
    879882                        processLogin( sessionObject, request );
    880883
    881                 if( sessionObject.state != STATE_AUTH && sessionObject.state != STATE_CONFIG )
     884                if( sessionObject.state != STATE_AUTH )
    882885                        processLogout( sessionObject, request, isPOST );
    883886
     
    17981801                                }
    17991802                                out.print("</head>\n<body" + (sessionObject.state == STATE_LIST ? " onload=\"deleteboxclicked()\">" : ">"));
    1800                                 String nonce = Long.toString(ctx.random().nextLong());
     1803                                String nonce = sessionObject.state == STATE_AUTH ? LOGIN_NONCE :
     1804                                                                                   Long.toString(ctx.random().nextLong());
    18011805                                sessionObject.addNonce(nonce);
    18021806                                out.println(
     
    24102414                else
    24112415                        out.println(button(DELETE, _t("Delete")));
     2416                out.println(spacer + button(LOGOUT, _t("Logout") ));
    24122417                out.println("<br>" +
    24132418                        ( sessionObject.folder.isFirstElement( sessionObject.showUIDL ) ? button2( PREV, _t("Previous") ) : button( PREV, _t("Previous") ) ) + spacer +
     
    24172422                //if (Config.hasConfigFile())
    24182423                //      out.println(button( RELOAD, _t("Reload Config") ) + spacer);
    2419                 //out.println(button( LOGOUT, _t("Logout") ) );
    24202424                if( mail != null ) {
    24212425                        out.println( "<table cellspacing=\"0\" cellpadding=\"5\">\n" +
     
    24742478                out.println(button(SAVE, _t("Save Configuration")));
    24752479                out.println(button(CANCEL, _t("Cancel")));
     2480                if (sessionObject.folder != null)
     2481                        out.println(spacer + button(LOGOUT, _t("Logout") ));
    24762482                out.println("</div>");
    24772483        }
  • apps/systray/java/build.xml

    r01cfb7b r11579b9  
    6666                <attribute name="Base-Revision" value="${workspace.version}" />
    6767                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     68                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     69                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    6870            </manifest>
    6971        </jar>
  • build.xml

    r01cfb7b r11579b9  
    401401    </target>
    402402
    403     <target name="buildJrobin" depends="buildProperties" >
     403    <target name="buildJrobin" depends="buildCore" >
    404404        <ant dir="apps/jrobin/java/" target="jar" />
    405405        <copy file="apps/jrobin/java/build/jrobin.jar" todir="build/" />
     
    11851185
    11861186    <!-- see targets below for conditional copying -->
    1187     <target name="preppkg-base" depends="build, preplicenses, prepConsoleDocs, prepthemeupdates, prepCertificates, prepRouterInfos, copyjetty, copytomcat-unlesspkg, copyjstl-unlesspkg, copystandard-unlesspkg">
     1187    <target name="preppkg-base" depends="build, preplicenses, prepConsoleDocs, prepthemeupdates, prepCertificates, prepRouterInfos, copyjetty, copytomcat-unlesspkg, copyjstl-unlesspkg, copystandard-unlesspkg, truncatehistory">
    11881188        <!-- if updater200 was run previously, it left *.pack files in pkg-temp -->
    11891189        <!-- Also remove deletelist.txt used for updater only -->
     
    12191219        <copy file="installer/resources/hosts.txt" todir="pkg-temp/" />
    12201220        <copy file="INSTALL-headless.txt" todir="pkg-temp/" />
    1221         <!-- overwrite the truncated history put in by the updater -->
    1222         <copy file="history.txt" todir="pkg-temp/" overwrite="true" />
    12231221        <mkdir dir="pkg-temp/scripts" />
    12241222        <copy file="apps/proxyscript/i2pProxy.pac" todir="pkg-temp/scripts/" />
     
    15071505    </target>
    15081506
    1509     <target name="prepupdate" depends="build2, prepupdateSmall, prepConsoleDocUpdates, prepCertificates, prep-script-translation">
     1507    <target name="prepupdate" depends="build2, prepupdateSmall, prepConsoleDocUpdates, prepCertificates, prep-script-translation, truncatehistory">
    15101508        <copy file="build/BOB.jar" todir="pkg-temp/lib/" />
    15111509        <copy file="build/sam.jar" todir="pkg-temp/lib/" />
     
    15241522       -->
    15251523        <copy file="build/i2psnark.war" todir="pkg-temp/webapps/" />
     1524        <copy file="installer/resources/deletelist.txt" todir="pkg-temp/" />
     1525        <copy file="installer/resources/blocklist.txt" todir="pkg-temp/" />
     1526        <copy todir="pkg-temp/man/">
     1527            <fileset dir="installer/resources/man/" />
     1528        </copy>
     1529    </target>
     1530
     1531    <target name="truncatehistory">
    15261532        <copy file="history.txt" todir="pkg-temp/" />
    15271533        <!-- the following overwrites history.txt on unix to shrink the update file -->
     
    15311537            </filterchain>
    15321538        </copy>
    1533         <concat append="true" destfile="pkg-temp/history.txt">&#10;&#10;----------------&#10;&#10;EARLIER HISTORY IS AVAILABLE IN THE SOURCE PACKAGE"</concat>
    1534         <copy file="installer/resources/deletelist.txt" todir="pkg-temp/" />
    1535         <copy file="installer/resources/blocklist.txt" todir="pkg-temp/" />
    1536         <copy todir="pkg-temp/man/">
    1537             <fileset dir="installer/resources/man/" />
    1538         </copy>
     1539        <concat append="true" destfile="pkg-temp/history.txt">&#10;&#10;----------------&#10;&#10;EARLIER HISTORY IS AVAILABLE IN THE SOURCE PACKAGE</concat>
    15391540    </target>
    15401541
  • core/java/build.xml

    r01cfb7b r11579b9  
    109109                <attribute name="Main-Class" value="net.i2p.util.CommandLine" />
    110110                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     111                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     112                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    111113            </manifest>
    112114        </jar>
  • core/java/src/net/i2p/client/impl/RequestLeaseSetMessageHandler.java

    r01cfb7b r11579b9  
    1010 */
    1111
     12import java.io.EOFException;
    1213import java.security.GeneralSecurityException;
    1314import java.util.Map;
     
    186187            session.propogateError("Error signing the leaseSet", dfe);
    187188        } catch (I2PSessionException ise) {
    188             session.propogateError("Error sending the signed leaseSet", ise);
     189            if (session.isClosed()) {
     190                // race, closed while signing leaseset
     191                // EOFExceptions are logged at WARN level (see I2PSessionImpl.propogateError())
     192                // so the user won't see this
     193                EOFException eof = new EOFException("Session closed while signing leaseset");
     194                eof.initCause(ise);
     195                session.propogateError("Session closed while signing leaseset", eof);
     196            } else {
     197                session.propogateError("Error sending the signed leaseSet", ise);
     198            }
    189199        }
    190200    }
  • core/java/src/net/i2p/crypto/CertUtil.java

    r01cfb7b r11579b9  
    536536
    537537
    538 
    539 /****
    540538    public static final void main(String[] args) {
    541539        if (args.length < 2) {
     
    546544            File f = new File(args[1]);
    547545            if (args[0].equals("loadcert")) {
    548                 loadCert(f);
     546                X509Certificate cert = loadCert(f);
     547                System.out.println(net.i2p.util.HexDump.dump(cert.getEncoded()));
    549548            } else if (args[0].equals("loadcrl")) {
    550549                loadCRL(f);
     
    570569        }
    571570    }
    572 ****/
    573571}
  • core/java/src/net/i2p/crypto/SelfSignedGenerator.java

    r01cfb7b r11579b9  
    265265        byte[] version = { (byte) 0xa0, 3, 2, 1, 2 };
    266266
    267         // postive serial number (int)
    268         byte[] serial = new byte[6];
     267        // positive serial number (long)
     268        byte[] serial = new byte[10];
    269269        serial[0] = 2;
    270         serial[1] = 4;
    271         RandomSource.getInstance().nextBytes(serial, 2, 4);
     270        serial[1] = 8;
     271        RandomSource.getInstance().nextBytes(serial, 2, 8);
    272272        serial[2] &= 0x7f;
    273273
  • core/java/src/net/i2p/crypto/eddsa/math/Constants.java

    r01cfb7b r11579b9  
    33import net.i2p.crypto.eddsa.Utils;
    44
    5 public class Constants {
     5final class Constants {
    66    public static final byte[] ZERO = Utils.hexToBytes("0000000000000000000000000000000000000000000000000000000000000000");
    77    public static final byte[] ONE = Utils.hexToBytes("0100000000000000000000000000000000000000000000000000000000000000");
  • core/java/src/net/i2p/util/Addresses.java

    r01cfb7b r11579b9  
    55 */
    66
     7import java.io.BufferedReader;
     8import java.io.File;
     9import java.io.FileInputStream;
     10import java.io.IOException;
     11import java.io.InputStreamReader;
    712import java.net.InetAddress;
    813import java.net.Inet4Address;
     14import java.net.Inet6Address;
    915import java.net.NetworkInterface;
    1016import java.net.SocketException;
     
    1319import java.util.Collections;
    1420import java.util.Enumeration;
     21import java.util.HashMap;
    1522import java.util.List;
    1623import java.util.Map;
     
    2229
    2330import net.i2p.I2PAppContext;
     31import net.i2p.data.DataHelper;
     32
    2433
    2534/**
     
    3140public abstract class Addresses {
    3241   
     42    private static final File IF_INET6_FILE = new File("/proc/net/if_inet6");
     43    private static final long INET6_CACHE_EXPIRE = 10*60*1000;
     44    private static final boolean INET6_CACHE_ENABLED = !SystemVersion.isMac() && !SystemVersion.isWindows() &&
     45                                                    !SystemVersion.isAndroid() && IF_INET6_FILE.exists();
     46    private static final int FLAG_PERMANENT = 0x80;
     47    private static final int FLAG_DEPRECATED = 0x20;
     48    private static final int FLAG_TEMPORARY = 0x01;
     49    private static long _ifCacheTime;
     50    private static final Map<Inet6Address, Inet6Addr> _ifCache = INET6_CACHE_ENABLED ? new HashMap<Inet6Address, Inet6Addr>(8) : null;
     51
    3352    /**
    3453     *  Do we have any non-loop, non-wildcard IPv4 address at all?
     
    102121        boolean haveIPv6 = false;
    103122        SortedSet<String> rv = new TreeSet<String>();
     123        final boolean omitDeprecated = INET6_CACHE_ENABLED && !includeSiteLocal && includeIPv6;
    104124        try {
    105125            InetAddress localhost = InetAddress.getLocalHost();
     
    107127            if (allMyIps != null) {
    108128                for (int i = 0; i < allMyIps.length; i++) {
    109                     if (allMyIps[i] instanceof Inet4Address)
     129                    boolean isv4 = allMyIps[i] instanceof Inet4Address;
     130                    if (isv4)
    110131                        haveIPv4 = true;
    111132                    else
    112133                        haveIPv6 = true;
     134                    if (omitDeprecated && !isv4) {
     135                        if (isDeprecated((Inet6Address) allMyIps[i]))
     136                            continue;
     137                    }
    113138                    if (shouldInclude(allMyIps[i], includeSiteLocal,
    114                                       includeLoopbackAndWildcard, includeIPv6))
     139                                      includeLoopbackAndWildcard, includeIPv6)) {
    115140                        rv.add(stripScope(allMyIps[i].getHostAddress()));
     141                    }
    116142                }
    117143            }
     
    125151                    for(Enumeration<InetAddress> addrs =  ifc.getInetAddresses(); addrs.hasMoreElements();) {
    126152                        InetAddress addr = addrs.nextElement();
    127                         if (addr instanceof Inet4Address)
     153                        boolean isv4 = addr instanceof Inet4Address;
     154                        if (isv4)
    128155                            haveIPv4 = true;
    129156                        else
    130157                            haveIPv6 = true;
     158                        if (omitDeprecated && !isv4) {
     159                            if (isDeprecated((Inet6Address) addr))
     160                                continue;
     161                        }
    131162                        if (shouldInclude(addr, includeSiteLocal,
    132                                           includeLoopbackAndWildcard, includeIPv6))
     163                                          includeLoopbackAndWildcard, includeIPv6)) {
    133164                            rv.add(stripScope(addr.getHostAddress()));
     165                        }
    134166                    }
    135167                }
     
    334366    /**
    335367     *  For literal IP addresses, this is the same as getIP(String).
    336      *  For host names, will return the preferred type (IPv4/v6) if available,
    337      *  else the other type if available.
     368     *  For host names, may return multiple addresses, both IPv4 and IPv6,
     369     *  even if those addresses are not reachable due to configuration or available interfaces.
    338370     *  Will resolve but not cache DNS host names.
    339371     *
     
    371403    }
    372404
     405    //////// IPv6 Cache Utils ///////
     406
     407    /**
     408     *  @since 0.9.28
     409     */
     410    private static class Inet6Addr {
     411        private final Inet6Address addr;
     412        private final boolean isDyn, isDep, isTemp;
     413
     414        public Inet6Addr(Inet6Address a, int flags) {
     415            addr = a;
     416            isDyn = (flags & FLAG_PERMANENT) == 0;
     417            isDep = (flags & FLAG_DEPRECATED) != 0;
     418            isTemp = (flags & FLAG_TEMPORARY) != 0;
     419        }
     420
     421        public Inet6Address getAddress() { return addr; }
     422        public boolean isDynamic() { return isDyn; }
     423        public boolean isDeprecated() { return isDep; }
     424        public boolean isTemporary() { return isTemp; }
     425    }
     426
     427    /**
     428     *  Only call if INET6_CACHE_ENABLED.
     429     *  Caller must sync on _ifCache.
     430     *  @since 0.9.28
     431     */
     432    private static void refreshCache() {
     433        long now = System.currentTimeMillis();
     434        if (now - _ifCacheTime < INET6_CACHE_EXPIRE)
     435            return;
     436        _ifCache.clear();
     437        BufferedReader in = null;
     438        try {
     439            in = new BufferedReader(new InputStreamReader(new FileInputStream(IF_INET6_FILE), "ISO-8859-1"), 4096);
     440            String line = null;
     441            while ( (line = in.readLine()) != null) {
     442                // http://tldp.org/HOWTO/html_single/Linux+IPv6-HOWTO/#PROC-NET
     443                // 00000000000000000000000000000001 01 80 10 80       lo
     444                String[] parts = DataHelper.split(line, " ", 6);
     445                if (parts.length < 5)
     446                    continue;
     447                String as = parts[0];
     448                if (as.length() != 32)
     449                    continue;
     450                StringBuilder buf = new StringBuilder(40);
     451                int i = 0;
     452                while(true) {
     453                    buf.append(as.substring(i, i+4));
     454                    i += 4;
     455                    if (i >= 32)
     456                        break;
     457                    buf.append(':');
     458                }
     459                Inet6Address addr;
     460                try {
     461                    addr = (Inet6Address) InetAddress.getByName(buf.toString());
     462                } catch (UnknownHostException uhe) {
     463                    continue;
     464                }
     465                int flags = FLAG_PERMANENT;
     466                try {
     467                    flags = Integer.parseInt(parts[4], 16);
     468                } catch (NumberFormatException nfe) {}
     469                Inet6Addr a = new Inet6Addr(addr, flags);
     470                _ifCache.put(addr, a);
     471            }
     472        } catch (IOException ioe) {
     473        } finally {
     474            if (in != null) try { in.close(); } catch (IOException ioe) {}
     475        }
     476        _ifCacheTime = now;
     477    }
     478
     479    /**
     480     *  Is this address dynamic?
     481     *  Returns false if unknown.
     482     *  @since 0.9.28
     483     */
     484    public static boolean isDynamic(Inet6Address addr) {
     485        if (!INET6_CACHE_ENABLED)
     486            return false;
     487        Inet6Addr a;
     488        synchronized(_ifCache) {
     489            refreshCache();
     490            a = _ifCache.get(addr);
     491        }
     492        if (a == null)
     493            return false;
     494        return a.isDynamic();
     495    }
     496
     497    /**
     498     *  Is this address deprecated?
     499     *  Returns false if unknown.
     500     *  @since 0.9.28
     501     */
     502    public static boolean isDeprecated(Inet6Address addr) {
     503        if (!INET6_CACHE_ENABLED)
     504            return false;
     505        Inet6Addr a;
     506        synchronized(_ifCache) {
     507            refreshCache();
     508            a = _ifCache.get(addr);
     509        }
     510        if (a == null)
     511            return false;
     512        return a.isDeprecated();
     513    }
     514
     515    /**
     516     *  Is this address temporary?
     517     *  Returns false if unknown.
     518     *  @since 0.9.28
     519     */
     520    public static boolean isTemporary(Inet6Address addr) {
     521        if (!INET6_CACHE_ENABLED)
     522            return false;
     523        Inet6Addr a;
     524        synchronized(_ifCache) {
     525            refreshCache();
     526            a = _ifCache.get(addr);
     527        }
     528        if (a == null)
     529            return false;
     530        return a.isTemporary();
     531    }
     532
     533    //////// End IPv6 Cache Utils ///////
     534
    373535    /**
    374536     *  @since 0.9.3
     
    378540            _IPAddress.clear();
    379541        }
     542        if (_ifCache != null) {
     543            synchronized(_ifCache) {
     544                _ifCache.clear();
     545                _ifCacheTime = 0;
     546            }
     547        }
    380548    }
    381549
     
    384552     */
    385553    public static void main(String[] args) {
    386         System.err.println("External IPv4 Addresses:");
     554        System.out.println("External IPv4 Addresses:");
    387555        Set<String> a = getAddresses(false, false, false);
    388556        for (String s : a)
    389             System.err.println(s);
    390         System.err.println("\nExternal and Local IPv4 Addresses:");
     557            System.out.println(s);
     558        System.out.println("\nExternal and Local IPv4 Addresses:");
    391559        a = getAddresses(true, false, false);
    392560        for (String s : a)
    393             System.err.println(s);
    394         System.err.println("\nAll External Addresses:");
     561            System.out.println(s);
     562        System.out.println("\nAll External Addresses:");
    395563        a = getAddresses(false, false, true);
    396564        for (String s : a)
    397             System.err.println(s);
    398         System.err.println("\nAll External and Local Addresses:");
     565            System.out.println(s);
     566        System.out.println("\nAll External and Local Addresses:");
    399567        a = getAddresses(true, false, true);
    400568        for (String s : a)
    401             System.err.println(s);
    402         System.err.println("\nAll addresses:");
     569            System.out.println(s);
     570        System.out.println("\nAll addresses:");
    403571        a = getAddresses(true, true, true);
    404572        for (String s : a)
    405             System.err.println(s);
    406         System.err.println("\nIs connected? " + isConnected());
     573            System.out.println(s);
     574        System.out.println("\nIPv6 address flags:");
     575        for (String s : a) {
     576            if (!s.contains(":"))
     577                continue;
     578            StringBuilder buf = new StringBuilder(64);
     579            buf.append(s);
     580            Inet6Address addr;
     581            try {
     582                addr = (Inet6Address) InetAddress.getByName(buf.toString());
     583                if (addr.isSiteLocalAddress())
     584                    buf.append(" host");
     585                else if (addr.isLinkLocalAddress())
     586                    buf.append(" link");
     587                else if (addr.isAnyLocalAddress())
     588                    buf.append(" wildcard");
     589                else if (addr.isLoopbackAddress())
     590                    buf.append(" loopback");
     591                else
     592                    buf.append(" global");
     593                if (isTemporary(addr))
     594                    buf.append(" temporary");
     595                if (isDeprecated(addr))
     596                    buf.append(" deprecated");
     597                if (isDynamic(addr))
     598                    buf.append(" dynamic");
     599            } catch (UnknownHostException uhe) {}
     600            System.out.println(buf.toString());
     601        }
     602        System.out.println("\nIs connected? " + isConnected());
    407603    }
    408604}
  • core/java/src/net/i2p/util/CommandLine.java

    r01cfb7b r11579b9  
    2323        "net.i2p.CoreVersion",
    2424        "net.i2p.client.naming.BlockfileNamingService",
     25        "net.i2p.crypto.CertUtil",
    2526        "net.i2p.crypto.CryptoCheck",
    2627        "net.i2p.crypto.SU3File",
  • core/java/src/net/i2p/util/LogWriter.java

    r01cfb7b r11579b9  
    3030    protected volatile boolean _write;
    3131    private LogRecord _last;
     32    private long _firstTimestamp;
    3233    // ms
    3334    private volatile long _flushInterval = FLUSH_INTERVAL;
     
    9697            if (records == null) return;
    9798            if (!records.isEmpty()) {
    98                 if (_last != null && _last.getDate() < _manager.getContext().clock().now() - 30*60*1000)
     99                if (_last != null && _firstTimestamp < _manager.getContext().clock().now() - 30*60*1000)
    99100                    _last = null;
    100101                LogRecord rec;
     
    109110                        }
    110111                        writeRecord(rec);
     112                        _firstTimestamp = rec.getDate();
    111113                    }
    112114                    _last = rec;
  • core/java/src/net/i2p/util/SystemVersion.java

    r01cfb7b r11579b9  
    3535    private static final boolean _is64;
    3636    private static final boolean _hasWrapper = System.getProperty("wrapper.version") != null;
    37     private static final boolean _isLinuxService = !_isWin && !_isMac &&
    38                                                    DAEMON_USER.equals(System.getProperty("user.name"));
     37    private static final boolean _isLinuxService;
    3938
    4039    private static final boolean _oneDotSix;
     
    6463        String runtime = System.getProperty("java.runtime.name");
    6564        _isOpenJDK = runtime != null && runtime.contains("OpenJDK");
     65        _isLinuxService = !_isWin && !_isMac && !_isAndroid &&
     66                          DAEMON_USER.equals(System.getProperty("user.name"));
    6667
    6768        int sdk = 0;
  • history.txt

    r01cfb7b r11579b9  
     12016-11-16 zzz
     2 * Console: Remove dead home page links (ticket #1882)
     3 * Profiles: Pull same-IP detection into a utility class
     4 * Router: Add methods to verify and track members of our family
     5
     62016-11-15 zzz
     7 * Certs: Add Let's Encrypt ISRG Root X1 cert
     8
     92016-11-14 zzz
     10 * Logs: Fix output of dup message after 30 minutes
     11
     122016-11-13 zzz
     13 * Console: Add initial news to bottom of news page (ticket #1153)
     14 * i2psnark: Periodically DHT nodes (ticket #1328)
     15 * UPnP:
     16   - Prevent exception on bad HTTP header (ticket #1480)
     17   - Prevent NPE on socket creation fail (tickets #728, #1681)
     18
     192016-11-12 zzz
     20 * Console:
     21   - Fix inadvertent config save when clicking sidebar
     22     buttons on /configstats
     23   - Add IPv6 firewalled setting on /confignet
     24 * I2CP: Reduce error level on session closed while signing LS (ticket #1606)
     25 * JRobin: Move DeallocationHelper logging from wrapper log to router log
     26 * Profiles: Periodically save, delete old ones after saving (ticket #1328)
     27 * Susimail:
     28   - Add logout button to more pages (ticket #1374)
     29   - Fix nonce error on login after logout
     30   - Fix internal error after cancel button on settings form when not logged in
     31
     322016-11-11 zzz
     33 * Build: Truncate history.txt bundled in installers
     34
     352016-11-10 zzz
     36 * Transport: Use NTCP for some outbound connections even before
     37   SSU minimums are met (ticket #1835)
     38
     392016-11-09 zzz
     40 * Transport: Add stats for inbound v4/v6 connections (ticket #1854)
     41 * Tunnels: Reduce default VTBM records from 5 to 4
     42
     432016-11-08 zzz
     44 * Build: Fix minimum Java version for Windows
     45 * Install: Add max memory option to runplain.sh
     46 * Crypto: Change serial number in selfsigned certs from int to long
     47 * Router: Fix low-memory log messages for non-wrapper (ticket #1795)
     48 * Transport: Improve IPv6 selection logic
     49
     502016-11-06 zzz
     51 * Console: Add Java 9 log warning (ticket #1870)
     52 * Security: Consistently log authentication failures for all interfaces
     53 * Util: Consolidate linux service detection code
     54
     552016-11-05 zzz
     56 * Build: Add support for using libtomcat8-java package
     57 * Console: Add message to ignore InstanceManager warning (ticket #1818)
     58 * SusiDNS: Fix jsp EL syntax error with EL 3.0 (Tomcat 8) (ticket #1870)
     59
     602016-11-04 zzz
     61 * Console: Improve handling and logging of webapps that fail to start
     62 * i2psnark: Add launch-i2psnark.bat (ticket #1871)
     63 * Transports:
     64   - New config i2np.allowLocal, fixes test networks (ticket #1875)
     65   - New configs i2np.udp.minpeers and i2np.udp.minv6peers, for testing (ticket #1876)
     66
    1672016-10-29 zzz
    268 * Console: Java 9 fixes for classloader (ticket #1870)
     
    48114 * Debian: Update package descriptions, allow Java 9
    49115 * i2psnark: Add ids to rows, add to per-torrent show peers link
    50  * SSU: Fix minimum version check for IPv6 peer test (ticket #1861)
     116 * SSU: Fix minimum version check for IPv6 peer test (tickets #1829, #1861)
    51117
    52118* 2016-10-17 0.9.27 released
  • installer/i2pinstaller.xml

    r01cfb7b r11579b9  
    88  <icon>resources/console.ico</icon>
    99  <jre>
    10     <minVersion>1.6.0</minVersion>
     10    <minVersion>1.7.0</minVersion>
    1111  </jre>
    1212  <!--
  • installer/i2pstandalone.xml

    r01cfb7b r11579b9  
    88  <icon>resources/start.ico</icon>
    99  <jre>
    10     <minVersion>1.6.0</minVersion>
     10    <minVersion>1.7.0</minVersion>
    1111    <!--
    1212    <minHeapSize>64</minHeapSize>
  • installer/java/build.xml

    r01cfb7b r11579b9  
    5858                <attribute name="Base-Revision" value="${workspace.version}" />
    5959                <attribute name="Workspace-Changes" value="${workspace.changes.util.tr}" />
     60                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     61                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    6062            </manifest>
    6163        </jar>
  • installer/resources/blocklist.txt

    r01cfb7b r11579b9  
    4646#   *   44-byte Base64 router hash
    4747#   *
     48#   * Acceptable formats (IPV6 only):
     49#   *   comment:IPv6 (must replace : with ; e.g. abcd;1234;0;12;;ff)
     50#   *   IPv6 (must replace : with ; e.g. abcd;1234;0;12;;ff)
     51#   *
    4852#   * No whitespace allowed after the last ':'.
    4953#   *
  • installer/resources/runplain.sh

    r01cfb7b r11579b9  
    44# This means the router will not restart if it crashes.
    55# Also, you will be using the default memory size, which is
    6 # probably not enough for i2p.
     6# probably not enough for i2p, unless you set it below.
    77# You should really use the i2prouter script instead.
    88#
     
    1919PREFERv4="false"
    2020CP=
     21
     22# Uncomment to set the maximum memory. The default and the option may vary in different JVMs.
     23# Check your java documentation to be sure.
     24#MAXMEMOPT="-Xmx256m"
    2125
    2226# Try using the Java binary that I2P was installed with.
     
    4044    export JAVA_TOOL_OPTIONS="-Djava.awt.headless=true"
    4145fi
    42 JAVAOPTS="-Djava.net.preferIPv4Stack=${PREFERv4} -Djava.library.path=${I2P}:${I2P}/lib -Di2p.dir.base=${I2P} -DloggerFilenameOverride=logs/log-router-@.txt"
     46JAVAOPTS="${MAXMEMOPT} -Djava.net.preferIPv4Stack=${PREFERv4} -Djava.library.path=${I2P}:${I2P}/lib -Di2p.dir.base=${I2P} -DloggerFilenameOverride=logs/log-router-@.txt"
    4347(
    4448    nohup ${JAVA} -cp \"${CP}\" ${JAVAOPTS} net.i2p.router.RouterLaunch > /dev/null 2>&1
  • installer/tools/java/build.xml

    r01cfb7b r11579b9  
    3939                <attribute name="Build-Date" value="${build.timestamp}" />
    4040                <attribute name="Base-Revision" value="${workspace.version}" />
     41                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     42                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    4143            </manifest>
    4244        </jar>
  • router/java/build.xml

    r01cfb7b r11579b9  
    7979                <attribute name="Main-Class" value="net.i2p.router.CommandLine" />
    8080                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     81                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     82                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
    8183            </manifest>
    8284        </jar>
  • router/java/src/net/i2p/router/Blocklist.java

    r01cfb7b r11579b9  
    249249    *   44-byte Base64 router hash
    250250    *
     251    * Acceptable formats (IPV6 only):
     252    *   comment:IPv6 (must replace : with ; e.g. abcd;1234;0;12;;ff)
     253    *   IPv6 (must replace : with ; e.g. abcd;1234;0;12;;ff)
     254    *
    251255    * No whitespace allowed after the last ':'.
    252256    *
     
    291295                }
    292296                byte[] ip1 = e.ip1;
    293                 byte[] ip2 = e.ip2;
    294 
    295                 store(ip1, ip2, count++);
    296                 ipcount += 1 + toInt(ip2) - toInt(ip1); // includes dups, oh well
     297                if (ip1.length == 4) {
     298                    byte[] ip2 = e.ip2;
     299                    store(ip1, ip2, count++);
     300                    ipcount += 1 + toInt(ip2) - toInt(ip1); // includes dups, oh well
     301                } else {
     302                    // IPv6
     303                    add(ip1);
     304                }
    297305            }
    298306        } catch (IOException ioe) {
     
    394402        int mask = -1;
    395403        String comment = null;
    396         int index = buf.indexOf("#");
     404        int index = buf.indexOf('#');
    397405        if (index == 0)
    398406            return null;  // comment
    399         index = buf.lastIndexOf(":");
     407        index = buf.lastIndexOf(':');
    400408        if (index >= 0) {
    401409            comment = buf.substring(0, index);
    402410            start1 = index + 1;
    403411        }
    404         if (end1 - start1 == 44 && buf.substring(start1).indexOf(".") < 0) {
     412        if (end1 - start1 == 44 && buf.substring(start1).indexOf('.') < 0) {
    405413            byte b[] = Base64.decode(buf.substring(start1));
    406414            if (b != null)
    407415                return new Entry(comment, Hash.create(b), null, null);
    408416        }
    409         index = buf.indexOf("-", start1);
     417        index = buf.indexOf('-', start1);
    410418        if (index >= 0) {
    411419            end1 = index;
    412420            start2 = index + 1;
    413421        } else {
    414             index = buf.indexOf("/", start1);
     422            index = buf.indexOf('/', start1);
    415423            if (index >= 0) {
    416424                end1 = index;
     
    421429            return null;  // blank
    422430        try {
    423             InetAddress pi = InetAddress.getByName(buf.substring(start1, end1));
     431            String sip = buf.substring(start1, end1);
     432            // IPv6
     433            sip = sip.replace(';', ':');
     434            InetAddress pi = InetAddress.getByName(sip);
    424435            if (pi == null) return null;
    425436            ip1 = pi.getAddress();
    426             if (ip1.length != 4)
    427                 throw new UnknownHostException();
     437            //if (ip1.length != 4)
     438            //    throw new UnknownHostException();
    428439            if (start2 >= 0) {
    429440                pi = InetAddress.getByName(buf.substring(start2));
     
    463474            }
    464475        } catch (UnknownHostException uhe) {
    465             if (shouldLog && _log.shouldLog(Log.ERROR))
    466                 _log.error("Format error in the blocklist file: " + buf);
     476            if (shouldLog)
     477                _log.logAlways(Log.WARN, "Format error in the blocklist file: " + buf);
    467478            return null;
    468479        } catch (NumberFormatException nfe) {
    469             if (shouldLog && _log.shouldLog(Log.ERROR))
    470                 _log.error("Format error in the blocklist file: " + buf);
     480            if (shouldLog)
     481                _log.logAlways(Log.WARN, "Format error in the blocklist file: " + buf);
    471482            return null;
    472483        } catch (IndexOutOfBoundsException ioobe) {
    473             if (shouldLog && _log.shouldLog(Log.ERROR))
    474                 _log.error("Format error in the blocklist file: " + buf);
     484            if (shouldLog)
     485                _log.logAlways(Log.WARN, "Format error in the blocklist file: " + buf);
    475486            return null;
    476487        }
     
    744755    }
    745756
     757    /**
     758     *  IPv4 only
     759     */
    746760    private void store(byte ip1[], byte ip2[], int idx) {
    747761        _blocklist[idx] = toEntry(ip1, ip2);
     
    10361050
    10371051/****
    1038     public static void main(String args[]) {
    1039         Blocklist b = new Blocklist();
    1040         if ( (args != null) && (args.length == 1) )
    1041             b.readBlocklistFile(args[0]);
     1052    public static void main(String args[]) throws Exception {
     1053        Blocklist b = new Blocklist(new Router().getContext());
     1054        if (args != null && args.length == 1) {
     1055            File f = new File(args[0]);
     1056            b.allocate(Collections.singletonList(f));
     1057            int count = b.readBlocklistFile(f, 0);
     1058            b.merge(count);
     1059            Writer w = new java.io.OutputStreamWriter(System.out);
     1060            b.renderStatusHTML(w);
     1061        }
    10421062        System.out.println("Saved " + b._blocklistSize + " records");
    10431063        String tests[] = {"0.0.0.0", "0.0.0.1", "0.0.0.2", "0.0.0.255", "1.0.0.0",
  • router/java/src/net/i2p/router/CommandLine.java

    r01cfb7b r11579b9  
    2424        "net.i2p.router.transport.GeoIPv6",
    2525        "net.i2p.router.transport.udp.MTU",
    26         //"net.i2p.router.transport.UPnP"
     26        "net.i2p.router.transport.UPnP"
    2727    });
    2828
  • router/java/src/net/i2p/router/RouterVersion.java

    r01cfb7b r11579b9  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 6;
     21    public final static long BUILD = 9;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/client/ClientMessageEventListener.java

    r01cfb7b r11579b9  
    330330            }
    331331            if (user == null || user.length() == 0 || pw == null || pw.length() == 0) {
    332                 _log.error("I2CP auth failed");
     332                _log.logAlways(Log.WARN, "I2CP authentication failed");
    333333                _runner.disconnectClient("Authorization required, specify i2cp.username and i2cp.password in options");
    334334                _authorized = false;
     
    337337            PasswordManager mgr = new PasswordManager(_context);
    338338            if (!mgr.checkHash(PROP_AUTH, user, pw)) {
    339                 _log.error("I2CP auth failed user: " + user);
     339                _log.logAlways(Log.WARN, "I2CP authentication failed, user: " + user);
    340340                _runner.disconnectClient("Authorization failed, user = " + user);
    341341                _authorized = false;
  • router/java/src/net/i2p/router/crypto/FamilyKeyCrypto.java

    r01cfb7b r11579b9  
    1111import java.security.cert.X509Certificate;
    1212import java.security.cert.X509CRL;
     13import java.util.Collections;
    1314import java.util.HashMap;
    1415import java.util.Map;
     
    4546    private final Map<Hash, String> _verified;
    4647    private final Set<Hash> _negativeCache;
     48    private final Set<Hash> _ourFamily;
    4749    // following for verification only, otherwise null
    4850    private final String _fname;
     
    8385        if (_fname != null) {
    8486            if (_fname.contains("/") || _fname.contains("\\") ||
    85                 _fname.contains("..") || (new File(_fname)).isAbsolute())
    86                 throw new GeneralSecurityException("Illegal family name");
     87                _fname.contains("..") || (new File(_fname)).isAbsolute() ||
     88                _fname.length() <= 0)
     89                throw new GeneralSecurityException("Illegal family name: " + _fname);
    8790        }
    8891        _privkey = (_fname != null) ? initialize() : null;
     
    9093        _verified = new ConcurrentHashMap<Hash, String>(4);
    9194        _negativeCache = new ConcurrentHashSet<Hash>(4);
     95        _ourFamily = (_privkey != null) ? new ConcurrentHashSet<Hash>(4) : Collections.<Hash>emptySet();
    9296    }
    9397   
     
    146150
    147151    /**
     152     *  Do we have a valid family?
     153     *  @since 0.9.28
     154     */
     155    public boolean hasFamily() {
     156        return _pubkey != null;
     157    }
     158
     159    /**
     160     *  Get verified members of our family.
     161     *  Will not contain ourselves.
     162     *
     163     *  @return non-null, not a copy, do not modify
     164     *  @since 0.9.28
     165     */
     166    public Set<Hash> getOurFamily() {
     167        return _ourFamily;
     168    }
     169
     170    /**
     171     *  Get our family name.
     172     *
     173     *  @return name or null
     174     *  @since 0.9.28
     175     */
     176    public String getOurFamilyName() {
     177        return _fname;
     178    }
     179
     180    /**
    148181     *  Verify the family signature in a RouterInfo.
    149182     *  @return true if good sig or if no family specified at all
     
    153186        if (name == null)
    154187            return true;
     188        return verify(ri, name);
     189    }
     190
     191    /**
     192     *  Verify the family in a RouterInfo matches ours and the signature is good.
     193     *  Returns false if we don't have a family and sig, or they don't.
     194     *  Returns false for ourselves.
     195     *
     196     *  @return true if family matches with good sig
     197     *  @since 0.9.28
     198     */
     199    public boolean verifyOurFamily(RouterInfo ri) {
     200        if (_pubkey == null)
     201            return false;
     202        String name = ri.getOption(OPT_NAME);
     203        if (!_fname.equals(name))
     204            return false;
     205        Hash h = ri.getHash();
     206        if (_ourFamily.contains(h))
     207            return true;
     208        if (h.equals(_context.routerHash()))
     209            return false;
     210        boolean rv = verify(ri, name);
     211        if (rv) {
     212            _ourFamily.add(h);
     213            _log.logAlways(Log.INFO, "Found and verified member of our family (" + _fname + "): " + h);
     214        } else {
     215            if (_log.shouldWarn())
     216                _log.warn("Found spoofed member of our family (" + _fname + "): " + h);
     217        }
     218        return rv;
     219    }
     220
     221    /**
     222     *  Verify the family in a RouterInfo, name already retrieved
     223     *  @since 0.9.28
     224     */
     225    private boolean verify(RouterInfo ri, String name) {
    155226        Hash h = ri.getHash();
    156227        String ssig = ri.getOption(OPT_SIG);
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillVerifyStoreJob.java

    r01cfb7b r11579b9  
    2020import net.i2p.router.RouterContext;
    2121import net.i2p.router.TunnelInfo;
     22import net.i2p.router.util.MaskedIPSet;
    2223import net.i2p.util.Log;
    2324
     
    4041    private MessageWrapper.WrappedMessage _wrappedMessage;
    4142    private final Set<Hash> _ignore;
     43    private final MaskedIPSet _ipSet;
    4244   
    4345    private static final int START_DELAY = 18*1000;
     
    4547    private static final int VERIFY_TIMEOUT = 20*1000;
    4648    private static final int MAX_PEERS_TO_TRY = 4;
     49    private static final int IP_CLOSE_BYTES = 3;
    4750   
    4851    /**
     
    6164        _ignore = new HashSet<Hash>(MAX_PEERS_TO_TRY);
    6265        if (sentTo != null) {
     66            _ipSet = new MaskedIPSet(ctx, sentTo, IP_CLOSE_BYTES);
    6367            _ignore.add(_sentTo);
     68        } else {
     69            _ipSet = new MaskedIPSet(4);
    6470        }
    6571        // wait some time before trying to verify the store
     
    189195                Hash peer = peers.get(0);
    190196                RouterInfo ri = _facade.lookupRouterInfoLocally(peer);
    191                 if (ri != null && StoreJob.supportsCert(ri, keyCert))
    192                     return peer;
    193                 if (_log.shouldLog(Log.INFO))
    194                     _log.info(getJobId() + ": Skipping verify w/ router that doesn't support key certs " + peer);
     197                if (ri != null && StoreJob.supportsCert(ri, keyCert)) {
     198                    Set<String> peerIPs = new MaskedIPSet(getContext(), ri, IP_CLOSE_BYTES);
     199                    if (!_ipSet.containsAny(peerIPs)) {
     200                        _ipSet.addAll(peerIPs);
     201                        return peer;
     202                    } else {
     203                        if (_log.shouldLog(Log.INFO))
     204                            _log.info(getJobId() + ": Skipping verify w/ router too close to the store " + peer);
     205                    }
     206                } else {
     207                    if (_log.shouldLog(Log.INFO))
     208                        _log.info(getJobId() + ": Skipping verify w/ router that doesn't support key certs " + peer);
     209                }
    195210                _ignore.add(peer);
    196211            }
  • router/java/src/net/i2p/router/peermanager/PeerManager.java

    r01cfb7b r11579b9  
    1818import java.util.Set;
    1919import java.util.concurrent.ConcurrentHashMap;
     20import java.util.concurrent.atomic.AtomicBoolean;
    2021
    2122import net.i2p.data.Hash;
     
    4445    /** value strings are lower case */
    4546    private final Map<Hash, String> _capabilitiesByPeer;
     47    private final AtomicBoolean _storeLock = new AtomicBoolean();
     48    private volatile long _lastStore;
     49
    4650    private static final long REORGANIZE_TIME = 45*1000;
    4751    private static final long REORGANIZE_TIME_MEDIUM = 123*1000;
     
    5357     */
    5458    private static final long REORGANIZE_TIME_LONG = 351*1000;
     59    private static final long STORE_TIME = 19*60*60*1000;
     60    private static final long EXPIRE_AGE = 3*24*60*60*1000;
    5561   
    5662    public static final String TRACKED_CAPS = "" +
     
    98104
    99105    /**
     106     *  Reorganize the profiles. Also periodically store them,
     107     *  and delete very old ones.
     108     *
    100109     *  This takes too long to run on the SimpleTimer2 queue
    101110     *  @since 0.9.10
    102111     */
    103112    private class ReorgThread extends I2PThread {
    104         private SimpleTimer2.TimedEvent _event;
     113        private final SimpleTimer2.TimedEvent _event;
    105114
    106115        public ReorgThread(SimpleTimer2.TimedEvent event) {
     
    118127            }
    119128            long orgtime = System.currentTimeMillis() - start;
     129            if (_lastStore == 0) {
     130                _lastStore = start;
     131            } else if (start - _lastStore > STORE_TIME) {
     132                _lastStore = start;
     133                try {
     134                    _log.debug("Periodic profile store start");
     135                    storeProfiles();
     136                    _persistenceHelper.deleteOldProfiles(EXPIRE_AGE);
     137                    _log.debug("Periodic profile store end");
     138                } catch (Throwable t) {
     139                    _log.log(Log.CRIT, "Error storing profiles", t);
     140                }
     141            }
    120142            long uptime = _context.router().getUptime();
    121143            long delay;
     
    131153   
    132154    void storeProfiles() {
    133         Set<Hash> peers = selectPeers();
    134         for (Hash peer : peers) {
    135             storeProfile(peer);
     155        // lock in case shutdown bumps into periodic store
     156        if (!_storeLock.compareAndSet(false, true))
     157            return;
     158        try {
     159            Set<Hash> peers = selectPeers();
     160            for (Hash peer : peers) {
     161                storeProfile(peer);
     162            }
     163        } finally {
     164            _storeLock.set(false);
    136165        }
    137166    }
  • router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java

    r01cfb7b r11579b9  
    2525import net.i2p.router.RouterContext;
    2626import net.i2p.router.tunnel.pool.TunnelPeerSelector;
     27import net.i2p.router.util.MaskedIPSet;
    2728import net.i2p.router.util.RandomIterator;
    2829import net.i2p.stat.Rate;
     
    12461247    private void locked_selectPeers(Map<Hash, PeerProfile> peers, int howMany, Set<Hash> toExclude, Set<Hash> matches, int mask) {
    12471248        List<Hash> all = new ArrayList<Hash>(peers.keySet());
    1248         Set<String> IPSet = new HashSet<String>(8);
     1249        MaskedIPSet IPSet = new MaskedIPSet(8);
    12491250        // use RandomIterator to avoid shuffling the whole thing
    12501251        for (Iterator<Hash> iter = new RandomIterator<Hash>(all); (matches.size() < howMany) && iter.hasNext(); ) {
     
    12781279     * @param IPMatches all IPs so far, modified by this routine
    12791280     */
    1280     private boolean notRestricted(Hash peer, Set<String> IPSet, int mask) {
    1281         Set<String> peerIPs = maskedIPSet(peer, mask);
    1282         if (containsAny(IPSet, peerIPs))
     1281    private boolean notRestricted(Hash peer, MaskedIPSet IPSet, int mask) {
     1282        Set<String> peerIPs = new MaskedIPSet(_context, peer, mask);
     1283        if (IPSet.containsAny(peerIPs))
    12831284            return false;
    12841285        IPSet.addAll(peerIPs);
    12851286        return true;
    1286     }
    1287 
    1288     /**
    1289       * The Set of IPs for this peer, with a given mask.
    1290       * Includes the comm system's record of the IP, and all netDb addresses.
    1291       *
    1292       * As of 0.9.24, returned set will include netdb family as well.
    1293       *
    1294       * @return an opaque set of masked IPs for this peer
    1295       */
    1296     private Set<String> maskedIPSet(Hash peer, int mask) {
    1297         Set<String> rv = new HashSet<String>(4);
    1298         byte[] commIP = _context.commSystem().getIP(peer);
    1299         if (commIP != null)
    1300             rv.add(maskedIP(commIP, mask));
    1301         RouterInfo pinfo = _context.netDb().lookupRouterInfoLocally(peer);
    1302         if (pinfo == null)
    1303             return rv;
    1304         Collection<RouterAddress> paddr = pinfo.getAddresses();
    1305         for (RouterAddress pa : paddr) {
    1306             byte[] pib = pa.getIP();
    1307             if (pib == null) continue;
    1308             rv.add(maskedIP(pib, mask));
    1309         }
    1310         String family = pinfo.getOption("family");
    1311         if (family != null) {
    1312             // TODO should KNDF put a family-verified indicator in the RI,
    1313             // after checking the sig, or does it matter?
    1314             // What's the threat here of not avoid ding a router
    1315             // falsely claiming to be in the family?
    1316             // Prefix with something so an IP can't be spoofed
    1317             rv.add('x' + family);
    1318         }
    1319         return rv;
    1320     }
    1321 
    1322     /**
    1323      * generate an arbitrary unique value for this ip/mask (mask = 1-4)
    1324      * If IPv6, force mask = 6.
    1325      */
    1326     private static String maskedIP(byte[] ip, int mask) {
    1327         final StringBuilder buf = new StringBuilder(1 + (mask*2));
    1328         final char delim;
    1329         if (ip.length == 16) {
    1330             mask = 6;
    1331             delim = ':';
    1332         } else {
    1333             delim = '.';
    1334         }
    1335         buf.append(delim);
    1336         buf.append(Long.toHexString(DataHelper.fromLong(ip, 0, mask)));
    1337         return buf.toString();
    1338     }
    1339 
    1340     /** does a contain any of the elements in b? */
    1341     private static <T> boolean  containsAny(Set<T> a, Set<T> b) {
    1342         if (a.isEmpty() || b.isEmpty())
    1343             return false;
    1344         for (T o : b) {
    1345             if (a.contains(o))
    1346                 return true;
    1347         }
    1348         return false;
    13491287    }
    13501288
  • router/java/src/net/i2p/router/peermanager/ProfilePersistenceHelper.java

    r01cfb7b r11579b9  
    230230    }
    231231   
     232    /**
     233     *  Delete profile files with timestamps older than 'age' ago
     234     *  @since 0.9.28
     235     */
     236    public void deleteOldProfiles(long age) {
     237        long cutoff = System.currentTimeMillis() - age;
     238        List<File> files = selectFiles();
     239        int i = 0;
     240        for (File f :  files) {
     241            if (!f.isFile())
     242                continue;
     243            if (f.lastModified() < cutoff) {
     244                i++;
     245                f.delete();
     246            }
     247        }
     248        if (_log.shouldWarn())
     249            _log.warn("Deleted " + i + " old profiles");
     250    }
     251
    232252    private boolean isExpired(long lastSentToSuccessfully) {
    233253        long timeSince = _context.clock().now() - lastSentToSuccessfully;
  • router/java/src/net/i2p/router/tasks/OOMListener.java

    r01cfb7b r11579b9  
    5050            log.log(Log.CRIT, "free mem: " + Runtime.getRuntime().freeMemory() +
    5151                              " total mem: " + Runtime.getRuntime().totalMemory());
     52            // Can't find any System property or wrapper property that gives
     53            // you the actual config file path, have to guess
     54            String path;
     55            if (SystemVersion.isLinuxService()) {
     56                path = "/etc/i2p";
     57            } else {
     58                path = _context.getBaseDir().toString();
     59            }
    5260            if (_context.hasWrapper()) {
    53                 // Can't find any System property or wrapper property that gives
    54                 // you the actual config file path, have to guess
    55                 String path;
    56                 if (SystemVersion.isLinuxService()) {
    57                     path = "/etc/i2p";
    58                 } else {
    59                     path = _context.getBaseDir().toString();
    60                 }
    6161                log.log(Log.CRIT, "To prevent future shutdowns, increase wrapper.java.maxmemory in " +
     62                                  path + File.separatorChar + "wrapper.config");
     63            } else if (!SystemVersion.isWindows()) {
     64                log.log(Log.CRIT, "To prevent future shutdowns, increase MAXMEMOPT in " +
     65                                  path + File.separatorChar + "runplain.sh or /usr/bin/i2prouter-nowrapper");
     66            } else {
     67                log.log(Log.CRIT, "To prevent future shutdowns, run the restartable version of I2P, and increase wrapper.java.maxmemory in " +
    6268                                  path + File.separatorChar + "wrapper.config");
    6369            }
  • router/java/src/net/i2p/router/transport/TransportManager.java

    r01cfb7b r11579b9  
    1212import java.io.Writer;
    1313import java.net.InetAddress;
     14import java.net.Inet6Address;
    1415import java.net.UnknownHostException;
    1516import java.util.ArrayList;
     
    166167                int port = udp.getRequestedPort();
    167168                if (port > 0)
    168                     ntcp.externalAddressReceived(SOURCE_CONFIG, null, port);
     169                    ntcp.externalAddressReceived(SOURCE_CONFIG, (byte[]) null, port);
    169170            }
    170171        }
     
    183184    private void initializeAddress(Transport t) {
    184185        Set<String> ipset = Addresses.getAddresses(false, true);  // non-local, include IPv6
     186        //
     187        // Avoid IPv6 temporary addresses if we have a non-temporary one
     188        //
     189        boolean hasNonTempV6Address = false;
     190        List<InetAddress> addresses = new ArrayList<InetAddress>(4);
     191        List<Inet6Address> tempV6Addresses = new ArrayList<Inet6Address>(4);
    185192        for (String ips : ipset) {
    186193            try {
    187                 InetAddress ia = InetAddress.getByName(ips);
    188                 byte[] ip = ia.getAddress();
    189                 t.externalAddressReceived(SOURCE_INTERFACE, ip, 0);
     194                InetAddress addr = InetAddress.getByName(ips);
     195                if (ips.contains(":") && (addr instanceof Inet6Address)) {
     196                    Inet6Address v6addr = (Inet6Address) addr;
     197                    // getAddresses(false, true) will not return deprecated addresses
     198                    //if (Addresses.isDeprecated(v6addr)) {
     199                    //    if (_log.shouldWarn())
     200                    //        _log.warn("Not binding to deprecated temporary address " + bt);
     201                    //    continue;
     202                    //}
     203                    if (Addresses.isTemporary(v6addr)) {
     204                        // Save temporary addresses
     205                        // we only use these if we don't have a non-temporary adress
     206                        tempV6Addresses.add(v6addr);
     207                        continue;
     208                    }
     209                    hasNonTempV6Address = true;
     210                }
     211                addresses.add(addr);
    190212            } catch (UnknownHostException e) {
    191213                _log.error("UDP failed to bind to local address", e);
    192214            }
     215        }
     216        // we only use these if we don't have a non-temporary adress
     217        if (!tempV6Addresses.isEmpty()) {
     218            if (hasNonTempV6Address) {
     219                if (_log.shouldWarn()) {
     220                    for (Inet6Address addr : tempV6Addresses) {
     221                        _log.warn("Not binding to temporary address " + addr.getHostAddress());
     222                    }
     223                }
     224            } else {
     225                addresses.addAll(tempV6Addresses);
     226            }
     227        }
     228        for (InetAddress ia : addresses) {
     229            byte[] ip = ia.getAddress();
     230            t.externalAddressReceived(SOURCE_INTERFACE, ip, 0);
    193231        }
    194232    }
  • router/java/src/net/i2p/router/transport/TransportUtil.java

    r01cfb7b r11579b9  
    2626    public static final String SSU_IPV6_CONFIG = "i2np.udp.ipv6";
    2727    public static final String PROP_IPV4_FIREWALLED = "i2np.ipv4.firewalled";
     28    /** @since 0.9.28 */
     29    public static final String PROP_IPV6_FIREWALLED = "i2np.ipv6.firewalled";
    2830
    2931    public enum IPv6Config {
     
    100102     *
    101103     *  @param transportStyle ignored
    102      *  @since 0.9.27
     104     *  @since 0.9.27, implemented in 0.9.28
    103105     */
    104106    public static boolean isIPv6Firewalled(RouterContext ctx, String transportStyle) {
    105         // TODO
    106         //return ctx.getBooleanProperty(PROP_IPV6_FIREWALLED);
    107         return false;
     107        return ctx.getBooleanProperty(PROP_IPV6_FIREWALLED);
    108108    }
    109109
  • router/java/src/net/i2p/router/transport/UPnP.java

    r01cfb7b r11579b9  
    5959 * some code has been borrowed from Limewire : @see com.limegroup.gnutella.UPnPManager
    6060 *
     61 * Public only for command line usage. Not a public API, not for external use.
     62 *
    6163 * @see "http://www.upnp.org/"
    6264 * @see "http://en.wikipedia.org/wiki/Universal_Plug_and_Play"
     
    6971 * TODO: Implement EventListener and react on ip-change
    7072 */
    71 class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
     73public class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
    7274        private final Log _log;
    7375        private final I2PAppContext _context;
  • router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java

    r01cfb7b r11579b9  
    151151        _context.statManager().createRateStat("ntcp.inboundEstablished", "", "ntcp", RATES);
    152152        _context.statManager().createRateStat("ntcp.inboundEstablishedDuplicate", "", "ntcp", RATES);
     153        _context.statManager().createRateStat("ntcp.inboundIPv4Conn", "Inbound IPv4 NTCP Connection", "ntcp", RATES);
     154        _context.statManager().createRateStat("ntcp.inboundIPv6Conn", "Inbound IPv6 NTCP Connection", "ntcp", RATES);
    153155        //_context.statManager().createRateStat("ntcp.infoMessageEnqueued", "", "ntcp", RATES);
    154156        //_context.statManager().createRateStat("ntcp.floodInfoMessageEnqueued", "", "ntcp", RATES);
     
    214216            old = _conByIdent.put(peer, con);
    215217        }
    216         if (con.isIPv6())
     218        if (con.isIPv6()) {
    217219            _lastInboundIPv6 = con.getCreated();
    218         else
     220            _context.statManager().addRateData("ntcp.inboundIPv6Conn", 1);
     221        } else {
    219222            _lastInboundIPv4 = con.getCreated();
     223            _context.statManager().addRateData("ntcp.inboundIPv4Conn", 1);
     224        }
    220225        return old;
    221226    }
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    r01cfb7b r11579b9  
    290290        _context.statManager().createRateStat("udp.dropPeerDroplist", "How many peers currently have their packets dropped outright when a new peer is added to the list?", "udp", RATES);
    291291        _context.statManager().createRateStat("udp.dropPeerConsecutiveFailures", "How many consecutive failed sends to a peer did we attempt before giving up and reestablishing a new session (lifetime is inactivity perood)", "udp", RATES);
     292        _context.statManager().createRateStat("udp.inboundIPv4Conn", "Inbound IPv4 UDP Connection", "udp", RATES);
     293        _context.statManager().createRateStat("udp.inboundIPv6Conn", "Inbound IPv4 UDP Connection", "udp", RATES);
    292294        // following are for PacketBuider
    293295        //_context.statManager().createRateStat("udp.packetAuthTime", "How long it takes to encrypt and MAC a packet for sending", "udp", RATES);
     
    781783        if (isIPv6) {
    782784            _lastInboundIPv6 = _context.clock().now();
     785            _context.statManager().addRateData("udp.inboundIPv6Conn", 1);
    783786            // former workaround for lack of IPv6 peer testing
    784787            //if (_currentOurV6Address != null)
     
    789792            // use OS clock since its an ordering thing, not a time thing
    790793            _lastInboundReceivedOn = System.currentTimeMillis();
     794            _context.statManager().addRateData("udp.inboundIPv4Conn", 1);
    791795        }
    792796    }
     
    17661770            // never get any introducers)
    17671771            int count = _peersByIdent.size();
    1768             if (alwaysPreferUDP() || count < _min_peers ||
    1769                 (_haveIPv6Address && count < _min_v6_peers) ||
    1770                 (introducersRequired() && _introManager.introducerCount() < MIN_INTRODUCER_POOL))
     1772            if (alwaysPreferUDP()) {
    17711773                return _cachedBid[SLOW_PREFERRED_BID];
    1772             else if (preferUDP())
     1774            } else if (count < _min_peers ||
     1775                       (_haveIPv6Address && count < _min_v6_peers) ||
     1776                       (introducersRequired() && _introManager.introducerCount() < MIN_INTRODUCER_POOL)) {
     1777                 // Even if we haven't hit our minimums, give NTCP a chance some of the time.
     1778                 // This may make things work a little faster at startup
     1779                 // (especially when we have an IPv6 address and the increased minimums),
     1780                 // and if UDP is completely blocked we'll still have some connectivity.
     1781                 // TODO After some time, decide that UDP is blocked/broken and return TRANSIENT_FAIL_BID?
     1782                if (_context.random().nextInt(4) == 0)
     1783                    return _cachedBid[SLOWEST_BID];
     1784                else
     1785                    return _cachedBid[SLOW_PREFERRED_BID];
     1786            } else if (preferUDP()) {
    17731787                return _cachedBid[SLOW_BID];
    1774             else if (haveCapacity()) {
     1788            } else if (haveCapacity()) {
    17751789                if (addr.getCost() > DEFAULT_COST)
    17761790                    return _cachedBid[SLOWEST_COST_BID];
  • router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java

    r01cfb7b r11579b9  
    105105        // Can't find any System property or wrapper property that gives
    106106        // you the actual config file path, have to guess
    107         // TODO if !SystemVersion.hasWrapper ...
    108107        String path;
    109108        if (SystemVersion.isLinuxService()) {
     
    115114            "Configured for " + DataHelper.formatSize(KBps *1024L) +
    116115            "Bps share bandwidth but only " +
    117             DataHelper.formatSize(maxMemory) + "B available memory." +
    118             " Recommend increasing wrapper.java.maxmemory in " +
    119             path + File.separatorChar + "wrapper.config" +
    120             // getMaxMemory() returns significantly lower than wrapper config, so add 10%
    121             " to at least " + (recMaxMem * 11 / 10 / (1024*1024)) + " (MB)" +
    122             " if the actual share bandwidth exceeds " +
    123             DataHelper.formatSize(threshKBps * 1024L) + "Bps.";
     116            DataHelper.formatSize(maxMemory) + "B available memory.";
     117        if (_context.hasWrapper()) {
     118            msg += " Recommend increasing wrapper.java.maxmemory in " +
     119                   path + File.separatorChar + "wrapper.config";
     120        } else if (!SystemVersion.isWindows()) {
     121            msg += " Recommend increasing MAXMEMOPT in " +
     122                   path + File.separatorChar + "runplain.sh or /usr/bin/i2prouter-nowrapper";
     123        } else {
     124            msg += " Recommend running the restartable version of I2P, and increasing wrapper.java.maxmemory in " +
     125                   path + File.separatorChar + "wrapper.config";
     126        }
     127        // getMaxMemory() returns significantly lower than wrapper config, so add 10%
     128        msg += " to at least " + (recMaxMem * 11 / 10 / (1024*1024)) + " (MB)" +
     129               " if the actual share bandwidth exceeds " +
     130               DataHelper.formatSize(threshKBps * 1024L) + "Bps.";
    124131        System.out.println("WARN: " + msg);
    125132        _context.logManager().getLog(BloomFilterIVValidator.class).logAlways(Log.WARN, msg);
  • router/java/src/net/i2p/router/tunnel/pool/BuildRequestor.java

    r01cfb7b r11579b9  
    2626abstract class BuildRequestor {
    2727    private static final List<Integer> ORDER = new ArrayList<Integer>(TunnelBuildMessage.MAX_RECORD_COUNT);
     28    private static final String MIN_VARIABLE_VERSION = "0.7.12";
     29    private static final boolean SEND_VARIABLE = true;
     30    private static final int SHORT_RECORDS = 4;
     31    private static final List<Integer> SHORT_ORDER = new ArrayList<Integer>(SHORT_RECORDS);
     32    /** 5 (~2600 bytes) fits nicely in 3 tunnel messages */
     33    private static final int MEDIUM_RECORDS = 5;
     34    private static final List<Integer> MEDIUM_ORDER = new ArrayList<Integer>(MEDIUM_RECORDS);
    2835    static {
    29         for (int i = 0; i < TunnelBuildMessage.MAX_RECORD_COUNT; i++)
     36        for (int i = 0; i < TunnelBuildMessage.MAX_RECORD_COUNT; i++) {
    3037            ORDER.add(Integer.valueOf(i));
     38        }
     39        for (int i = 0; i < SHORT_RECORDS; i++) {
     40            SHORT_ORDER.add(Integer.valueOf(i));
     41        }
     42        for (int i = 0; i < MEDIUM_RECORDS; i++) {
     43            MEDIUM_ORDER.add(Integer.valueOf(i));
     44        }
    3145    }
    3246
     
    224238        return true;
    225239    }
    226    
    227     private static final String MIN_VARIABLE_VERSION = "0.7.12";
    228     /** change this to true in 0.7.13 if testing goes well */
    229     private static final boolean SEND_VARIABLE = true;
    230     /** 5 (~2600 bytes) fits nicely in 3 tunnel messages */
    231     private static final int SHORT_RECORDS = 5;
    232     private static final List<Integer> SHORT_ORDER = new ArrayList<Integer>(SHORT_RECORDS);
    233     static {
    234         for (int i = 0; i < SHORT_RECORDS; i++)
    235             SHORT_ORDER.add(Integer.valueOf(i));
    236     }
    237240
    238241    /** @since 0.7.12 */
     
    257260        long replyTunnel = 0;
    258261        Hash replyRouter = null;
    259         boolean useVariable = SEND_VARIABLE && cfg.getLength() <= SHORT_RECORDS;
     262        boolean useVariable = SEND_VARIABLE && cfg.getLength() <= MEDIUM_RECORDS;
    260263        if (cfg.isInbound()) {
    261264            //replyTunnel = 0; // as above
     
    296299        List<Integer> order;
    297300        if (useVariable) {
    298             msg = new VariableTunnelBuildMessage(ctx, SHORT_RECORDS);
    299             order = new ArrayList<Integer>(SHORT_ORDER);
    300             //if (log.shouldLog(Log.INFO))
    301             //    log.info("Using new VTBM");
     301            if (cfg.getLength() <= SHORT_RECORDS) {
     302                msg = new VariableTunnelBuildMessage(ctx, SHORT_RECORDS);
     303                order = new ArrayList<Integer>(SHORT_ORDER);
     304            } else {
     305                msg = new VariableTunnelBuildMessage(ctx, MEDIUM_RECORDS);
     306                order = new ArrayList<Integer>(MEDIUM_ORDER);
     307            }
    302308        } else {
    303309            msg = new TunnelBuildMessage(ctx);
  • router/java/src/org/cybergarage/http/HTTPHeader.java

    r01cfb7b r11579b9  
    117117        public final static String getValue(String data, String name)
    118118        {
     119                // I2P #1480 avoid IAE
     120                if (data.length() <= 0)
     121                        return "";
    119122                /* Thanks for Stephan Mehlhase (2010-10-26) */
    120123                StringReader strReader = new StringReader(data);
  • router/java/src/org/cybergarage/upnp/ssdp/HTTPUSocket.java

    r01cfb7b r11579b9  
    9393                if (0 < localAddr.length())
    9494                        return localAddr;
     95                // I2P prevent NPE #1681
     96                if (ssdpUniSock == null)
     97                        return "";
    9598                return ssdpUniSock.getLocalAddress().getHostAddress();
    9699        }
Note: See TracChangeset for help on using the changeset viewer.