forked from I2P_Developers/i2p.i2p
SSU: Reuse previous introducer expiration if available,
so we don't force a republish - Don't run peer test if configured to force firewalled
This commit is contained in:
@ -1,3 +1,9 @@
|
||||
2017-04-14 zzz
|
||||
* SSU:
|
||||
- Reuse previous introducer expiration if available,
|
||||
so we don't force a republish
|
||||
- Don't run peer test if configured to force firewalled
|
||||
|
||||
2017-04-13 zzz
|
||||
* SSU: Publish introducer expiration (proposal 133)
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
||||
/** deprecated */
|
||||
public final static String ID = "Monotone";
|
||||
public final static String VERSION = CoreVersion.VERSION;
|
||||
public final static long BUILD = 16;
|
||||
public final static long BUILD = 17;
|
||||
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "-rc";
|
||||
|
@ -167,10 +167,11 @@ class IntroductionManager {
|
||||
* to keep the connection up, since the netDb can have quite stale information,
|
||||
* and we want to keep our introducers valid.
|
||||
*
|
||||
* @param current current router address, may be null
|
||||
* @param ssuOptions out parameter, options are added
|
||||
* @return number of introducers added
|
||||
*/
|
||||
public int pickInbound(Properties ssuOptions, int howMany) {
|
||||
public int pickInbound(RouterAddress current, Properties ssuOptions, int howMany) {
|
||||
int start = _context.random().nextInt();
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Picking inbound out of " + _inbound.size());
|
||||
@ -244,7 +245,31 @@ class IntroductionManager {
|
||||
ssuOptions.setProperty(UDPAddress.PROP_INTRO_PORT_PREFIX + i, in.sport);
|
||||
ssuOptions.setProperty(UDPAddress.PROP_INTRO_KEY_PREFIX + i, in.skey);
|
||||
ssuOptions.setProperty(UDPAddress.PROP_INTRO_TAG_PREFIX + i, in.stag);
|
||||
ssuOptions.setProperty(UDPAddress.PROP_INTRO_EXP_PREFIX + i, exp);
|
||||
String sexp = exp;
|
||||
// look for existing expiration in current published
|
||||
// and reuse if still recent enough, so deepEquals() won't fail in UDPT.rEA
|
||||
if (current != null) {
|
||||
for (int j = 0; j < UDPTransport.PUBLIC_RELAY_COUNT; j++) {
|
||||
if (in.sip.equals(current.getOption(UDPAddress.PROP_INTRO_HOST_PREFIX + j)) &&
|
||||
in.sport.equals(current.getOption(UDPAddress.PROP_INTRO_PORT_PREFIX + j)) &&
|
||||
in.skey.equals(current.getOption(UDPAddress.PROP_INTRO_KEY_PREFIX + j)) &&
|
||||
in.stag.equals(current.getOption(UDPAddress.PROP_INTRO_TAG_PREFIX + j))) {
|
||||
// found old one
|
||||
String oexp = current.getOption(UDPAddress.PROP_INTRO_EXP_PREFIX + j);
|
||||
if (oexp != null) {
|
||||
try {
|
||||
long oex = Long.parseLong(oexp) * 1000;
|
||||
if (oex > now + UDPTransport.INTRODUCER_EXPIRATION_MARGIN) {
|
||||
// still good, use old expiration time
|
||||
sexp = oexp;
|
||||
}
|
||||
} catch (NumberFormatException nfe) {}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ssuOptions.setProperty(UDPAddress.PROP_INTRO_EXP_PREFIX + i, sexp);
|
||||
}
|
||||
|
||||
// FIXME failsafe if found == 0, relax inactivityCutoff and try again?
|
||||
|
@ -39,18 +39,19 @@ class PeerTestEvent extends SimpleTimer2.TimedEvent {
|
||||
}
|
||||
|
||||
public synchronized void timeReached() {
|
||||
// just for IPv6 for now
|
||||
if (shouldTest()) {
|
||||
long now = _context.clock().now();
|
||||
long sinceRunV4 = now - _lastTested.get();
|
||||
long sinceRunV6 = now - _lastTestedV6.get();
|
||||
if (_forceRun == FORCE_IPV4 && sinceRunV4 >= MIN_TEST_FREQUENCY) {
|
||||
boolean configV4fw = _transport.isIPv4Firewalled();
|
||||
boolean configV6fw = _transport.isIPv6Firewalled();
|
||||
if (!configV4fw && _forceRun == FORCE_IPV4 && sinceRunV4 >= MIN_TEST_FREQUENCY) {
|
||||
locked_runTest(false);
|
||||
} else if (_transport.hasIPv6Address() &&_forceRun == FORCE_IPV6 && sinceRunV6 >= MIN_TEST_FREQUENCY) {
|
||||
} else if (!configV6fw && _transport.hasIPv6Address() &&_forceRun == FORCE_IPV6 && sinceRunV6 >= MIN_TEST_FREQUENCY) {
|
||||
locked_runTest(true);
|
||||
} else if (sinceRunV4 >= TEST_FREQUENCY && _transport.getIPv6Config() != IPV6_ONLY) {
|
||||
} else if (!configV4fw && sinceRunV4 >= TEST_FREQUENCY && _transport.getIPv6Config() != IPV6_ONLY) {
|
||||
locked_runTest(false);
|
||||
} else if (_transport.hasIPv6Address() && sinceRunV6 >= TEST_FREQUENCY) {
|
||||
} else if (!configV6fw && _transport.hasIPv6Address() && sinceRunV6 >= TEST_FREQUENCY) {
|
||||
locked_runTest(true);
|
||||
} else {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
|
@ -203,7 +203,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
private static final int MIN_PEERS_IF_HAVE_V6 = 30;
|
||||
/** minimum peers volunteering to be introducers if we need that */
|
||||
private static final int MIN_INTRODUCER_POOL = 5;
|
||||
private static final long INTRODUCER_EXPIRATION_MARGIN = 20*60*1000L;
|
||||
static final long INTRODUCER_EXPIRATION_MARGIN = 20*60*1000L;
|
||||
|
||||
private static final int[] BID_VALUES = { 15, 20, 50, 65, 80, 95, 100, 115, TransportBid.TRANSIENT_FAIL };
|
||||
private static final int FAST_PREFERRED_BID = 0;
|
||||
@ -2130,7 +2130,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
// intro manager now sorts introducers, so
|
||||
// deepEquals() below will not fail even with same introducers.
|
||||
// Was only a problem when we had very very few peers to pick from.
|
||||
int found = _introManager.pickInbound(options, PUBLIC_RELAY_COUNT);
|
||||
RouterAddress current = getCurrentAddress(isIPv6);
|
||||
int found = _introManager.pickInbound(current, options, PUBLIC_RELAY_COUNT);
|
||||
if (found > 0) {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Direct? " + directIncluded + " reqd? " + introducersRequired +
|
||||
|
Reference in New Issue
Block a user