|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.router.transport.GeoIP
class GeoIP
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)
Field Summary | |
---|---|
(package private) static String |
COUNTRY_FILE_DEFAULT
|
(package private) static String |
GEOIP_DIR_DEFAULT
|
(package private) static String |
GEOIP_FILE_DEFAULT
|
(package private) static String |
PROP_GEOIP_ENABLED
|
static String |
PROP_IP_COUNTRY
|
Constructor Summary | |
---|---|
GeoIP(RouterContext context)
|
Method Summary | |
---|---|
void |
add(byte[] ip)
|
void |
add(String ip)
Add to the list needing lookup |
void |
blockingLookup()
Blocking lookup of all pending IPs. |
String |
fullName(String code)
Get the country for a country code |
String |
get(byte[] ip)
Get the country for an IP from the cache. |
String |
get(String ip)
Get the country for an IP from the cache. |
void |
shutdown()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final String PROP_GEOIP_ENABLED
static final String GEOIP_DIR_DEFAULT
static final String GEOIP_FILE_DEFAULT
static final String COUNTRY_FILE_DEFAULT
public static final String PROP_IP_COUNTRY
Constructor Detail |
---|
public GeoIP(RouterContext context)
Method Detail |
---|
public void shutdown()
public void blockingLookup()
public void add(String ip)
public void add(byte[] ip)
public String get(String ip)
public String get(byte[] ip)
public String fullName(String code)
code
- two-letter lower case code
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |