This commit is contained in:
Jack Robison 2018-10-08 18:46:22 -04:00
parent 0c9ee7794e
commit 2581b79db5
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 6 additions and 5 deletions

View file

@ -30,16 +30,19 @@ class SSDPProtocol(MulticastProtocol):
man=man, mx=1
)
log.debug("sending packet to %s:%i: %s", address, SSDP_PORT, packet)
print(packet.encode())
self.transport.sendto(packet.encode().encode(), (address, SSDP_PORT))
async def m_search(self, address, timeout: int = 1, service=UPNP_ORG_IGD) -> SSDPDatagram:
if (address, service) in self.discover_callbacks:
return self.discover_callbacks[(address, service)]
# D-Link, Cisco
self.send_m_search_packet(service, address, "\"%s\"" % SSDP_DISCOVER)
# D-Link works with both
# DD-WRT
# Cisco only works with quotes
self.send_m_search_packet(service, address, '"%s"' % SSDP_DISCOVER)
# DD-WRT only works without quotes
self.send_m_search_packet(service, address, SSDP_DISCOVER)
f: Future = Future()

View file

@ -112,8 +112,6 @@ class SSDPDatagram(object):
raise UPnPError("required field for {} is missing: {}".format(self._packet_type, attr_name))
if attr_name == 'mx':
value = str(attr)
elif attr_name == 'man':
value = "\"%s\"" % attr
else:
value = attr
lines.append("{}: {}".format(attr_name.upper(), value))