Changeset 19faa35


Ignore:
Timestamp:
Jul 25, 2013 6:52:45 PM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
b2d72f9
Parents:
ffda7f63
Message:
  • Transports:
    • Prefer IPv6 by default
    • Fix IPv6-only option
    • Don't try NTCP IPv6 addresses unless we have one
    • Fix non-%16 SSU padding in data and session confirmed packets; enable by default
    • Log tweaks
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    rffda7f63 r19faa35  
     12012-07-25 zzz
     2 * Transports:
     3   - Prefer IPv6 by default
     4   - Fix IPv6-only option
     5   - Don't try NTCP IPv6 addresses unless we have one
     6   - Fix non-%16 SSU padding; enable by default
     7 * Tunnels:
     8   - Make expl. default 3 hops  (ticket #966)
     9   - Allow expl. fallback up to -2 hops
     10
    1112012-07-24 zzz
    212 * GeoIP: Fix lookups, broken in IPv6 branch
  • router/java/src/net/i2p/router/RouterVersion.java

    rffda7f63 r19faa35  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 10;
     21    public final static long BUILD = 11;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/transport/TransportImpl.java

    rffda7f63 r19faa35  
    244244            msg.transportFailed(getStyle());
    245245
    246         if (msToSend > 1000) {
    247             if (_log.shouldLog(Log.WARN))
     246        if (msToSend > 1500) {
     247            if (_log.shouldLog(Log.INFO))
    248248                _log.warn(getStyle() + " afterSend slow: " + (sendSuccessful ? "success " : "FAIL ")
    249249                          + msg.getMessageSize() + " byte "
     
    578578    protected List<RouterAddress> getTargetAddresses(RouterInfo target) {
    579579        List<RouterAddress> rv = target.getTargetAddresses(getStyle());
     580        if (rv.isEmpty())
     581            return rv;
    580582        // Shuffle so everybody doesn't use the first one
    581         if (rv.size() > 1) {
     583        if (rv.size() > 1)
    582584            Collections.shuffle(rv, _context.random());
    583             TransportUtil.IPv6Config config = getIPv6Config();
    584             int adj;
    585             switch (config) {
     585        TransportUtil.IPv6Config config = getIPv6Config();
     586        int adj;
     587        switch (config) {
    586588              case IPV6_DISABLED:
    587                 adj = 10; break;
     589                adj = 10;
     590              /**** IPv6 addresses will be rejected in isPubliclyRoutable()
     591                for (Iterator<RouterAddress> iter = rv.iterator(); iter.hasNext(); ) {
     592                    byte[] ip = iter.next().getIP();
     593                    if (ip != null && ip.length == 16)
     594                        iter.remove();
     595                }
     596               ****/
     597                break;
    588598              case IPV6_NOT_PREFERRED:
    589599                adj = 1; break;
     
    594604                adj = -1; break;
    595605              case IPV6_ONLY:
    596                 adj = -10; break;
    597             }
     606                adj = -10;
     607                // IPv4 addresses not rejected in isPubliclyRoutable()
     608                for (Iterator<RouterAddress> iter = rv.iterator(); iter.hasNext(); ) {
     609                    byte[] ip = iter.next().getIP();
     610                    if (ip != null && ip.length == 4)
     611                        iter.remove();
     612                }
     613                break;
     614        }
     615        if (rv.size() > 1)
    598616            Collections.sort(rv, new AddrComparator(adj));
    599         }
    600617        return rv;
    601618    }
  • router/java/src/net/i2p/router/transport/TransportUtil.java

    rffda7f63 r19faa35  
    5353
    5454    private static final Map<String, IPv6Config> BY_NAME = new HashMap<String, IPv6Config>();
    55     public static final IPv6Config DEFAULT_IPV6_CONFIG = IPv6Config.IPV6_DISABLED;
     55    public static final IPv6Config DEFAULT_IPV6_CONFIG = IPv6Config.IPV6_PREFERRED;
    5656
    5757    static {
     
    6161        // alias
    6262        BY_NAME.put("true", IPv6Config.IPV6_ENABLED);
     63        BY_NAME.put("disable", IPv6Config.IPV6_DISABLED);
    6364    }
    6465
  • router/java/src/net/i2p/router/transport/ntcp/EventPumper.java

    rffda7f63 r19faa35  
    2626import net.i2p.router.RouterContext;
    2727import net.i2p.router.transport.FIFOBandwidthLimiter;
     28import net.i2p.util.Addresses;
    2829import net.i2p.util.ConcurrentHashSet;
    2930import net.i2p.util.I2PThread;
     
    782783                key.attach(con);
    783784                con.setKey(key);
     785                RouterAddress naddr = con.getRemoteAddress();
    784786                try {
    785                     RouterAddress naddr = con.getRemoteAddress();
    786787                    if (naddr.getPort() <= 0)
    787788                        throw new IOException("Invalid NTCP address: " + naddr);
     
    795796                    }
    796797                } catch (IOException ioe) {
    797                     if (_log.shouldLog(Log.WARN)) _log.warn("error connecting", ioe);
     798                    if (_log.shouldLog(Log.WARN))
     799                        _log.warn("error connecting to " + Addresses.toString(naddr.getIP(), naddr.getPort()), ioe);
    798800                    _context.statManager().addRateData("ntcp.connectFailedIOE", 1);
    799801                    _transport.markUnreachable(con.getRemotePeer().calculateHash());
  • router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java

    rffda7f63 r19faa35  
    7272     */
    7373    private final Set<NTCPConnection> _establishing;
     74
     75    /**
     76     *  Do we have a public IPv6 address?
     77     *  TODO periodically update via CSFI.NetMonitor?
     78     */
     79    private boolean _haveIPv6Address;
    7480
    7581    public final static String PROP_I2NP_NTCP_HOSTNAME = "i2np.ntcp.hostname";
     
    365371                continue;
    366372            }
    367             if (!isPubliclyRoutable(ip)) {
     373            if (!isValid(ip)) {
    368374                if (! _context.getBooleanProperty("i2np.ntcp.allowLocal")) {
    369375                    //_context.statManager().addRateData("ntcp.bidRejectedLocalAddress", 1);
     
    376382        }
    377383        return null;
     384    }
     385   
     386    /**
     387     * An IPv6 address is only valid if we are configured to support IPv6
     388     * AND we have a public IPv6 address.
     389     *
     390     * @param addr may be null, returns false
     391     * @since 0.9.8
     392     */
     393    private boolean isValid(byte addr[]) {
     394        if (addr == null) return false;
     395        if (isPubliclyRoutable(addr) &&
     396            (addr.length != 16 || _haveIPv6Address))
     397            return true;
     398        return false;
    378399    }
    379400
     
    810831        if (_log.shouldLog(Log.WARN))
    811832            _log.warn("Received address: " + Addresses.toString(ip, port) + " from: " + source);
    812         if (ip != null && !isPubliclyRoutable(ip)) {
     833        if ((source == SOURCE_INTERFACE || source == SOURCE_SSU)
     834             && ip != null && ip.length == 16) {
     835            // must be set before isValid() call
     836            _haveIPv6Address = true;
     837        }
     838        if (ip != null && !isValid(ip)) {
    813839            if (_log.shouldLog(Log.WARN))
    814840                _log.warn("Invalid address: " + Addresses.toString(ip, port) + " from: " + source);
  • router/java/src/net/i2p/router/transport/udp/PacketBuilder.java

    rffda7f63 r19faa35  
    162162
    163163    private static final String PROP_PADDING = "i2np.udp.padding";
     164    private static final boolean DEFAULT_ENABLE_PADDING = true;
    164165
    165166    /**
     
    409410        // pad up so we're on the encryption boundary
    410411        off = pad1(data, off);
    411         off = pad2(data, off, currentMTU);
     412        off = pad2(data, off, currentMTU - (ipHeaderSize + UDP_HEADER_SIZE));
    412413        pkt.setLength(off);
    413414
     
    783784                off += paddingRequired;
    784785            }
     786            // We cannot have non-mod16 (pad2) padding here, since the signature
     787            // is at the end. As of 0.9.7 we won't decrypt past the end of the packet
     788            // so trailing non-mod-16 data is ignored. That truncates the sig.
    785789           
    786790            // BUG: NPE here if null signature
     
    793797            // pad up so we're on the encryption boundary
    794798            off = pad1(data, off);
     799            // allowed but untested
     800            //off = pad2(data, off);
    795801        }
    796         off = pad2(data, off);
    797802        pkt.setLength(off);
    798803        authenticate(packet, state.getCipherKey(), state.getMACKey());
     
    13521357     */
    13531358    private int pad2(byte[] data, int off) {
    1354         if (!_context.getBooleanProperty(PROP_PADDING))
     1359        if (!_context.getProperty(PROP_PADDING, DEFAULT_ENABLE_PADDING))
    13551360            return off;
    13561361        int padSize = _context.random().nextInt(MAX_PAD2);
     
    13711376     */
    13721377    private int pad2(byte[] data, int off, int maxLen) {
    1373         if (!_context.getBooleanProperty(PROP_PADDING))
     1378        if (!_context.getProperty(PROP_PADDING, DEFAULT_ENABLE_PADDING))
    13741379            return off;
    13751380        if (off >= maxLen)
Note: See TracChangeset for help on using the changeset viewer.