forked from I2P_Developers/i2p.i2p
* 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
This commit is contained in:
@ -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";
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user