Changeset 13ad5d7 for router


Ignore:
Timestamp:
Mar 20, 2017 10:31:32 PM (3 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
a00f11d
Parents:
b9a7a76
Message:

SSU: More work on introducer expiration (proposal 133)

Location:
router/java/src/net/i2p/router/transport/udp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/transport/udp/PacketBuilder.java

    rb9a7a76 r13ad5d7  
    12161216        int count = addr.getIntroducerCount();
    12171217        List<UDPPacket> rv = new ArrayList<UDPPacket>(count);
     1218        long cutoff = _context.clock().now() + 5*60*1000L;
    12181219        for (int i = 0; i < count; i++) {
    12191220            InetAddress iaddr = addr.getIntroducerHost(i);
     
    12211222            byte ikey[] = addr.getIntroducerKey(i);
    12221223            long tag = addr.getIntroducerTag(i);
     1224            long exp = addr.getIntroducerExpiration(i);
    12231225            // let's not use an introducer on a privileged port, sounds like trouble
    12241226            if (ikey == null || !TransportUtil.isValidPort(iport) ||
     
    12271229                iaddr.getAddress().length != 4 ||
    12281230                (!_transport.isValid(iaddr.getAddress())) ||
     1231                (exp > 0 && exp < cutoff) ||
    12291232                (Arrays.equals(iaddr.getAddress(), _transport.getExternalIP()) && !_transport.allowLocal())) {
    12301233                if (_log.shouldLog(Log.WARN))
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    rb9a7a76 r13ad5d7  
    204204    /** minimum peers volunteering to be introducers if we need that */
    205205    private static final int MIN_INTRODUCER_POOL = 5;
     206    private static final long INTRODUCER_EXPIRATION_MARGIN = 20*60*1000L;
    206207   
    207208    private static final int[] BID_VALUES = { 15, 20, 50, 65, 80, 95, 100, 115, TransportBid.TRANSIENT_FAIL };
     
    15591560        if (introducersRequired()) {
    15601561            UDPAddress ua = new UDPAddress(addr);
     1562            long now = _context.clock().now();
    15611563            int valid = 0;
    15621564            for (int i = 0; i < ua.getIntroducerCount(); i++) {
     
    15651567                if (key.length != Hash.HASH_LENGTH)
    15661568                    continue;
     1569                long exp = ua.getIntroducerExpiration(i);
     1570                if (exp > 0 && exp < now + INTRODUCER_EXPIRATION_MARGIN)
     1571                    continue;
    15671572                PeerState peer = getPeerState(new Hash(key));
    15681573                if (peer != null)
    15691574                    valid++;
    15701575            }
    1571             long sinceSelected = _context.clock().now() - _introducersSelectedOn;
     1576            long sinceSelected = now - _introducersSelectedOn;
    15721577            if (valid >= PUBLIC_RELAY_COUNT) {
    15731578                // try to shift 'em around every 10 minutes or so
Note: See TracChangeset for help on using the changeset viewer.