SSU: Publish introducer expiration (proposal 133)

This commit is contained in:
zzz
2017-04-13 15:58:52 +00:00
parent 9dd146680d
commit dd0153e29a
3 changed files with 16 additions and 3 deletions

View File

@ -1,3 +1,12 @@
2017-04-13 zzz
* SSU: Publish introducer expiration (proposal 133)
2017-04-06 zzz
* Debian: Add bash-completion scripts
2017-04-04 zzz
* Router: Fix config dir location in Gentoo
2017-04-02 zzz
* Context: Fix ClientAppManagerImpl in AppContext
* i2psnark: Fix standalone configuration for Jetty 9

View File

@ -18,10 +18,10 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 15;
public final static long BUILD = 16;
/** for example "-test" */
public final static String EXTRA = "";
public final static String EXTRA = "-rc";
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
public static void main(String args[]) {
System.out.println("I2P Router version: " + FULL_VERSION);

View File

@ -99,6 +99,7 @@ class IntroductionManager {
private static final long PUNCH_CLEAN_TIME = 5*1000;
/** Max for all targets per PUNCH_CLEAN_TIME */
private static final int MAX_PUNCHES = 8;
private static final long INTRODUCER_EXPIRATION = 80*60*1000L;
public IntroductionManager(RouterContext ctx, UDPTransport transport) {
_context = ctx;
@ -178,7 +179,8 @@ class IntroductionManager {
int sz = peers.size();
start = start % sz;
int found = 0;
long inactivityCutoff = _context.clock().now() - (UDPTransport.EXPIRE_TIMEOUT / 2); // 15 min
long now = _context.clock().now();
long inactivityCutoff = now - (UDPTransport.EXPIRE_TIMEOUT / 2); // 15 min
// if not too many to choose from, be less picky
if (sz <= howMany + 2)
inactivityCutoff -= UDPTransport.EXPIRE_TIMEOUT / 4;
@ -235,12 +237,14 @@ class IntroductionManager {
// we sort them so a change in order only won't happen, and won't cause a republish
Collections.sort(introducers);
String exp = Long.toString((now + INTRODUCER_EXPIRATION) / 1000);
for (int i = 0; i < found; i++) {
Introducer in = introducers.get(i);
ssuOptions.setProperty(UDPAddress.PROP_INTRO_HOST_PREFIX + i, in.sip);
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);
}
// FIXME failsafe if found == 0, relax inactivityCutoff and try again?