I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 2805388a authored by zzz's avatar zzz
Browse files

GeoIP: Add unknown and Kosovo country codes for db-ip.com (ticket #2692)

parent 631a082e
No related branches found
No related tags found
No related merge requests found
...@@ -248,6 +248,7 @@ VN,AS ...@@ -248,6 +248,7 @@ VN,AS
VU,OC VU,OC
WF,OC WF,OC
WS,OC WS,OC
XK,EU
YE,AS YE,AS
YT,AF YT,AF
ZA,AF ZA,AF
......
...@@ -254,6 +254,7 @@ VN,Vietnam ...@@ -254,6 +254,7 @@ VN,Vietnam
VU,Vanuatu VU,Vanuatu
WF,Wallis and Futuna WF,Wallis and Futuna
WS,Samoa WS,Samoa
XK,Kosovo
YE,Yemen YE,Yemen
YT,Mayotte YT,Mayotte
ZA,South Africa ZA,South Africa
......
...@@ -84,6 +84,8 @@ public class GeoIP { ...@@ -84,6 +84,8 @@ public class GeoIP {
private static final boolean ENABLE_DEBIAN = !DISABLE_DEBIAN && !(SystemVersion.isWindows() || SystemVersion.isAndroid()); private static final boolean ENABLE_DEBIAN = !DISABLE_DEBIAN && !(SystemVersion.isWindows() || SystemVersion.isAndroid());
/** maxmind API */ /** maxmind API */
private static final String UNKNOWN_COUNTRY_CODE = "--"; private static final String UNKNOWN_COUNTRY_CODE = "--";
/** db-ip.com https://db-ip.com/faq.php */
private static final String UNKNOWN_COUNTRY_CODE2 = "ZZ";
/** /**
* @param context RouterContext in production, I2PAppContext for testing only * @param context RouterContext in production, I2PAppContext for testing only
...@@ -223,7 +225,7 @@ public class GeoIP { ...@@ -223,7 +225,7 @@ public class GeoIP {
String ipv4 = toV4(ipl); String ipv4 = toV4(ipl);
// returns upper case or null // returns upper case or null
String uc = dbr.country(ipv4); String uc = dbr.country(ipv4);
if (uc != null) { if (uc != null && !uc.equals(UNKNOWN_COUNTRY_CODE2)) {
String lc = uc.toLowerCase(Locale.US); String lc = uc.toLowerCase(Locale.US);
String cached = _codeCache.get(lc); String cached = _codeCache.get(lc);
if (cached == null) if (cached == null)
...@@ -294,7 +296,7 @@ public class GeoIP { ...@@ -294,7 +296,7 @@ public class GeoIP {
String ipv6 = toV6(ipl); String ipv6 = toV6(ipl);
// returns upper case or null // returns upper case or null
String uc = dbr.country(ipv6); String uc = dbr.country(ipv6);
if (uc != null) { if (uc != null && !uc.equals(UNKNOWN_COUNTRY_CODE2)) {
String lc = uc.toLowerCase(Locale.US); String lc = uc.toLowerCase(Locale.US);
String cached = _codeCache.get(lc); String cached = _codeCache.get(lc);
if (cached == null) if (cached == null)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment