Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.i2p.router
Class Blocklist

    java.lang.Object
      net.i2p.router.Blocklist

    public class Blocklist

extends Object

Manage blocking by IP address, in a manner similar to the Shitlist, which blocks by router hash. We also try to keep the two lists in sync: if a router at a given IP is blocked, we will also shitlist it "forever" (until the next reboot). While the reverse case (blocking the IP of a router shitlisted forever) is not automatic, the transports will call add() below to block the IP, which allows the transports to terminate an inbound connection before the router ident handshake. And the on-disk blocklist can also contain router hashes to be shitlisted. So, this class maintains three separate lists: 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 needed Read 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 shitlisted, shitlist it forever, then go back to the file to get the original entry so we can add the reason to the shitlist text.

Field Summary
`(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 Summary
`Blocklist()`
`Blocklist(RouterContext context)`

Method Summary
`void` | `add(byte[] ip)`
`void` | `add(String ip)`
`void` | `disable()`
`List<byte[]>` | `getAddresses(Hash peer)` this tries to not return duplicates but I suppose it could.
`boolean` | `isBlocklisted(byte[] ip)`
`boolean` | `isBlocklisted(Hash peer)` Does the peer's IP address appear in the blocklist? If so, and it isn't shitlisted, shitlist it forever...
`boolean` | `isBlocklisted(String ip)`
`static void` | `main(String[] args)`
`void` | `renderStatusHTML(Writer out)` write directly to the stream so we don't OOM on a huge list
`void` | `shitlist(Hash peer)` We don't keep the comment field in-memory, so we have to go back out to the file to find it.
`void` | `startup()`
`static String` | `toStr(byte[] ip)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### PROP_BLOCKLIST_ENABLED

    static final String PROP_BLOCKLIST_ENABLED

See Also:
  Constant Field Values

### PROP_BLOCKLIST_DETAIL

    static final String PROP_BLOCKLIST_DETAIL

See Also:
  Constant Field Values

### PROP_BLOCKLIST_FILE

    static final String PROP_BLOCKLIST_FILE

See Also:
  Constant Field Values

### BLOCKLIST_FILE_DEFAULT

    static final String BLOCKLIST_FILE_DEFAULT

See Also:
  Constant Field Values

Constructor Detail

### Blocklist

    public Blocklist(RouterContext context)

### Blocklist

    public Blocklist()

Method Detail

### startup

    public void startup()

### disable

    public void disable()

### add

    public void add(String ip)

### add

    public void add(byte[] ip)

### getAddresses

    public List<byte[]> getAddresses(Hash peer)

  this tries to not return duplicates but I suppose it could.

### isBlocklisted

    public boolean isBlocklisted(Hash peer)

  Does the peer's IP address appear in the blocklist? If so, and it isn't shitlisted, shitlist it forever...

### isBlocklisted

    public boolean isBlocklisted(String ip)

### isBlocklisted

    public boolean isBlocklisted(byte[] ip)

### toStr

    public static String toStr(byte[] ip)

### shitlist

    public void shitlist(Hash peer)

  We don't keep the comment field in-memory, so we have to go back out to the file to find it. Put this in a job because we're looking for the actual line in the blocklist file, this could take a while.

### renderStatusHTML

    public void renderStatusHTML(Writer out)
                          throws IOException

  write directly to the stream so we don't OOM on a huge list

  Throws:
    `IOException`

### main

    public static void main(String[] args)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD