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

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

* Addresses: Fix NPE if no interfaces found http://forum.i2p/viewtopic.php?t=6365

parent 0a4d6c0b
No related branches found
No related tags found
No related merge requests found
...@@ -75,16 +75,19 @@ public abstract class Addresses { ...@@ -75,16 +75,19 @@ public abstract class Addresses {
} catch (UnknownHostException e) {} } catch (UnknownHostException e) {}
try { try {
for(Enumeration<NetworkInterface> ifcs = NetworkInterface.getNetworkInterfaces(); ifcs.hasMoreElements();) { Enumeration<NetworkInterface> ifcs = NetworkInterface.getNetworkInterfaces();
NetworkInterface ifc = ifcs.nextElement(); if (ifcs != null) {
for(Enumeration<InetAddress> addrs = ifc.getInetAddresses(); addrs.hasMoreElements();) { while (ifcs.hasMoreElements()) {
InetAddress addr = addrs.nextElement(); NetworkInterface ifc = ifcs.nextElement();
if (addr instanceof Inet4Address) for(Enumeration<InetAddress> addrs = ifc.getInetAddresses(); addrs.hasMoreElements();) {
haveIPv4 = true; InetAddress addr = addrs.nextElement();
else if (addr instanceof Inet4Address)
haveIPv6 = true; haveIPv4 = true;
if (shouldInclude(addr, includeLocal, includeIPv6)) else
rv.add(addr.getHostAddress()); haveIPv6 = true;
if (shouldInclude(addr, includeLocal, includeIPv6))
rv.add(addr.getHostAddress());
}
} }
} }
} catch (SocketException e) {} } catch (SocketException e) {}
......
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