forked from I2P_Developers/i2p.i2p
* Addresses: Fix NPE if no interfaces found http://forum.i2p/viewtopic.php?t=6365
This commit is contained in:
@ -75,16 +75,19 @@ public abstract class Addresses {
|
||||
} catch (UnknownHostException e) {}
|
||||
|
||||
try {
|
||||
for(Enumeration<NetworkInterface> ifcs = NetworkInterface.getNetworkInterfaces(); ifcs.hasMoreElements();) {
|
||||
NetworkInterface ifc = ifcs.nextElement();
|
||||
for(Enumeration<InetAddress> addrs = ifc.getInetAddresses(); addrs.hasMoreElements();) {
|
||||
InetAddress addr = addrs.nextElement();
|
||||
if (addr instanceof Inet4Address)
|
||||
haveIPv4 = true;
|
||||
else
|
||||
haveIPv6 = true;
|
||||
if (shouldInclude(addr, includeLocal, includeIPv6))
|
||||
rv.add(addr.getHostAddress());
|
||||
Enumeration<NetworkInterface> ifcs = NetworkInterface.getNetworkInterfaces();
|
||||
if (ifcs != null) {
|
||||
while (ifcs.hasMoreElements()) {
|
||||
NetworkInterface ifc = ifcs.nextElement();
|
||||
for(Enumeration<InetAddress> addrs = ifc.getInetAddresses(); addrs.hasMoreElements();) {
|
||||
InetAddress addr = addrs.nextElement();
|
||||
if (addr instanceof Inet4Address)
|
||||
haveIPv4 = true;
|
||||
else
|
||||
haveIPv6 = true;
|
||||
if (shouldInclude(addr, includeLocal, includeIPv6))
|
||||
rv.add(addr.getHostAddress());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SocketException e) {}
|
||||
|
Reference in New Issue
Block a user