public class Banlist extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Banlist.Entry
Entry representing a banned peer with expiration and reason information
|
| Modifier and Type | Field and Description |
|---|---|
static long |
BANLIST_DURATION_FOREVER
Permanent ban duration (will be rounded down to 180 days on console).
|
static long |
BANLIST_DURATION_MAX
Maximum ban duration for transient bans.
|
static long |
BANLIST_DURATION_MS
Default ban duration for transient bans.
|
static long |
BANLIST_DURATION_NO_NETWORK
Buggy i2pd fork
|
static long |
BANLIST_DURATION_PARTIAL
Default ban duration for transport-specific bans.
|
static long |
BANLIST_DURATION_PRIVATE
Ban duration for private IP addresses.
|
static Hash |
HASH_ZERORI
hash of 387 zeros
|
| Constructor and Description |
|---|
Banlist(RouterContext context)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
Map<Hash,Banlist.Entry> |
getEntries()
Get the banlist entries.
|
int |
getRouterCount()
Get the number of currently banlisted routers.
|
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).
|
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_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 boolean banlistRouter(Hash peer)
peer - the router hash to banpublic boolean banlistRouter(Hash peer, String reason)
peer - the router hash to banreason - the reason for the ban (may be null)public boolean banlistRouter(Hash peer, String reason, String transport)
peer - the router hash to banreason - the reason for the ban (may be null)transport - the transport to ban (may be null for all transports)public boolean banlistRouter(Hash peer, String reason, String transport, boolean forever)
peer - the router hash to banreason - the reason for the ban (may be null)transport - the transport to ban (may be null for all transports)forever - if true, ban permanentlypublic boolean banlistRouter(Hash peer, String reason, String reasonCode, String transport, long expireOn)
peer - the router hash to banreason - the reason for the ban (may be null)reasonCode - separate code so cause can contain {0} for translation (may be null)transport - the transport to ban (may be null for all transports)expireOn - 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 reason for the ban (may be null)public boolean banlistRouterForever(Hash peer, String reason)
peer - the router hash to banreason - the reason for the ban (may be null)public boolean banlistRouterForever(Hash peer, String reason, String reasonCode)
peer - the router hash to banreason - the reason for the ban (may be null)reasonCode - separate code so cause can contain {0} for translationpublic Map<Hash,Banlist.Entry> getEntries()
public int getRouterCount()
public boolean isBanlisted(Hash peer)
peer - the router hash to checkpublic boolean isBanlisted(Hash peer, String transport)
peer - the router hash to checktransport - the transport to check (may be null)public boolean isBanlistedForever(Hash peer)
peer - the router hash to checkpublic boolean isBanlistedHostile(Hash peer)
peer - the router hash to checkpublic void unbanlistRouter(Hash peer)
peer - the router hash to remove from banlist