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

https://db-ip.com/faq.php
This commit is contained in:
zzz
2020-02-20 15:42:22 +00:00
parent 631a082ebd
commit 2805388a4c
3 changed files with 6 additions and 2 deletions

View File

@ -84,6 +84,8 @@ public class GeoIP {
private static final boolean ENABLE_DEBIAN = !DISABLE_DEBIAN && !(SystemVersion.isWindows() || SystemVersion.isAndroid());
/** maxmind API */
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
@ -223,7 +225,7 @@ public class GeoIP {
String ipv4 = toV4(ipl);
// returns upper case or null
String uc = dbr.country(ipv4);
if (uc != null) {
if (uc != null && !uc.equals(UNKNOWN_COUNTRY_CODE2)) {
String lc = uc.toLowerCase(Locale.US);
String cached = _codeCache.get(lc);
if (cached == null)
@ -294,7 +296,7 @@ public class GeoIP {
String ipv6 = toV6(ipl);
// returns upper case or null
String uc = dbr.country(ipv6);
if (uc != null) {
if (uc != null && !uc.equals(UNKNOWN_COUNTRY_CODE2)) {
String lc = uc.toLowerCase(Locale.US);
String cached = _codeCache.get(lc);
if (cached == null)