diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index e7160d576b3f01c9d18e5c7d28bd7d7e409a63f0..8bbd79a54e5bb01668779f3535aa1c9a0feeb277 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -15,9 +15,9 @@ import net.i2p.CoreVersion; * */ public class RouterVersion { - public final static String ID = "$Revision: 1.434 $ $Date: 2006-07-18 15:08:02 $"; + public final static String ID = "$Revision: 1.435 $ $Date: 2006-07-26 01:36:30 $"; public final static String VERSION = "0.6.1.22"; - public final static long BUILD = 1; + public final static long BUILD = 2; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("Router ID: " + RouterVersion.ID); 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 795bcd06931cb83dc0207682cd1c25c1fd646e63..3ebb528285437998068c541cefed96a0febbf497 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java @@ -237,7 +237,7 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad // entry locally, firing no job if it gets a reply with an updated value (meaning // we shouldn't drop them but instead use the new data), or if they all time out, // firing the dropLookupFailedJob, which actually removes out local reference - search(peer, null, new DropLookupFailedJob(_context, peer, info), 10*1000, false); + search(peer, new DropLookupFoundJob(_context, peer, info), new DropLookupFailedJob(_context, peer, info), 10*1000, false); } private class DropLookupFailedJob extends JobImpl { @@ -254,6 +254,26 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad dropAfterLookupFailed(_peer, _info); } } + private class DropLookupFoundJob extends JobImpl { + private Hash _peer; + private RouterInfo _info; + + public DropLookupFoundJob(RouterContext ctx, Hash peer, RouterInfo info) { + super(ctx); + _peer = peer; + _info = info; + } + public String getName() { return "Lookup on failure of netDb peer matched"; } + public void runJob() { + RouterInfo updated = lookupRouterInfoLocally(_peer); + if ( (updated != null) && (updated.getPublished() > _info.getPublished()) ) { + // great, a legitimate update + } else { + // they just sent us what we already had. kill 'em both + dropAfterLookupFailed(_peer, _info); + } + } + } } /** 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 0c885b2ee8432f088faabe6e5c9581e50666ac60..a9d93691bcc8f019680a720d6aed72add2215a7a 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java @@ -462,9 +462,22 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade { if (!_initialized) return null; DataStructure ds = _ds.get(key); if (ds != null) { - if (ds instanceof RouterInfo) + if (ds instanceof RouterInfo) { + // more aggressive than perhaps is necessary, but makes sure we + // drop old references that we had accepted on startup (since + // startup allows some lax rules). + boolean valid = true; + try { + valid = (null == validate(key, (RouterInfo)ds)); + } catch (IllegalArgumentException iae) { + valid = false; + } + if (!valid) { + fail(key); + return null; + } return (RouterInfo)ds; - else { + } else { //_log.debug("Looking for a router [" + key + "] but it ISN'T a RouterInfo! " + ds, new Exception("Who thought that lease was a router?")); return null; } @@ -677,6 +690,9 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade { String rv = "Peer " + key.toBase64() + " is from another network, not accepting it (id=" + routerInfo.getNetworkId() + ", want " + Router.NETWORK_ID + ")"; return rv; + } else if ( (_context.router().getUptime() > 60*60*1000) && (routerInfo.getPublished() < now - 2*24*60*60*1000l) ) { + long age = _context.clock().now() - routerInfo.getPublished(); + return "Peer " + key.toBase64() + " published " + DataHelper.formatDuration(age) + " ago"; } return null; } diff --git a/router/java/src/net/i2p/router/transport/TransportManager.java b/router/java/src/net/i2p/router/transport/TransportManager.java index bb750293cf1cf621d550483d5770b09e99357bf0..7c04f010ddbf4e0cf0f4ad271bd2c0492b7590e8 100644 --- a/router/java/src/net/i2p/router/transport/TransportManager.java +++ b/router/java/src/net/i2p/router/transport/TransportManager.java @@ -44,6 +44,8 @@ public class TransportManager implements TransportEventListener { public TransportManager(RouterContext context) { _context = context; _log = _context.logManager().getLog(TransportManager.class); + _context.statManager().createRateStat("transport.shitlistOnUnreachable", "Add a peer to the shitlist since none of the transports can reach them", "Transport", new long[] { 60*1000, 10*60*1000, 60*60*1000 }); + _context.statManager().createRateStat("transport.noBidsYetNotAllUnreachable", "Add a peer to the shitlist since none of the transports can reach them", "Transport", new long[] { 60*1000, 10*60*1000, 60*60*1000 }); _transports = new ArrayList(); } @@ -239,10 +241,16 @@ public class TransportManager implements TransportEventListener { } else { if (_log.shouldLog(Log.DEBUG)) _log.debug("Transport " + t.getStyle() + " did not produce a bid"); + if (t.isUnreachable(peer)) + unreachableTransports++; } } - if (unreachableTransports >= _transports.size()) + if (unreachableTransports >= _transports.size()) { + _context.statManager().addRateData("transport.shitlistOnUnreachable", msg.getLifetime(), msg.getLifetime()); _context.shitlist().shitlistRouter(peer, "Unreachable on any transport"); + } else if (rv == null) { + _context.statManager().addRateData("transport.noBidsYetNotAllUnreachable", unreachableTransports, msg.getLifetime()); + } return rv; } diff --git a/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java b/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java index dd29ef16380f0033fe1bc2bbdcd571326182a6ce..5653a9bc5f2209be65311e5b0971fcbd2b41b46b 100644 --- a/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java +++ b/router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java @@ -256,7 +256,7 @@ public class NTCPConnection implements FIFOBandwidthLimiter.CompleteListener { synchronized (_writeBufs) { blocks = _writeBufs.size(); } if (_log.shouldLog(Log.ERROR)) _log.error("Too backlogged for too long (" + _consecutiveBacklog + " messages for " + DataHelper.formatDuration(queueTime()) + ", sched? " + wantsWrite + ", blocks: " + blocks + ") sending to " + _remotePeer.calculateHash().toBase64()); - _context.statManager().addRateData("ntcp.closeOnBacklog", _consecutiveBacklog, getUptime()); + _context.statManager().addRateData("ntcp.closeOnBacklog", getUptime(), getUptime()); close(); } _context.statManager().addRateData("ntcp.dontSendOnBacklog", _consecutiveBacklog, msg.getLifetime()); diff --git a/router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java b/router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java index 6da52359b1acdaf934dd16d8fa2934c37ae873ad..e4eb53ed6018ac2a7de28452d0b6b5cdf9bdef75 100644 --- a/router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java +++ b/router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java @@ -62,14 +62,13 @@ public class NTCPTransport extends TransportImpl { _context.statManager().createRateStat("ntcp.sendBacklogTime", "How long the head of the send queue has been waiting when we fail to add a new one to the queue (period is the number of messages queued)", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.failsafeWrites", "How many times do we need to proactively add in an extra nio write to a peer at any given failsafe pass?", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.failsafeCloses", "How many times do we need to proactively close an idle connection to a peer at any given failsafe pass?", "ntcp", new long[] { 60*1000, 10*60*1000 }); - _context.statManager().createRateStat("ntcp.accept", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.attemptShitlistedPeer", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.attemptUnreachablePeer", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.closeOnBacklog", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.connectFailedIOE", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.connectFailedInvalidPort", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); - _context.statManager().createRateStat("ntcp.connectFailedNoNTCPAddress", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); + _context.statManager().createRateStat("ntcp.bidRejectedNoNTCPAddress", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.connectFailedTimeout", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.connectFailedTimeoutIOE", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.connectFailedUnresolved", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); @@ -113,8 +112,6 @@ public class NTCPTransport extends TransportImpl { _context.statManager().createRateStat("ntcp.wantsQueuedWrite", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.write", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); _context.statManager().createRateStat("ntcp.writeError", "", "ntcp", new long[] { 60*1000, 10*60*1000 }); - - _establishing = new ArrayList(4); _conLock = new Object(); _conByIdent = new HashMap(64); @@ -254,12 +251,11 @@ public class NTCPTransport extends TransportImpl { _log.debug("fast bid when trying to send to " + toAddress.getIdentity().calculateHash().toBase64() + " as its already established"); return _fastBid; } - RouterAddress addr = toAddress.getTargetAddress(STYLE); if (addr == null) { markUnreachable(peer); - _context.statManager().addRateData("ntcp.connectFailedNoNTCPAddress", 1, 0); + _context.statManager().addRateData("ntcp.bidRejectedNoNTCPAddress", 1, 0); //_context.shitlist().shitlistRouter(toAddress.getIdentity().calculateHash(), "No NTCP address", STYLE); if (_log.shouldLog(Log.DEBUG)) _log.debug("no bid when trying to send to " + toAddress.getIdentity().calculateHash().toBase64() + " as they don't have an ntcp address");