public class Blocklist extends Object
1) The list of IP ranges, read in from a file at startup 2) The list of hashes, read in from the same file 3) A list of single IPs, initially empty, added to as neededRead in the IP blocklist from a file, store it in-memory as efficiently as we can, and perform tests against it as requested. When queried for a peer that is blocklisted but isn't banlisted, banlist it forever, then go back to the file to get the original entry so we can add the reason to the banlist text. On-disk blocklist supports IPv4 only. In-memory supports both IPv4 and IPv6.
Modifier and Type | Field and Description |
---|---|
(package private) static String |
BLOCKLIST_FILE_DEFAULT |
(package private) static String |
PROP_BLOCKLIST_DETAIL |
(package private) static String |
PROP_BLOCKLIST_ENABLED |
(package private) static String |
PROP_BLOCKLIST_FILE |
Constructor and Description |
---|
Blocklist(RouterContext context) |
Modifier and Type | Method and Description |
---|---|
void |
add(byte[] ip)
Maintain a simple in-memory single-IP blocklist
This is used for new additions, NOT for the main list
of IP ranges read in from the file.
|
void |
add(String ip)
Maintain a simple in-memory single-IP blocklist
This is used for new additions, NOT for the main list
of IP ranges read in from the file.
|
void |
disable() |
boolean |
isBlocklisted(byte[] ip)
calling this externally won't banlist the peer, this is just an IP check
|
boolean |
isBlocklisted(Hash peer)
Does the peer's IP address appear in the blocklist?
If so, and it isn't banlisted, banlist it forever...
|
boolean |
isBlocklisted(String ip)
calling this externally won't banlist the peer, this is just an IP check
|
void |
renderStatusHTML(Writer out)
Write directly to the stream so we don't OOM on a huge list.
|
void |
startup() |
static final String PROP_BLOCKLIST_ENABLED
static final String PROP_BLOCKLIST_DETAIL
static final String PROP_BLOCKLIST_FILE
static final String BLOCKLIST_FILE_DEFAULT
public Blocklist(RouterContext context)
public void startup()
public void disable()
public void add(String ip)
ip
- IPv4 or IPv6public void add(byte[] ip)
ip
- IPv4 or IPv6public boolean isBlocklisted(Hash peer)
public boolean isBlocklisted(String ip)
ip
- IPv4 or IPv6public boolean isBlocklisted(byte[] ip)
ip
- IPv4 or IPv6public void renderStatusHTML(Writer out) throws IOException
IOException