Router: Shorter ban time for localhost addresses

This commit is contained in:
zzz
2021-12-01 15:51:44 -05:00
parent 890a8927a5
commit cf22186182
2 changed files with 11 additions and 1 deletions

View File

@@ -54,6 +54,7 @@ public class Banlist {
public final static long BANLIST_DURATION_PARTIAL = 10*60*1000;
public final static long BANLIST_DURATION_FOREVER = 181l*24*60*60*1000; // will get rounded down to 180d on console
public final static long BANLIST_DURATION_NO_NETWORK = 6*60*60*1000;
public final static long BANLIST_DURATION_LOCALHOST = 2*60*60*1000;
private final static long BANLIST_CLEANER_START_DELAY = BANLIST_DURATION_PARTIAL;
public Banlist(RouterContext context) {

View File

@@ -1025,7 +1025,16 @@ public class Blocklist {
private void banlist(Hash peer, byte[] ip) {
// Temporary reason, until the job finishes
String reason = _x("IP banned by blocklist.txt entry {0}");
_context.banlist().banlistRouterForever(peer, reason, Addresses.toString(ip));
String sip = Addresses.toString(ip);
if ("127.0.0.1".equals(sip) ||
"0:0:0:0:0:0:0:1".equals(sip) ||
sip.startsWith("192.168.")) {
// i2pd bug, possibly at startup, don't ban forever
_context.banlist().banlistRouter(peer, reason, sip, null,
_context.clock().now() + Banlist.BANLIST_DURATION_LOCALHOST);
return;
}
_context.banlist().banlistRouterForever(peer, reason, sip);
if (! _context.getBooleanPropertyDefaultTrue(PROP_BLOCKLIST_DETAIL))
return;
boolean shouldRunJob;