Changeset f8ea882


Ignore:
Timestamp:
Apr 14, 2017 1:34:33 PM (3 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
75db7fa
Parents:
dd0153e2
Message:

SSU: Reuse previous introducer expiration if available,
so we don't force a republish

  • Don't run peer test if configured to force firewalled
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    rdd0153e2 rf8ea882  
     12017-04-14 zzz
     2 * SSU:
     3   - Reuse previous introducer expiration if available,
     4     so we don't force a republish
     5   - Don't run peer test if configured to force firewalled
     6
    172017-04-13 zzz
    28 * SSU: Publish introducer expiration (proposal 133)
  • router/java/src/net/i2p/router/RouterVersion.java

    rdd0153e2 rf8ea882  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 16;
     21    public final static long BUILD = 17;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/transport/udp/IntroductionManager.java

    rdd0153e2 rf8ea882  
    168168     * and we want to keep our introducers valid.
    169169     *
     170     * @param current current router address, may be null
    170171     * @param ssuOptions out parameter, options are added
    171172     * @return number of introducers added
    172173     */
    173     public int pickInbound(Properties ssuOptions, int howMany) {
     174    public int pickInbound(RouterAddress current, Properties ssuOptions, int howMany) {
    174175        int start = _context.random().nextInt();
    175176        if (_log.shouldLog(Log.DEBUG))
     
    245246            ssuOptions.setProperty(UDPAddress.PROP_INTRO_KEY_PREFIX + i, in.skey);
    246247            ssuOptions.setProperty(UDPAddress.PROP_INTRO_TAG_PREFIX + i, in.stag);
    247             ssuOptions.setProperty(UDPAddress.PROP_INTRO_EXP_PREFIX + i, exp);
     248            String sexp = exp;
     249            // look for existing expiration in current published
     250            // and reuse if still recent enough, so deepEquals() won't fail in UDPT.rEA
     251            if (current != null) {
     252                for (int j = 0; j < UDPTransport.PUBLIC_RELAY_COUNT; j++) {
     253                    if (in.sip.equals(current.getOption(UDPAddress.PROP_INTRO_HOST_PREFIX + j)) &&
     254                        in.sport.equals(current.getOption(UDPAddress.PROP_INTRO_PORT_PREFIX + j)) &&
     255                        in.skey.equals(current.getOption(UDPAddress.PROP_INTRO_KEY_PREFIX + j)) &&
     256                        in.stag.equals(current.getOption(UDPAddress.PROP_INTRO_TAG_PREFIX + j))) {
     257                        // found old one
     258                        String oexp = current.getOption(UDPAddress.PROP_INTRO_EXP_PREFIX + j);
     259                        if (oexp != null) {
     260                            try {
     261                                long oex = Long.parseLong(oexp) * 1000;
     262                                if (oex > now + UDPTransport.INTRODUCER_EXPIRATION_MARGIN) {
     263                                    // still good, use old expiration time
     264                                    sexp = oexp;
     265                                }
     266                            } catch (NumberFormatException nfe) {}
     267                        }
     268                        break;
     269                    }
     270                }
     271            }
     272            ssuOptions.setProperty(UDPAddress.PROP_INTRO_EXP_PREFIX + i, sexp);
    248273        }
    249274
  • router/java/src/net/i2p/router/transport/udp/PeerTestEvent.java

    rdd0153e2 rf8ea882  
    4040       
    4141    public synchronized void timeReached() {
    42         // just for IPv6 for now
    4342        if (shouldTest()) {
    4443            long now = _context.clock().now();
    4544            long sinceRunV4 = now - _lastTested.get();
    4645            long sinceRunV6 = now - _lastTestedV6.get();
    47             if (_forceRun == FORCE_IPV4 && sinceRunV4 >= MIN_TEST_FREQUENCY) {
     46            boolean configV4fw = _transport.isIPv4Firewalled();
     47            boolean configV6fw = _transport.isIPv6Firewalled();
     48            if (!configV4fw && _forceRun == FORCE_IPV4 && sinceRunV4 >= MIN_TEST_FREQUENCY) {
    4849                locked_runTest(false);
    49             } else if (_transport.hasIPv6Address() &&_forceRun == FORCE_IPV6 && sinceRunV6 >= MIN_TEST_FREQUENCY) {
     50            } else if (!configV6fw && _transport.hasIPv6Address() &&_forceRun == FORCE_IPV6 && sinceRunV6 >= MIN_TEST_FREQUENCY) {
    5051                locked_runTest(true);
    51             } else if (sinceRunV4 >= TEST_FREQUENCY && _transport.getIPv6Config() != IPV6_ONLY) {
     52            } else if (!configV4fw && sinceRunV4 >= TEST_FREQUENCY && _transport.getIPv6Config() != IPV6_ONLY) {
    5253                locked_runTest(false);
    53             } else if (_transport.hasIPv6Address() && sinceRunV6 >= TEST_FREQUENCY) {
     54            } else if (!configV6fw && _transport.hasIPv6Address() && sinceRunV6 >= TEST_FREQUENCY) {
    5455                locked_runTest(true);
    5556            } else {
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    rdd0153e2 rf8ea882  
    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;
     206    static final long INTRODUCER_EXPIRATION_MARGIN = 20*60*1000L;
    207207   
    208208    private static final int[] BID_VALUES = { 15, 20, 50, 65, 80, 95, 100, 115, TransportBid.TRANSIENT_FAIL };
     
    21312131            // deepEquals() below will not fail even with same introducers.
    21322132            // Was only a problem when we had very very few peers to pick from.
    2133             int found = _introManager.pickInbound(options, PUBLIC_RELAY_COUNT);
     2133            RouterAddress current = getCurrentAddress(isIPv6);
     2134            int found = _introManager.pickInbound(current, options, PUBLIC_RELAY_COUNT);
    21342135            if (found > 0) {
    21352136                if (_log.shouldLog(Log.INFO))
Note: See TracChangeset for help on using the changeset viewer.