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

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

only use valid IP for geoIP

parent d5a6ac59
No related branches found
No related tags found
No related merge requests found
......@@ -390,24 +390,40 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
RouterInfo ri = _context.netDb().lookupRouterInfoLocally(peer);
if (ri == null)
return null;
ip = getIP(ri);
ip = getValidIP(ri);
if (ip != null)
return _geoIP.get(ip);
return null;
}
/**
* Return first IP (v4 or v6) we find, any transport.
* Not validated, may be local, etc.
*/
private static byte[] getIP(RouterInfo ri) {
// Return first IP (v4 or v6) we find, any transport
// Assume IPv6 doesn't have geoIP for now
for (RouterAddress ra : ri.getAddresses()) {
byte[] rv = ra.getIP();
//if (rv != null && rv.length == 4)
if (rv != null)
return rv;
}
return null;
}
/**
* Return first valid IP (v4 or v6) we find, any transport.
* Local and other invalid IPs will not be returned.
*
* @since 0.9.18
*/
private static byte[] getValidIP(RouterInfo ri) {
for (RouterAddress ra : ri.getAddresses()) {
byte[] rv = ra.getIP();
if (rv != null && TransportUtil.isPubliclyRoutable(rv, true))
return rv;
}
return null;
}
/** full name for a country code, or the code if we don't know the name */
@Override
public String getCountryName(String c) {
......
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