Package net.i2p.router.transport
Class GeoIP
java.lang.Object
net.i2p.router.transport.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)
- Author:
- zzz
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(byte[] ip) Add to the list needing lookup Public for BundleRouterInfosvoid
Add to the list needing lookup Public for BundleRouterInfosvoid
Blocking lookup of all pending IPs.Get the country for a country code Public for BundleRouterInfos(package private) String
get
(byte[] ip) Get the country for an IP from the cache.Get the country for an IP from the cache.Get the country code mapstatic void
(package private) static void
notifyVersion
(I2PAppContext ctx, String subtype, long version) Tell the update manager.void
shutdown()
-
Field Details
-
PROP_GEOIP_ENABLED
- See Also:
-
PROP_GEOIP_DIR
- See Also:
-
GEOIP_DIR_DEFAULT
- See Also:
-
GEOIP_FILE_DEFAULT
- See Also:
-
GEOIP2_FILE_DEFAULT
- See Also:
-
COUNTRY_FILE_DEFAULT
- See Also:
-
PROP_IP_COUNTRY
- See Also:
-
PROP_DEBIAN_GEOIP
- See Also:
-
PROP_DEBIAN_GEOIPV6
- See Also:
-
-
Constructor Details
-
GeoIP
- Parameters:
context
- RouterContext in production, I2PAppContext for testing only
-
-
Method Details
-
shutdown
public void shutdown()- Since:
- 0.9.3
-
blockingLookup
public void blockingLookup()Blocking lookup of all pending IPs. Results will be added to the table and available via get() after completion. Public for BundleRouterInfos -
notifyVersion
Tell the update manager.- Since:
- 0.9.45
-
add
Add to the list needing lookup Public for BundleRouterInfos- Parameters:
ip
- IPv4 or IPv6
-
add
public void add(byte[] ip) Add to the list needing lookup Public for BundleRouterInfos- Parameters:
ip
- IPv4 or IPv6
-
get
Get the country for an IP from the cache. Public for BundleRouterInfos- Parameters:
ip
- IPv4 or IPv6- Returns:
- lower-case code, generally two letters, or null.
-
get
Get the country for an IP from the cache.- Parameters:
ip
- IPv4 or IPv6- Returns:
- lower-case code, generally two letters, or null.
-
fullName
Get the country for a country code Public for BundleRouterInfos- Parameters:
code
- two-letter lower case code- Returns:
- untranslated name or null
-
getCountries
Get the country code map- Returns:
- Map of two-letter lower case code to untranslated country name, unmodifiable
- Since:
- 0.9.53
-
main
-