forked from I2P_Developers/i2p.i2p
strip scope from returned address strings
This commit is contained in:
@ -95,7 +95,7 @@ public abstract class Addresses {
|
||||
haveIPv6 = true;
|
||||
if (shouldInclude(allMyIps[i], includeSiteLocal,
|
||||
includeLoopbackAndWildcard, includeIPv6))
|
||||
rv.add(allMyIps[i].getHostAddress());
|
||||
rv.add(stripScope(allMyIps[i].getHostAddress()));
|
||||
}
|
||||
}
|
||||
} catch (UnknownHostException e) {}
|
||||
@ -113,7 +113,7 @@ public abstract class Addresses {
|
||||
haveIPv6 = true;
|
||||
if (shouldInclude(addr, includeSiteLocal,
|
||||
includeLoopbackAndWildcard, includeIPv6))
|
||||
rv.add(addr.getHostAddress());
|
||||
rv.add(stripScope(addr.getHostAddress()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -128,6 +128,17 @@ public abstract class Addresses {
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip the trailing "%nn" from Inet6Address.getHostAddress()
|
||||
* @since IPv6
|
||||
*/
|
||||
private static String stripScope(String ip) {
|
||||
int pct = ip.indexOf("%");
|
||||
if (pct > 0)
|
||||
ip = ip.substring(0, pct);
|
||||
return ip;
|
||||
}
|
||||
|
||||
private static boolean shouldInclude(InetAddress ia, boolean includeSiteLocal,
|
||||
boolean includeLoopbackAndWildcard, boolean includeIPv6) {
|
||||
return
|
||||
|
Reference in New Issue
Block a user