forked from I2P_Developers/i2p.i2p
* GeoIP: Fix lookups, broken in IPv6 branch
This commit is contained in:
@@ -143,6 +143,7 @@ class GeoIP {
|
||||
Long[] search = _pendingSearch.toArray(new Long[_pendingSearch.size()]);
|
||||
_pendingSearch.clear();
|
||||
if (search.length > 0) {
|
||||
Arrays.sort(search);
|
||||
String[] countries = readGeoIPFile(search);
|
||||
for (int i = 0; i < countries.length; i++) {
|
||||
if (countries[i] != null)
|
||||
@@ -155,6 +156,7 @@ class GeoIP {
|
||||
search = _pendingSearch.toArray(new Long[_pendingIPv6Search.size()]);
|
||||
_pendingIPv6Search.clear();
|
||||
if (search.length > 0) {
|
||||
Arrays.sort(search);
|
||||
String[] countries = GeoIPv6.readGeoIPFile(_context, search, _codeCache);
|
||||
for (int i = 0; i < countries.length; i++) {
|
||||
if (countries[i] != null)
|
||||
|
||||
@@ -46,6 +46,10 @@ class GeoIPv6 {
|
||||
/**
|
||||
* Lookup search items in the geoip file.
|
||||
* See below for format.
|
||||
*
|
||||
* @param search a sorted array of IPs to search
|
||||
* @return an array of country codes, same order as the search param,
|
||||
* or a zero-length array on failure
|
||||
*/
|
||||
public static String[] readGeoIPFile(I2PAppContext context, Long[] search, Map<String, String> codeCache) {
|
||||
Log log = context.logManager().getLog(GeoIPv6.class);
|
||||
@@ -62,6 +66,10 @@ class GeoIPv6 {
|
||||
/**
|
||||
* Lookup search items in the geoip file.
|
||||
* See below for format.
|
||||
*
|
||||
* @param search a sorted array of IPs to search
|
||||
* @return an array of country codes, same order as the search param,
|
||||
* or a zero-length array on failure
|
||||
*/
|
||||
private static String[] readGeoIPFile(File geoFile, Long[] search, Map<String, String> codeCache, Log log) {
|
||||
String[] rv = new String[search.length];
|
||||
|
||||
Reference in New Issue
Block a user