Needed to not fix the multicast socket to a specific ip address

This is when upnp use interface only
This commit is contained in:
BWS Systems
2020-03-26 15:25:10 -04:00
parent c376253488
commit f5e100667e

View File

@@ -90,10 +90,11 @@ public class UpnpListener {
} }
try { try {
if (useUpnpIface) // This commented out code does not work... leave for review
upnpMulticastSocket = new MulticastSocket( // if (useUpnpIface)
new InetSocketAddress(upnpConfigIP, Configuration.UPNP_DISCOVERY_PORT)); // upnpMulticastSocket = new MulticastSocket(
else // new InetSocketAddress(upnpConfigIP, Configuration.UPNP_DISCOVERY_PORT));
// else
upnpMulticastSocket = new MulticastSocket(Configuration.UPNP_DISCOVERY_PORT); upnpMulticastSocket = new MulticastSocket(Configuration.UPNP_DISCOVERY_PORT);
} catch (IOException e) { } catch (IOException e) {
log.error("Upnp Discovery Port is in use, or restricted by admin (try running with sudo or admin privs): " log.error("Upnp Discovery Port is in use, or restricted by admin (try running with sudo or admin privs): "
@@ -136,7 +137,7 @@ public class UpnpListener {
if (traceupnp) if (traceupnp)
log.info("Traceupnp: Interface: " + name + " valid usable IP address: " + addr); log.info("Traceupnp: Interface: " + name + " valid usable IP address: " + addr);
IPsPerNic++; IPsPerNic++;
} else if (addr.getHostAddress().equals(upnpConfigIP)) { } else if (useUpnpIface && (addr.getHostAddress().equals(upnpConfigIP) || name.equals("lo"))) {
if (traceupnp) if (traceupnp)
log.info("Traceupnp: Interface: " + name + " matches upnp config address of IP address: " log.info("Traceupnp: Interface: " + name + " matches upnp config address of IP address: "
+ addr); + addr);
@@ -266,6 +267,7 @@ public class UpnpListener {
protected boolean isSSDPDiscovery(DatagramPacket packet) { protected boolean isSSDPDiscovery(DatagramPacket packet) {
// Only respond to discover request for strict upnp form // Only respond to discover request for strict upnp form
String packetString = new String(packet.getData(), 0, packet.getLength()); String packetString = new String(packet.getData(), 0, packet.getLength());
// log.info("Packet string <<<" + packetString + ">>>");
if (packetString != null && packetString.startsWith("M-SEARCH * HTTP/1.1") if (packetString != null && packetString.startsWith("M-SEARCH * HTTP/1.1")
&& packetString.contains("\"ssdp:discover\"")) { && packetString.contains("\"ssdp:discover\"")) {
if ((packetString.contains("ST: urn:schemas-upnp-org:device:basic:1") if ((packetString.contains("ST: urn:schemas-upnp-org:device:basic:1")