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

Skip to content
Snippets Groups Projects
Verified Commit 0b4fe1aa authored by zzz's avatar zzz
Browse files

Util: Improved classification of public/local IPv6 addresses

parent 1c8614bc
No related branches found
No related tags found
No related merge requests found
...@@ -273,8 +273,8 @@ public abstract class Addresses { ...@@ -273,8 +273,8 @@ public abstract class Addresses {
private static boolean shouldInclude(InetAddress ia, boolean includeSiteLocal, private static boolean shouldInclude(InetAddress ia, boolean includeSiteLocal,
boolean includeLoopbackAndWildcard, boolean includeIPv6) { boolean includeLoopbackAndWildcard, boolean includeIPv6) {
byte[] ip = ia.getAddress();
if (TEST_IPV6_ONLY) { if (TEST_IPV6_ONLY) {
byte[] ip = ia.getAddress();
if (ip.length == 4) { if (ip.length == 4) {
int i = ip[0] & 0xff; int i = ip[0] & 0xff;
if (i != 127 && if (i != 127 &&
...@@ -294,8 +294,10 @@ public abstract class Addresses { ...@@ -294,8 +294,10 @@ public abstract class Addresses {
(includeSiteLocal || (includeSiteLocal ||
((!ia.isSiteLocalAddress()) && ((!ia.isSiteLocalAddress()) &&
// disallow fc00::/8 and fd00::/8 (Unique local addresses RFC 4193) // disallow fc00::/8 and fd00::/8 (Unique local addresses RFC 4193)
// and yggdrasil
// not recognized as local by InetAddress // not recognized as local by InetAddress
(ia.getAddress().length != 16 || (ia.getAddress()[0] & 0xfe) != 0xfc))) && (ip.length != 16 ||
((ip[0] & 0xff) >= 0x20 && (ip[0] & 0xff) <= 0x3f)))) &&
// Hamachi 5/8 allocated to RIPE (30 November 2010) // Hamachi 5/8 allocated to RIPE (30 November 2010)
// Removed from TransportImpl.isPubliclyRoutable() // Removed from TransportImpl.isPubliclyRoutable()
// Check moved to here, for now, but will eventually need to // Check moved to here, for now, but will eventually need to
...@@ -303,7 +305,7 @@ public abstract class Addresses { ...@@ -303,7 +305,7 @@ public abstract class Addresses {
//(includeLocal || //(includeLocal ||
//(!ia.getHostAddress().startsWith("5."))) && //(!ia.getHostAddress().startsWith("5."))) &&
(includeIPv6 || (includeIPv6 ||
(ia instanceof Inet4Address)); ip.length == 4);
} }
/** /**
......
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