Skip to content

Commit

Permalink
Add better exception handling for the ipv6 ssdp multicast
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusFreke committed Apr 11, 2020
1 parent 1b86f03 commit a4adba2
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/main/java/org/jf/fusionIdea/run/FusionScriptState.java
Expand Up @@ -248,25 +248,36 @@ private MulticastSocket sendIpv6SSDPRequest() {
MulticastSocket socket = new MulticastSocket(0);
socket.setLoopbackMode(/* disabled= */ false);

boolean success = false;
for (NetworkInterface netint : Collections.list(nets)) {
if (netint.supportsMulticast()) {
boolean hasIpV6 = false;
for (InetAddress address : Collections.list(netint.getInetAddresses())) {
if (address instanceof Inet6Address) {
hasIpV6 = true;
break;
try {
if (netint.supportsMulticast()) {
boolean hasIpV6 = false;
for (InetAddress address : Collections.list(netint.getInetAddresses())) {
if (address instanceof Inet6Address) {
hasIpV6 = true;
break;
}
}
if (hasIpV6) {
socket.setNetworkInterface(netint);
socket.send(new DatagramPacket(SEARCH_MESSAGE, SEARCH_MESSAGE.length, multicastAddress));
success = true;
}
}
if (hasIpV6) {
socket.setNetworkInterface(netint);
socket.send(new DatagramPacket(SEARCH_MESSAGE, SEARCH_MESSAGE.length, multicastAddress));
}
} catch (IOException ex) {
FusionIdeaPlugin.log.debug("ipv6 multicast failed on " + netint.getName(), ex);
}
}

if (!success) {
FusionIdeaPlugin.log.error("Couldn't send ipv6 ssdp packet on any interface");
return null;
}

return socket;
} catch (IOException ex) {
FusionIdeaPlugin.log.debug("ipv6 ssdp failed");
FusionIdeaPlugin.log.debug("ipv6 ssdp failed", ex);
return null;
}
}
Expand Down

0 comments on commit a4adba2

Please sign in to comment.