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

Skip to content
Snippets Groups Projects
Commit 803d7ff2 authored by zzz's avatar zzz
Browse files

* GeoIP: Fix lookups, broken in IPv6 branch

parent a1c724f8
No related branches found
No related tags found
No related merge requests found
...@@ -143,6 +143,7 @@ class GeoIP { ...@@ -143,6 +143,7 @@ class GeoIP {
Long[] search = _pendingSearch.toArray(new Long[_pendingSearch.size()]); Long[] search = _pendingSearch.toArray(new Long[_pendingSearch.size()]);
_pendingSearch.clear(); _pendingSearch.clear();
if (search.length > 0) { if (search.length > 0) {
Arrays.sort(search);
String[] countries = readGeoIPFile(search); String[] countries = readGeoIPFile(search);
for (int i = 0; i < countries.length; i++) { for (int i = 0; i < countries.length; i++) {
if (countries[i] != null) if (countries[i] != null)
...@@ -155,6 +156,7 @@ class GeoIP { ...@@ -155,6 +156,7 @@ class GeoIP {
search = _pendingSearch.toArray(new Long[_pendingIPv6Search.size()]); search = _pendingSearch.toArray(new Long[_pendingIPv6Search.size()]);
_pendingIPv6Search.clear(); _pendingIPv6Search.clear();
if (search.length > 0) { if (search.length > 0) {
Arrays.sort(search);
String[] countries = GeoIPv6.readGeoIPFile(_context, search, _codeCache); String[] countries = GeoIPv6.readGeoIPFile(_context, search, _codeCache);
for (int i = 0; i < countries.length; i++) { for (int i = 0; i < countries.length; i++) {
if (countries[i] != null) if (countries[i] != null)
......
...@@ -46,6 +46,10 @@ class GeoIPv6 { ...@@ -46,6 +46,10 @@ class GeoIPv6 {
/** /**
* Lookup search items in the geoip file. * Lookup search items in the geoip file.
* See below for format. * 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) { public static String[] readGeoIPFile(I2PAppContext context, Long[] search, Map<String, String> codeCache) {
Log log = context.logManager().getLog(GeoIPv6.class); Log log = context.logManager().getLog(GeoIPv6.class);
...@@ -62,6 +66,10 @@ class GeoIPv6 { ...@@ -62,6 +66,10 @@ class GeoIPv6 {
/** /**
* Lookup search items in the geoip file. * Lookup search items in the geoip file.
* See below for format. * 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) { private static String[] readGeoIPFile(File geoFile, Long[] search, Map<String, String> codeCache, Log log) {
String[] rv = new String[search.length]; String[] rv = new String[search.length];
......
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