diff --git a/history.txt b/history.txt index d3d016b01..03891b8fc 100644 --- a/history.txt +++ b/history.txt @@ -1,5 +1,8 @@ 2011-02-23 zzz - * BuildHandler: Lower participating throttler max limit + * BuildHandler: + - Lower participating throttler max limit + - Cleanups and loop checks + * Console: Fix summary bar HTML error 2011-02-22 zzz * BuildHandler: Prelmiinary participating tunnel throttler diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 14408f1ed..987fc2f75 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 = 18; + public final static long BUILD = 19; /** for example "-test" */ public final static String EXTRA = "-rc"; diff --git a/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java b/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java index ca9c6ad63..618395576 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java +++ b/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java @@ -501,6 +501,25 @@ class BuildHandler { boolean isInGW = req.readIsInboundGateway(); boolean isOutEnd = req.readIsOutboundEndpoint(); + // Loop checks + if ((!isOutEnd) && _context.routerHash().equals(nextPeer)) { + // We are 2 hops in a row? Drop it without a reply. + // No way to recognize if we are every other hop, but see below + _log.error("Dropping build request where we are in two consecutive hops"); + return; + } + if ((!isOutEnd) && (!isInGW)) { + Hash from = state.fromHash; + if (from == null) + from = state.from.calculateHash(); + // Previous and next hop the same? Don't help somebody be evil. Drop it without a reply. + // A-B-C-A is not preventable + if (nextPeer.equals(from)) { + _log.error("Dropping build request with the same previous and next hop"); + return; + } + } + // time is in hours, and only for log below - what's the point? // tunnel-alt-creation.html specifies that this is enforced +/- 1 hour but it is not. long time = req.readRequestTime(); @@ -569,9 +588,9 @@ class BuildHandler { } } if (response == 0 && (!isOutEnd) && - _throttler.shouldThrottle(req.readNextIdentity())) { + _throttler.shouldThrottle(nextPeer)) { if (_log.shouldLog(Log.WARN)) - _log.warn("Rejecting tunnel (hop throttle), next hop: " + req.readNextIdentity()); + _log.warn("Rejecting tunnel (hop throttle), next hop: " + nextPeer); // no setTunnelStatus() indication response = TunnelHistory.TUNNEL_REJECT_BANDWIDTH; } @@ -606,7 +625,7 @@ class BuildHandler { cfg.setSendTo(null); cfg.setSendTunnelId(null); } else { - cfg.setSendTo(req.readNextIdentity()); + cfg.setSendTo(nextPeer); cfg.setSendTunnelId(DataHelper.toLong(4, nextId)); } @@ -622,7 +641,7 @@ class BuildHandler { _context.tunnelDispatcher().joinParticipant(cfg); } else { _context.statManager().addRateData("tunnel.reject." + response, 1, 1); - _context.messageHistory().tunnelRejected(state.fromHash, new TunnelId(ourId), req.readNextIdentity(), + _context.messageHistory().tunnelRejected(state.fromHash, new TunnelId(ourId), nextPeer, "rejecting for " + response + ": " + state.msg.getUniqueId() + "/" + ourId + "/" + req.readNextTunnelId() + " delay " + recvDelay + " as " +