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 {
} 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) {}
......
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