Nested Class Summary
Modifier and TypeClassDescriptionprivate classPeriodically removes expired bans and offenses.static classEntry representing a banned peer with expiration and reason information.Field Summary
Modifier and TypeFieldDescriptionprivate longBad packet ban length in effect right now.private final ConcurrentHashMap<String, long[]> Bad packet offenses by IP address, with times.private final RouterContextThe router context.private final ConcurrentHashMap<String, long[]> Corrupt connection offenses by IP address, with times.private StringCapability letters to ban, from the config.private booleanWhether bad packet banning is enabled.private booleanWhether the blocklist is enabled.private booleanWhether corrupt connection banning is enabled.private booleanWhether country banning is enabled.private booleanWhether the introducer-cap ban is enabled.private booleanWhether the invalid version ban is enabled.private booleanWhether the LU router ban is enabled.private booleanWhether port hopping banning is enabled.private booleanWhether the bad publication date ban is enabled.private booleanWhether the contradictory caps ban is enabled.private booleanWhether the Tor blocklist is enabled.private booleanWhether the XG router ban is enabled.private final Map<Hash, Banlist.Entry> Active bans by router hash.private final LogLogger for ban decisions.private intOffenses needed to ban, in effect right now.private longOffense window in effect right now.private final ConcurrentHashMap<String, long[]> Port hopping offenses by IP address, with times.private longStartup grace period in effect right now.private static final intBan count baseline for proportional duration reduction.private static final intAbove this count, ALL bans over 1h are halved regardless of existing scaling.private static final longEligible ban durations for reduction: < 1 week.private static final longEligible ban durations for reduction: > 4 hours.private static final longWait before the cleanup job first runs.static final longBan duration for repeat bad packet offenders.private static final longThe default bad packet ban lasts 1 hour.static final longPermanent ban duration (will be rounded down to 180 days on console).static final longMaximum ban duration for transient bans.static final longDefault ban duration for transient bans.static final longBuggy i2pd fork.static final longDefault ban duration for transport-specific bans.static final longBan duration for private IP addresses.private static final longA ban that expires after this will return true inisBanlistedForever(Hash).private static final PatternSplits the capability ban list on commas and spaces.private static final booleanBad packet banning is off by default.private static final booleanThe blocklist is on by default.private static final booleanCorrupt connection banning is off by default.private static final booleanCountry banning is off by default.private static final booleanBanning introducer-capped routers is on by default.private static final booleanBanning invalid router versions is on by default.private static final booleanBanning LU capacity routers is off by default.private static final booleanPort hopping banning is off by default.private static final booleanBanning bad publication dates is on by default.private static final booleanBanning contradictory reachability caps is on by default.private static final booleanThe Tor blocklist is on by default.private static final booleanBanning XG capacity routers is off by default.static final HashHash of 387 zeros.private static final intDefault offenses needed to ban.(package private) static final StringHighest I2P version recognised as real.private static final doubleSmallest factor a ban duration may be scaled by.private static final longThe default offense window is 15 minutes.private static final StringConfig key for the bad packet ban length.private static final StringConfig key listing capability letters to ban.private static final StringConfig key turning the bad packet ban on or off.private static final StringConfig key turning the blocklist on or off.private static final StringConfig key turning the corrupt connection ban on or off.private static final StringConfig key turning the country blocklist on or off.private static final StringConfig key turning the introducer-cap ban on or off, for an SSU2 address advertising more introducers than the spec allows.private static final StringConfig key turning the invalid version ban on or off.private static final StringConfig key turning the LU router ban on or off.private static final StringConfig key turning the port hopping ban on or off.private static final StringConfig key turning the bad publication date ban on or off, for a router info published in the past epoch.private static final StringConfig key turning the contradictory caps ban on or off.private static final StringConfig key turning the Tor blocklist on or off.private static final StringConfig key turning the XG router ban on or off.private static final StringConfig key for the offenses needed to ban.private static final StringConfig key for the window offenses count in, 15 minutes by default.private static final StringConfig key for the startup grace period, during which offenses are not tracked, 3 minutes by default.private static final longThe default startup grace before offenses count is 3 minutes.Constructor Summary
ConstructorsConstructorDescriptionBanlist(RouterContext context) Seeds the entry maps, bans the known invalid hashes, and reads the config.Method Summary
Modifier and TypeMethodDescriptionvoidRecord a bad packet from an IP.voidRecord a bad packet from a peer identified by its Router hash.booleanbanlistRouter(String reasonCode, Hash peer, String reason) Ban a router with default duration.booleanbanlistRouter(Hash peer) Ban a router with default duration.booleanbanlistRouter(Hash peer, String reason) Ban a router with default duration.booleanbanlistRouter(Hash peer, String reason, String transport) Ban a router on a specific transport.booleanbanlistRouter(Hash peer, String reason, String transport, boolean forever) Ban a router with configurable duration and transport.private booleanbanlistRouter(Hash peer, String reason, String reasonCode, String transport, boolean forever) Ban a router with automatic duration calculation.booleanbanlistRouter(Hash peer, String reason, String reasonCode, String transport, long expireOn) Ban a router with a specified expiration time.booleanbanlistRouterForever(Hash peer, String reason) Permanently ban a router.booleanbanlistRouterForever(Hash peer, String reason, String reasonCode) Permanently ban a router.voidClear all session-based bans.voidcorruptConnection(String ip, String version) Record a corrupt connection (EOF/no data during establishment) from an IP.voidcorruptConnection(Hash hash, String version) Record a corrupt connection from a peer identified by its Router hash.longGet the current bad packet ban duration in ms.longHow long the banlist has been holding a peer, in milliseconds.getBanCause(Hash peer) Reason recorded when the peer was banlisted.Get custom capability ban pattern.Get the banlist entries.intGet the current max offenses setting.longGet the current offense window setting in ms.intNumber of currently banlisted routers.private static StringExtract the first reachable IP from a RouterInfo's address list.longGet the current startup grace period in ms.private voidInitialize configurable properties.booleanCheck if bad packet auto-ban is enabled.booleanisBanlisted(Hash peer) Check if a router is banlisted.booleanisBanlisted(Hash peer, String transport) Check if a router is banlisted on a specific transport.booleanisBanlistedForever(Hash peer) Check if a router is permanently banlisted.booleanisBanlistedHostile(Hash peer) Check if a router is banlisted with a hostile duration (at least 1 hour).booleanCheck if IP blocklist is enabled.booleanCheck if corrupt connection auto-ban is enabled.booleanCheck if country-based bans are enabled.booleanCheck if introducer-cap router bans are enabled.static booleanisInvalidVersion(String version) Whether a RouterInfo version is above every version that has been released, which makes the RouterInfo fabricated rather than merely old.booleanCheck the invalid-RouterInfo-version ban is enabled.booleanCheck if LU router bans are enabled.booleanCheck if port hopping auto-ban is enabled.booleanCheck the invalid-publication-date ban is enabled.booleanCheck the contradictory-reachability-caps ban is enabled.booleanCheck if Tor exit node blocklist is enabled.booleanCheck if XG router bans are enabled.(package private) static StringmatchCapabilityPattern(String capabilities, String patternsStr) Pure decision helper: match a capabilities string against a comma/space-separated list of capability ban patterns.voidportHopping(String ip) Record a port hopping attempt from an IP.voidportHopping(Hash hash) Record a port hopping attempt from a peer identified by its Router hash.static booleanWhether a capability string claims to be reachable and unreachable at once.private voidreduceDurations(long now) When the ban count exceeds BAN_COUNT_BASELINE, proportionally reduce remaining durations of eligible entries (between BAN_REDUCTION_MIN and BAN_REDUCTION_MAX) to keep the list manageable under memory pressure.voidReload configuration from properties.shouldBanlistByCapability(String capabilities) Check if router capabilities match any of the custom ban patterns.booleanCheck if a retroactive NetDb purge sweep is needed.voidunbanlistRouter(Hash peer) Remove a router from the banlist.private voidunbanlistRouter(Hash peer, boolean realUnbanlist) Remove a peer from the banlist, optionally updating message history.private voidunbanlistRouter(Hash peer, boolean realUnbanlist, String transport) Remove a router from the banlist.voidunbanlistRouter(Hash peer, String transport) Remove a router from the banlist for a specific transport.
Field Details
_log
Logger for ban decisions._context
The router context._entries
Active bans by router hash._badPacketIPs
Bad packet offenses by IP address, with times._corruptConnectionIPs
Corrupt connection offenses by IP address, with times._portHoppingIPs
Port hopping offenses by IP address, with times.PROP_MAX_OFFENSES
Config key for the offenses needed to ban.- See Also:
MAX_OFFENSES_DEFAULT
private static final int MAX_OFFENSES_DEFAULTDefault offenses needed to ban.- See Also:
_maxOffenses
private int _maxOffensesOffenses needed to ban, in effect right now.PROP_OFFENSE_WINDOW
Config key for the window offenses count in, 15 minutes by default.- See Also:
OFFENSE_WINDOW_DEFAULT
private static final long OFFENSE_WINDOW_DEFAULTThe default offense window is 15 minutes.- See Also:
_offenseWindow
private long _offenseWindowOffense window in effect right now.PROP_STARTUP_GRACE
Config key for the startup grace period, during which offenses are not tracked, 3 minutes by default.- See Also:
STARTUP_GRACE_DEFAULT
private static final long STARTUP_GRACE_DEFAULTThe default startup grace before offenses count is 3 minutes.- See Also:
_startupGrace
private long _startupGraceStartup grace period in effect right now.PROP_BAD_PACKET_DURATION
Config key for the bad packet ban length.- See Also:
BANLIST_DURATION_BAD_PACKETS_DEFAULT
private static final long BANLIST_DURATION_BAD_PACKETS_DEFAULTThe default bad packet ban lasts 1 hour.- See Also:
_badPacketDuration
private long _badPacketDurationBad packet ban length in effect right now.PROP_ENABLE_BAD_PACKET_BAN
Config key turning the bad packet ban on or off.- See Also:
ENABLE_BAD_PACKET_BAN_DEFAULT
private static final boolean ENABLE_BAD_PACKET_BAN_DEFAULTBad packet banning is off by default.- See Also:
_enableBadPacketBan
private boolean _enableBadPacketBanWhether bad packet banning is enabled.PROP_ENABLE_CORRUPT_CONNECTION_BAN
Config key turning the corrupt connection ban on or off.- See Also:
ENABLE_CORRUPT_CONNECTION_BAN_DEFAULT
private static final boolean ENABLE_CORRUPT_CONNECTION_BAN_DEFAULTCorrupt connection banning is off by default.- See Also:
_enableCorruptConnectionBan
private boolean _enableCorruptConnectionBanWhether corrupt connection banning is enabled.PROP_ENABLE_PORT_HOPPING_BAN
Config key turning the port hopping ban on or off.- See Also:
ENABLE_PORT_HOPPING_BAN_DEFAULT
private static final boolean ENABLE_PORT_HOPPING_BAN_DEFAULTPort hopping banning is off by default.- See Also:
_enablePortHoppingBan
private boolean _enablePortHoppingBanWhether port hopping banning is enabled.PROP_ENABLE_BLOCKLIST
Config key turning the blocklist on or off.- See Also:
ENABLE_BLOCKLIST_DEFAULT
private static final boolean ENABLE_BLOCKLIST_DEFAULTThe blocklist is on by default.- See Also:
_enableBlocklist
private boolean _enableBlocklistWhether the blocklist is enabled.PROP_ENABLE_TOR_BLOCKLIST
Config key turning the Tor blocklist on or off.- See Also:
ENABLE_TOR_BLOCKLIST_DEFAULT
private static final boolean ENABLE_TOR_BLOCKLIST_DEFAULTThe Tor blocklist is on by default.- See Also:
_enableTorBlocklist
private boolean _enableTorBlocklistWhether the Tor blocklist is enabled.PROP_ENABLE_COUNTRY_BAN
Config key turning the country blocklist on or off.- See Also:
ENABLE_COUNTRY_BAN_DEFAULT
private static final boolean ENABLE_COUNTRY_BAN_DEFAULTCountry banning is off by default.- See Also:
_enableCountryBan
private boolean _enableCountryBanWhether country banning is enabled.PROP_ENABLE_XG_BAN
Config key turning the XG router ban on or off.- See Also:
ENABLE_XG_BAN_DEFAULT
private static final boolean ENABLE_XG_BAN_DEFAULTBanning XG capacity routers is off by default.- See Also:
_enableXgBan
private boolean _enableXgBanWhether the XG router ban is enabled.PROP_ENABLE_LU_BAN
Config key turning the LU router ban on or off.- See Also:
ENABLE_LU_BAN_DEFAULT
private static final boolean ENABLE_LU_BAN_DEFAULTBanning LU capacity routers is off by default.- See Also:
_enableLuBan
private boolean _enableLuBanWhether the LU router ban is enabled.PROP_ENABLE_INTRODUCER_BAN
Config key turning the introducer-cap ban on or off, for an SSU2 address advertising more introducers than the spec allows.- See Also:
ENABLE_INTRODUCER_BAN_DEFAULT
private static final boolean ENABLE_INTRODUCER_BAN_DEFAULTBanning introducer-capped routers is on by default.- See Also:
_enableIntroducerBan
private boolean _enableIntroducerBanWhether the introducer-cap ban is enabled.PROP_ENABLE_INVALID_VERSION_BAN
Config key turning the invalid version ban on or off.- See Also:
ENABLE_INVALID_VERSION_BAN_DEFAULT
private static final boolean ENABLE_INVALID_VERSION_BAN_DEFAULTBanning invalid router versions is on by default.- See Also:
_enableInvalidVersionBan
private boolean _enableInvalidVersionBanWhether the invalid version ban is enabled.PROP_ENABLE_PUB_DATE_BAN
Config key turning the bad publication date ban on or off, for a router info published in the past epoch.- See Also:
ENABLE_PUB_DATE_BAN_DEFAULT
private static final boolean ENABLE_PUB_DATE_BAN_DEFAULTBanning bad publication dates is on by default.- See Also:
_enablePubDateBan
private boolean _enablePubDateBanWhether the bad publication date ban is enabled.PROP_ENABLE_RU_CAPS_BAN
Config key turning the contradictory caps ban on or off.- See Also:
ENABLE_RU_CAPS_BAN_DEFAULT
private static final boolean ENABLE_RU_CAPS_BAN_DEFAULTBanning contradictory reachability caps is on by default.- See Also:
_enableRUCapsBan
private boolean _enableRUCapsBanWhether the contradictory caps ban is enabled.PROP_CUSTOM_CAPABILITY_BANS
Config key listing capability letters to ban.- See Also:
COMMA_SPLIT
Splits the capability ban list on commas and spaces._customCapabilityBans
Capability letters to ban, from the config.HASH_ZERORI
Hash of 387 zeros.BANLIST_DURATION_MS
public static final long BANLIST_DURATION_MSDefault ban duration for transient bans.- See Also:
BANLIST_DURATION_MAX
public static final long BANLIST_DURATION_MAXMaximum ban duration for transient bans.- See Also:
BANLIST_DURATION_PARTIAL
public static final long BANLIST_DURATION_PARTIALDefault ban duration for transport-specific bans.- See Also:
BANLIST_DURATION_FOREVER
public static final long BANLIST_DURATION_FOREVERPermanent ban duration (will be rounded down to 180 days on console).- See Also:
BANLIST_DURATION_NO_NETWORK
BANLIST_DURATION_PRIVATE
public static final long BANLIST_DURATION_PRIVATEBan duration for private IP addresses.- See Also:
BANLIST_DURATION_BAD_PACKETS
public static final long BANLIST_DURATION_BAD_PACKETSBan duration for repeat bad packet offenders.- See Also:
BANLIST_CLEANER_START_DELAY
private static final long BANLIST_CLEANER_START_DELAYWait before the cleanup job first runs.- See Also:
BAN_COUNT_BASELINE
private static final int BAN_COUNT_BASELINEBan count baseline for proportional duration reduction. At this count or below, no reduction is applied. Above this, remaining durations are scaled by baseline / count, minimum scale floor MIN_BAN_SCALE.- See Also:
MIN_BAN_SCALE
private static final double MIN_BAN_SCALESmallest factor a ban duration may be scaled by.- See Also:
BAN_REDUCTION_MIN
private static final long BAN_REDUCTION_MINEligible ban durations for reduction: > 4 hours.- See Also:
BAN_REDUCTION_MAX
private static final long BAN_REDUCTION_MAXEligible ban durations for reduction: < 1 week.- See Also:
BAN_COUNT_HIGH
private static final int BAN_COUNT_HIGHAbove this count, ALL bans over 1h are halved regardless of existing scaling.- See Also:
BANLIST_FOREVER_THRESHOLD
private static final long BANLIST_FOREVER_THRESHOLDA ban that expires after this will return true inisBanlistedForever(Hash). In the transports, "forever" is treated as a hard ban, and both inbound and outbound connections will be rejected. Not-forever is treated as a soft ban, with outbound rejected but inbound will be allowed and will automatically unban.- See Also:
MAX_VALID_VERSION
Highest I2P version recognised as real. No released version reaches it, so a RouterInfo publishing a version at or above this ceiling has built the RouterInfo by hand - usually a scanner probing for netdb storage. Kept here so the NTCP2 handshake, the floodfill store path and the data store all agree on one ceiling.- See Also:
Constructor Details
Banlist
Seeds the entry maps, bans the known invalid hashes, and reads the config.- Parameters:
context- the router context
Method Details
initConfig
private void initConfig()Initialize configurable properties. Reads from router config, falls back to defaults.reloadConfig
public void reloadConfig()Reload configuration from properties. Called when settings are changed in the console.clearSessionBans
public void clearSessionBans()Clear all session-based bans.getMaxOffenses
public int getMaxOffenses()Get the current max offenses setting.- Returns:
- the maximum offenses before auto-ban
getOffenseWindow
public long getOffenseWindow()Get the current offense window setting in ms.- Returns:
- the offense window in milliseconds
getStartupGrace
public long getStartupGrace()Get the current startup grace period in ms.- Returns:
- the startup grace period in milliseconds
getBadPacketDuration
public long getBadPacketDuration()Get the current bad packet ban duration in ms.- Returns:
- the bad packet ban duration in milliseconds
isBadPacketBanEnabled
public boolean isBadPacketBanEnabled()Check if bad packet auto-ban is enabled.- Returns:
- true if bad packet auto-ban is enabled
isCorruptConnectionBanEnabled
public boolean isCorruptConnectionBanEnabled()Check if corrupt connection auto-ban is enabled.- Returns:
- true if corrupt connection auto-ban is enabled
isPortHoppingBanEnabled
public boolean isPortHoppingBanEnabled()Check if port hopping auto-ban is enabled.- Returns:
- true if port hopping auto-ban is enabled
isBlocklistEnabled
public boolean isBlocklistEnabled()Check if IP blocklist is enabled.- Returns:
- true if IP blocklist is enabled
isTorBlocklistEnabled
public boolean isTorBlocklistEnabled()Check if Tor exit node blocklist is enabled.- Returns:
- true if Tor exit node blocklist is enabled
isCountryBanEnabled
public boolean isCountryBanEnabled()Check if country-based bans are enabled.- Returns:
- true if country-based bans are enabled
isXgBanEnabled
public boolean isXgBanEnabled()Check if XG router bans are enabled. XG = unlimited bandwidth (X), no transit tunnels (G) - often botnet indicators.- Returns:
- true if XG router bans are enabled
isLuBanEnabled
public boolean isLuBanEnabled()Check if LU router bans are enabled. LU = low bandwidth tier (L) + unreachable/firewalled (U).- Returns:
- true if LU router bans are enabled
isIntroducerBanEnabled
public boolean isIntroducerBanEnabled()Check if introducer-cap router bans are enabled. An SSU2 address advertising more than the spec's five introducers is out of spec - usually a scanner or a modified client - so it can be banned when we learn of it, not only when we handshake.- Returns:
- true if over-cap introducer bans are enabled
isInvalidVersionBanEnabled
public boolean isInvalidVersionBanEnabled()Check the invalid-RouterInfo-version ban is enabled. A RouterInfo publishing a version above every released version is fabricated, so it can be banned where it is seen rather than only at the handshake.- Returns:
- true if fabricated-version bans are enabled
isPubDateBanEnabled
public boolean isPubDateBanEnabled()Check the invalid-publication-date ban is enabled.- Returns:
- true if bad-publication-date bans are enabled
isRUCapsBanEnabled
public boolean isRUCapsBanEnabled()Check the contradictory-reachability-caps ban is enabled.- Returns:
- true if routers publishing both R and U are banned
isInvalidVersion
Whether a RouterInfo version is above every version that has been released, which makes the RouterInfo fabricated rather than merely old.- Parameters:
version- the version string from the RouterInfo, may be null- Returns:
- true if the version is not a plausible released version
publishesContradictoryCaps
Whether a capability string claims to be reachable and unreachable at once. The two flags are mutually exclusive by definition, so a router publishing both has assembled its own RouterInfo rather than run a router that measured its reachability.- Parameters:
caps- the capability string, may be null- Returns:
- true if both the R and U flags are present
shouldPurgeExistingRouters
public boolean shouldPurgeExistingRouters()Check if a retroactive NetDb purge sweep is needed. True if LU/XG/introducer bans, the RouterInfo validation bans (version, publication date, reachability flags), or custom capability bans are enabled.- Returns:
- true if existing routers should be purged
getCustomCapabilityBans
Get custom capability ban pattern. Format: string of capability letters (e.g., "DG", "UX").- Returns:
- the custom capability ban pattern, or empty string if none
shouldBanlistByCapability
Check if router capabilities match any of the custom ban patterns.A pattern may carry an exclusion group after '!': "G!f" matches routers with G in their caps unless they are also floodfills. Exclusions require at least one required character.
Comparison is case-sensitive throughout: capability letters are case-significant (lowercase 'f' is floodfill, uppercase letters are separate meanings), so neither the stored patterns nor the router's caps may be case-folded before matching.
- Parameters:
capabilities- router capabilities string (e.g., "XfP")- Returns:
- the matched pattern exactly as configured (e.g., "G!f") or null if no match
matchCapabilityPattern
Pure decision helper: match a capabilities string against a comma/space-separated list of capability ban patterns.Each pattern is a set of required characters, optionally followed by '!'. A router matches when it carries every required character and none of the excluded ones. A pattern with an empty required part can never match, so a bare exclusion cannot ban the entire network. Case-sensitive: see
shouldBanlistByCapability(String).- Parameters:
capabilities- router capabilities string, may be nullpatternsStr- configured patterns, may be null or empty- Returns:
- the first matching pattern as configured, or null if none match
reduceDurations
private void reduceDurations(long now) When the ban count exceeds BAN_COUNT_BASELINE, proportionally reduce remaining durations of eligible entries (between BAN_REDUCTION_MIN and BAN_REDUCTION_MAX) to keep the list manageable under memory pressure. Scaling: remaining *= max(MIN_BAN_SCALE, (double) BAN_COUNT_BASELINE / count).- Parameters:
now- the current time in ms, the reference for each entry's remaining duration
badPacket
badPacket
Record a bad packet from a peer identified by its Router hash. Looks up the RouterInfo from the local netdb to extract the peer's IP address, caps, and version for threshold tracking and full-context BanLogger output. Silently returns if the RouterInfo is not in the netdb or has no reachable address.Prefer this overload when a Router hash is available at the call site; otherwise use
badPacket(String, String)for IP-only tracking.- Parameters:
hash- Router hash (non-null, must exist in local netdb)version- router version info (may be null, falls back to RouterInfo version)
corruptConnection
corruptConnection
Record a corrupt connection from a peer identified by its Router hash. Looks up the RouterInfo from the local netdb to extract the peer's IP address, caps, and version for threshold tracking and full-context BanLogger output. Silently returns if the RouterInfo is not in the netdb or has no reachable address.Prefer this overload when a Router hash is available at the call site; otherwise use
corruptConnection(String, String)for IP-only tracking.- Parameters:
hash- Router hash (non-null, must exist in local netdb)version- router version info (may be null, falls back to RouterInfo version)
portHopping
Record a port hopping attempt from an IP. If threshold exceeded, ban the IP.- Parameters:
ip- IP address (format: "1.2.3.4")
portHopping
Record a port hopping attempt from a peer identified by its Router hash. Looks up the RouterInfo from the local netdb to extract the peer's IP address, caps, and version for threshold tracking and full-context BanLogger output. Silently returns if the RouterInfo is not in the netdb or has no reachable address.Prefer this overload when a Router hash is available at the call site; otherwise use
portHopping(String)for IP-only tracking.- Parameters:
hash- Router hash (non-null, must exist in local netdb)
getRouterIP
Extract the first reachable IP from a RouterInfo's address list. Iterates over all published addresses and returns the host portion of the first one that has a non-null host string. This is used by the Hash-based overloads to obtain an IP for threshold tracking when the caller only has a Router hash.- Parameters:
ri- RouterInfo to extract from (null-safe)- Returns:
- the IP address string, or null if no address has a host
getRouterCount
public int getRouterCount()Number of currently banlisted routers.- Returns:
- the size of the ban map
getEntries
Get the banlist entries. For BanlistRenderer in router console. Note - may contain expired entries.- Returns:
- an unmodifiable map of router hashes to banlist entries
banlistRouter
Ban a router with default duration.- Parameters:
peer- the router hash to ban- Returns:
- true if it WAS previously on the list
banlistRouter
banlistRouter
Ban a router with default duration.- Parameters:
reasonCode- separate code so cause can contain {0} for translationpeer- the router hash to banreason- the human-readable cause of the ban, stored in the entry and shown in the console- Returns:
- true if it WAS previously on the list
banlistRouter
Ban a router on a specific transport.- Parameters:
peer- the router hash to banreason- the human-readable cause of the ban, stored in the entry and shown in the consoletransport- the transport name to restrict the ban to; null bans on every transport- Returns:
- true if it WAS previously on the list
banlistRouterForever
banlistRouterForever
Permanently ban a router.- Parameters:
peer- the router hash to banreason- the human-readable cause of the ban, stored in the entry and shown in the consolereasonCode- separate code so cause can contain {0} for translation- Returns:
- true if it WAS previously on the list
banlistRouter
Ban a router with configurable duration and transport.- Parameters:
peer- the router hash to banreason- the human-readable cause of the ban, stored in the entry and shown in the consoletransport- the transport name to restrict the ban to; null bans on every transportforever- if true, ban permanently- Returns:
- true if it WAS previously on the list
banlistRouter
private boolean banlistRouter(Hash peer, String reason, String reasonCode, String transport, boolean forever) Ban a router with automatic duration calculation.- Parameters:
peer- the router hash to banreason- the human-readable cause of the ban, stored in the entry and shown in the consolereasonCode- separate code so cause can contain {0} for translation (may be null)transport- the transport name to restrict the ban to; null bans on every transportforever- if true, ban permanently- Returns:
- true if it WAS previously on the list
banlistRouter
public boolean banlistRouter(Hash peer, String reason, String reasonCode, String transport, long expireOn) Ban a router with a specified expiration time.- Parameters:
peer- the router hash to banreason- the human-readable cause of the ban, stored in the entry and shown in the consolereasonCode- separate code so cause can contain {0} for translation (may be null)transport- the transport name to restrict the ban to; null bans on every transportexpireOn- absolute time when the ban expires, not a duration- Returns:
- true if it WAS previously on the list
- Throws:
IllegalArgumentException- if expireOn is before the earliest valid time
unbanlistRouter
Remove a router from the banlist.- Parameters:
peer- the router hash to remove from banlist
unbanlistRouter
Remove a peer from the banlist, optionally updating message history.- Parameters:
peer- the router hash to remove from banlistrealUnbanlist- if true, update message history
unbanlistRouter
unbanlistRouter
Remove a router from the banlist.- Parameters:
peer- the router hash to remove from banlistrealUnbanlist- if true, update message historytransport- the transport name whose ban to lift; null lifts the ban on every transport
isBanlisted
Check if a router is banlisted.- Parameters:
peer- the router hash to check- Returns:
- true if the router is banlisted on any transport
isBanlisted
isBanlistedForever
Check if a router is permanently banlisted.- Parameters:
peer- the router hash to check- Returns:
- true if the router is permanently banlisted
isBanlistedHostile
Check if a router is banlisted with a hostile duration (at least 1 hour).- Parameters:
peer- the router hash to check- Returns:
- true if the router is banlisted with hostile duration
getBanAge
How long the banlist has been holding a peer, in milliseconds.This is the discriminator between the two reasons a build request arrives naming a banlisted peer, which need different fixes:
- old age — the ban predates the build, so peer selection handed out a peer the banlist already held, which is a selection bug;
- young age — the ban landed while the build was in flight, so the selection was correct and only a selection-time cooldown would stop the next request repeating it.
- Parameters:
peer- the router hash to check- Returns:
- age of the standing ban in ms, or -1 if the peer is not currently banlisted or the entry predates this field
getBanCause
Reason recorded when the peer was banlisted.Diagnostic only. A rejected tunnel build says a peer was banned but not why, so a burst of rejections cannot be attributed to a cause. Without it the only way to find out which subsystem is banning peers is to add temporary logging to each caller.
- Parameters:
peer- the router hash to check- Returns:
- the recorded cause code or reason, or null when the peer is not currently banlisted or no cause was recorded