forked from I2P_Developers/i2p.i2p
GeoIP: Add unknown and Kosovo country codes for db-ip.com (ticket #2692)
https://db-ip.com/faq.php
This commit is contained in:
@ -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
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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)
|
||||||
|
Reference in New Issue
Block a user