From 728762d4fdcbf251365bd89d975c69a7c839c09c Mon Sep 17 00:00:00 2001 From: eyedeekay Date: Wed, 19 Jul 2023 10:22:08 -0400 Subject: [PATCH] Router: Add a minimum threshold for banning a router which repeatedly disrespects our congestion flags --- .../src/net/i2p/router/tunnel/pool/BuildHandler.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 f5537e2381..63976ca3d4 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java +++ b/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java @@ -489,11 +489,14 @@ private long handleRequest(BuildMessageState state, long now) { // congestion flags if (fromVersion != null){ if (VersionComparator.comp(fromVersion, MIN_VERSION_HONOR_CAPS) >= 0) { - if (_log.shouldLog(Log.WARN)) - _log.warn("Banning peer: " + fromRI.getHash() + " due to it disrespecting our congestion flags"); - _context.banlist().banlistRouter(from, "disrespected our tunnel flags", null, false); + _context.statManager().addRateData("tunnel.dropTunnelFromVersion"+from, 1); + long knocks = _context.statManager().getRate("tunnel.dropTunnelFromVersion"+from).getLifetimeEventCount(); + if (knocks > 10) { + if (_log.shouldLog(Log.WARN)) + _log.warn("Banning peer: " + fromRI.getHash() + " due to it disrespecting our congestion flags"); + _context.banlist().banlistRouter(from, "disrespected our tunnel flags", null, false); + } } - } } return -1;