net.i2p.router.transport
Class GeoIP
java.lang.Object
net.i2p.router.transport.GeoIP
public class GeoIP
- extends java.lang.Object
Manage geoip lookup in a file with the Tor geoip format.
The lookup is expensive, so a lookup is queued with add().
The actual lookup of multiple IPs is fired with lookup().
To get a country for an IP, use get() which returns a lower-case,
generally two-letter country code or null.
Everything here uses longs, since Java is signed-only, the file is
sorted by unsigned, and we don't store the table in memory
(unlike in Blocklist.java, where it's in-memory so we want to be
space-efficient)
- Author:
- zzz
Method Summary |
void |
add(byte[] ip)
|
void |
add(java.lang.String ip)
Add to the list needing lookup |
void |
blockingLookup()
Blocking lookup of all pending IPs. |
java.lang.String |
fullName(java.lang.String code)
|
java.lang.String |
get(byte[] ip)
|
java.lang.String |
get(java.lang.String ip)
Get the country for an IP |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PROP_GEOIP_ENABLED
static final java.lang.String PROP_GEOIP_ENABLED
- See Also:
- Constant Field Values
GEOIP_DIR_DEFAULT
static final java.lang.String GEOIP_DIR_DEFAULT
- See Also:
- Constant Field Values
GEOIP_FILE_DEFAULT
static final java.lang.String GEOIP_FILE_DEFAULT
- See Also:
- Constant Field Values
COUNTRY_FILE_DEFAULT
static final java.lang.String COUNTRY_FILE_DEFAULT
- See Also:
- Constant Field Values
PROP_IP_COUNTRY
public static final java.lang.String PROP_IP_COUNTRY
- See Also:
- Constant Field Values
GeoIP
public GeoIP(RouterContext context)
blockingLookup
public void blockingLookup()
- Blocking lookup of all pending IPs.
Results will be added to the table and available via get() after completion.
add
public void add(java.lang.String ip)
- Add to the list needing lookup
add
public void add(byte[] ip)
get
public java.lang.String get(java.lang.String ip)
- Get the country for an IP
- Returns:
- lower-case code, generally two letters.
get
public java.lang.String get(byte[] ip)
fullName
public java.lang.String fullName(java.lang.String code)