public class Banlist extends Object
| Modifier and Type | Class and Description |
|---|---|
static class | Banlist.EntryEntry representing a banned peer with expiration and reason information |
| Modifier and Type | Field and Description |
|---|---|
static long | BANLIST_DURATION_BAD_PACKETSBan duration for repeat bad packet offenders. |
static long | BANLIST_DURATION_FOREVERPermanent ban duration (will be rounded down to 180 days on console). |
static long | BANLIST_DURATION_MAXMaximum ban duration for transient bans. |
static long | BANLIST_DURATION_MSDefault ban duration for transient bans. |
static long | BANLIST_DURATION_NO_NETWORKBuggy i2pd fork |
static long | BANLIST_DURATION_PARTIALDefault ban duration for transport-specific bans. |
static long | BANLIST_DURATION_PRIVATEBan duration for private IP addresses. |
static Hash | HASH_ZERORIhash of 387 zeros |
| Constructor and Description |
|---|
Banlist(RouterContext context)Constructor. |
| Modifier and Type | Method and Description |
|---|---|
void | badPacket(Hash hash,
String version)Record a bad packet from a peer identified by its Router hash. |
void | badPacket(String ip,
String version)Record a bad packet from an IP. |
boolean | banlistRouter(Hash peer)Ban a router with default duration. |
boolean | banlistRouter(Hash peer,
String reason)Ban a router with default duration. |
boolean | banlistRouter(Hash peer,
String reason,
String transport)Ban a router on a specific transport. |
boolean | banlistRouter(Hash peer,
String reason,
String transport,
boolean forever)Ban a router with configurable duration and transport. |
boolean | banlistRouter(Hash peer,
String reason,
String reasonCode,
String transport,
long expireOn)Ban a router with a specified expiration time. |
boolean | banlistRouter(String reasonCode,
Hash peer,
String reason)Ban a router with default duration. |
boolean | banlistRouterForever(Hash peer,
String reason)Permanently ban a router. |
boolean | banlistRouterForever(Hash peer,
String reason,
String reasonCode)Permanently ban a router. |
void | clearSessionBans()Clear all session-based bans. |
void | corruptConnection(Hash hash,
String version)Record a corrupt connection from a peer identified by its Router hash. |
void | corruptConnection(String ip,
String version)Record a corrupt connection (EOF/no data during establishment) from an IP. |
long | getBadPacketDuration()Get the current bad packet ban duration in ms. |
String | getCustomCapabilityBans()Get custom capability ban pattern. |
Map<Hash,Banlist.Entry> | getEntries()Get the banlist entries. |
int | getMaxOffenses()Get the current max offenses setting. |
long | getOffenseWindow()Get the current offense window setting in ms. |
int | getRouterCount()Get the number of currently banlisted routers. |
long | getStartupGrace()Get the current startup grace period in ms. |
boolean | isBadPacketBanEnabled()Check if bad packet auto-ban is enabled. |
boolean | isBanlisted(Hash peer)Check if a router is banlisted. |
boolean | isBanlisted(Hash peer,
String transport)Check if a router is banlisted on a specific transport. |
boolean | isBanlistedForever(Hash peer)Check if a router is permanently banlisted. |
boolean | isBanlistedHostile(Hash peer)Check if a router is banlisted with a hostile duration (at least 1 hour). |
boolean | isBlocklistEnabled()Check if IP blocklist is enabled. |
boolean | isCorruptConnectionBanEnabled()Check if corrupt connection auto-ban is enabled. |
boolean | isCountryBanEnabled()Check if country-based bans are enabled. |
boolean | isLuBanEnabled()Check if LU router bans are enabled. |
boolean | isPortHoppingBanEnabled()Check if port hopping auto-ban is enabled. |
boolean | isTorBlocklistEnabled()Check if Tor exit node blocklist is enabled. |
boolean | isXgBanEnabled()Check if XG router bans are enabled. |
void | portHopping(Hash hash)Record a port hopping attempt from a peer identified by its Router hash. |
void | portHopping(String ip)Record a port hopping attempt from an IP. |
void | reloadConfig()Reload configuration from properties. |
String | shouldBanlistByCapability(String capabilities)Check if router capabilities match any of the custom ban patterns. |
boolean | shouldPurgeExistingRouters()Check if a retroactive NetDb purge sweep is needed. |
void | unbanlistRouter(Hash peer)Remove a router from the banlist. |
void | unbanlistRouter(Hash peer,
String transport)Remove a router from the banlist for a specific transport. |
public static final long BANLIST_DURATION_BAD_PACKETS
public static final long BANLIST_DURATION_FOREVER
public static final long BANLIST_DURATION_MAX
public static final long BANLIST_DURATION_MS
public static final long BANLIST_DURATION_NO_NETWORK
public static final long BANLIST_DURATION_PARTIAL
public static final long BANLIST_DURATION_PRIVATE
public static final Hash HASH_ZERORI
public Banlist(RouterContext context)
context - the router contextpublic void badPacket(Hash hash, String version)
Prefer this overload when a Router hash is available at the
call site; otherwise use badPacket(String, String)
for IP-only tracking.
hash - Router hash (non-null, must exist in local netdb)version - router version info (may be null, falls back to RouterInfo version)public void badPacket(String ip, String version)
ip - IP address (format: "1.2.3.4" or "1.2.3.4:port")version - router version info (may be null)public boolean banlistRouter(Hash peer)
peer - the router hash to banpublic boolean banlistRouter(Hash peer, String reason)
peer - the router hash to banreason - the reasonpublic boolean banlistRouter(Hash peer, String reason, String transport)
peer - the router hash to banreason - the reasontransport - the transportpublic boolean banlistRouter(Hash peer, String reason, String transport, boolean forever)
peer - the router hash to banreason - the reasontransport - the transportforever - if true, ban permanentlypublic boolean banlistRouter(Hash peer, String reason, String reasonCode, String transport, long expireOn)
peer - the router hash to banreason - the reasonreasonCode - separate code so cause can contain {0} for translation (may be null)transport - the transportexpireOn - absolute time when the ban expires, not a durationIllegalArgumentException - if expireOn is before the earliest valid timepublic boolean banlistRouter(String reasonCode, Hash peer, String reason)
reasonCode - separate code so cause can contain {0} for translationpeer - the router hash to banreason - the reasonpublic boolean banlistRouterForever(Hash peer, String reason)
peer - the router hash to banreason - the reasonpublic boolean banlistRouterForever(Hash peer, String reason, String reasonCode)
peer - the router hash to banreason - the reasonreasonCode - separate code so cause can contain {0} for translationpublic void clearSessionBans()
public void corruptConnection(Hash hash, String version)
Prefer this overload when a Router hash is available at the
call site; otherwise use corruptConnection(String, String)
for IP-only tracking.
hash - Router hash (non-null, must exist in local netdb)version - router version info (may be null, falls back to RouterInfo version)public void corruptConnection(String ip, String version)
ip - IP address (format: "1.2.3.4" or "1.2.3.4:port")version - router version info (may be null)public long getBadPacketDuration()
public String getCustomCapabilityBans()
public Map<Hash,Banlist.Entry> getEntries()
public int getMaxOffenses()
public long getOffenseWindow()
public int getRouterCount()
public long getStartupGrace()
public boolean isBadPacketBanEnabled()
public boolean isBanlisted(Hash peer)
peer - the router hash to checkpublic boolean isBanlisted(Hash peer, String transport)
peer - the router hash to checktransport - the transportpublic boolean isBanlistedForever(Hash peer)
peer - the router hash to checkpublic boolean isBanlistedHostile(Hash peer)
peer - the router hash to checkpublic boolean isBlocklistEnabled()
public boolean isCorruptConnectionBanEnabled()
public boolean isCountryBanEnabled()
public boolean isLuBanEnabled()
public boolean isPortHoppingBanEnabled()
public boolean isTorBlocklistEnabled()
public boolean isXgBanEnabled()
public void portHopping(Hash hash)
Prefer this overload when a Router hash is available at the
call site; otherwise use portHopping(String)
for IP-only tracking.
hash - Router hash (non-null, must exist in local netdb)public void portHopping(String ip)
ip - IP address (format: "1.2.3.4")public void reloadConfig()
public String shouldBanlistByCapability(String capabilities)
capabilities - router capabilities string (e.g., "XfP")public boolean shouldPurgeExistingRouters()
public void unbanlistRouter(Hash peer)
peer - the router hash to remove from banlist