* GeoIP: Fix lookups, broken in IPv6 branch

This commit is contained in:
zzz
2013-07-24 12:36:36 +00:00
parent a1c724f866
commit 803d7ff282
2 changed files with 10 additions and 0 deletions

View File

@@ -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)

View File

@@ -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];