diff --git a/history.txt b/history.txt index 295d634d2..13311893f 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,11 @@ +2012-02-22 zzz + * ExploratoryPeerSelector: Use fast peers if hidden for + inbound tunnels to improve success + * NetDB: + - Don't publish our RI if it has no addresses + - Publish our RI sooner after startup + to facilitate our IB tunnel builds + 2012-02-20 zzz * i2ptunnel: - Fix streamr session registration diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 098e16d49..14408f1ed 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -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 = 17; + public final static long BUILD = 18; /** for example "-test" */ public final static String EXTRA = "-rc"; diff --git a/router/java/src/net/i2p/router/networkdb/PublishLocalRouterInfoJob.java b/router/java/src/net/i2p/router/networkdb/PublishLocalRouterInfoJob.java index cfcdd8a34..f0f9e89ab 100644 --- a/router/java/src/net/i2p/router/networkdb/PublishLocalRouterInfoJob.java +++ b/router/java/src/net/i2p/router/networkdb/PublishLocalRouterInfoJob.java @@ -20,15 +20,21 @@ import net.i2p.router.RouterContext; import net.i2p.util.Log; /** - * Publish the local router's RouterInfo periodically - * NOTE - this also creates and signs the RI + * Publish the local router's RouterInfo periodically. + * NOTE - this also creates and signs the RI. + * This is run immediately at startup... but doesn't really + * send to the floodfills until the second time it runs. */ public class PublishLocalRouterInfoJob extends JobImpl { private Log _log; final static long PUBLISH_DELAY = 20*60*1000; /** this needs to be long enough to give us time to start up, - but less than 20m (when we start accepting tunnels and could be a IBGW) */ - final static long FIRST_TIME_DELAY = 8*60*1000; + but less than 20m (when we start accepting tunnels and could be a IBGW) + Actually no, we need this soon if we are a new router or + other routers have forgotten about us, else + we can't build IB exploratory tunnels. + */ + final static long FIRST_TIME_DELAY = 90*1000; boolean _notFirstTime; public PublishLocalRouterInfoJob(RouterContext ctx) { @@ -63,6 +69,7 @@ public class PublishLocalRouterInfoJob extends JobImpl { + "/" + ri.getOptionsMap().size() + " options on " + new Date(ri.getPublished())); try { + // This won't really publish until the netdb is initialized. getContext().netDb().publish(ri); } catch (IllegalArgumentException iae) { _log.log(Log.CRIT, "Error publishing our identity - corrupt? Restart required", iae); diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java index 3cda00ee9..0884a5be2 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java @@ -29,7 +29,7 @@ import net.i2p.util.ConcurrentHashSet; import net.i2p.util.Log; /** - * + * The network database */ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacade { public static final char CAPABILITY_FLOODFILL = 'f'; @@ -111,14 +111,25 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad static final long PUBLISH_TIMEOUT = 90*1000; /** + * Send our RI to the closest floodfill. * @throws IllegalArgumentException if the local router info is invalid */ @Override public void publish(RouterInfo localRouterInfo) throws IllegalArgumentException { if (localRouterInfo == null) throw new IllegalArgumentException("wtf, null localRouterInfo?"); + // should this be after super? why not publish locally? if (_context.router().isHidden()) return; // DE-nied! super.publish(localRouterInfo); - if (_context.router().getUptime() > PUBLISH_JOB_DELAY) + // wait until we've read in the RI's so we can find the closest floodfill + if (!isInitialized()) + return; + // no use sending if we have no addresses + // (unless maybe we used to have addresses? not worth it + if (localRouterInfo.getAddresses().isEmpty()) + return; + _log.info("Publishing our RI"); + // Don't delay, helps IB tunnel builds + //if (_context.router().getUptime() > PUBLISH_JOB_DELAY) sendStore(localRouterInfo.getIdentity().calculateHash(), localRouterInfo, null, null, PUBLISH_TIMEOUT, null); } diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java index 0fc4af026..58a1621ff 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java @@ -47,8 +47,8 @@ import net.i2p.util.ConcurrentHashSet; import net.i2p.util.Log; /** - * Kademlia based version of the network database - * + * Kademlia based version of the network database. + * Never instantiated directly; see FloodfillNetworkDatabaseFacade. */ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade { protected final Log _log; @@ -127,8 +127,14 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade { private final static long ROUTER_INFO_EXPIRATION_FLOODFILL = 60*60*1000l; private final static long EXPLORE_JOB_DELAY = 10*60*1000l; + /** this needs to be long enough to give us time to start up, - but less than 20m (when we start accepting tunnels and could be a IBGW) */ + but less than 20m (when we start accepting tunnels and could be a IBGW) + Actually no, we need this soon if we are a new router or + other routers have forgotten about us, else + we can't build IB exploratory tunnels. + Unused. + */ protected final static long PUBLISH_JOB_DELAY = 5*60*1000l; private static final int MAX_EXPLORE_QUEUE = 128; diff --git a/router/java/src/net/i2p/router/tunnel/pool/ExploratoryPeerSelector.java b/router/java/src/net/i2p/router/tunnel/pool/ExploratoryPeerSelector.java index 47c4d2b0c..1f05727dc 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/ExploratoryPeerSelector.java +++ b/router/java/src/net/i2p/router/tunnel/pool/ExploratoryPeerSelector.java @@ -43,10 +43,17 @@ class ExploratoryPeerSelector extends TunnelPeerSelector { // exclude.addAll(fac.getFloodfillPeers()); HashSet matches = new HashSet(length); boolean exploreHighCap = shouldPickHighCap(ctx); + // // We don't honor IP Restriction here, to be fixed // - if (exploreHighCap) + + // If hidden and inbound, use fast peers - that we probably have recently + // connected to and so they have our real RI - to maximize the chance + // that the adjacent hop can connect to us. + if (settings.isInbound() && ctx.router().isHidden()) + ctx.profileOrganizer().selectFastPeers(length, exclude, matches); + else if (exploreHighCap) ctx.profileOrganizer().selectHighCapacityPeers(length, exclude, matches); else if (ctx.commSystem().haveHighOutboundCapacity()) ctx.profileOrganizer().selectNotFailingPeers(length, exclude, matches, false);