check registered commands

This commit is contained in:
Jack Robison 2018-10-19 15:37:57 -04:00
parent 752f603066
commit 87e9617499
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -160,6 +160,11 @@ class Gateway:
igd_args: OrderedDict = None, ssdp_socket: socket.socket = None,
soap_socket: socket.socket = None, unicast: bool = False):
ignored: set = set()
required_commands = [
'AddPortMapping',
'DeletePortMapping',
'GetExternalIPAddress'
]
while True:
if not igd_args:
m_search_args, datagram = await asyncio.wait_for(fuzzy_m_search(lan_address, gateway_address, timeout, ssdp_socket,
@ -172,6 +177,11 @@ class Gateway:
gateway = cls(datagram, m_search_args, lan_address, gateway_address)
log.debug('get gateway descriptor %s', datagram.location)
await gateway.discover_commands(soap_socket)
requirements_met = all([required in gateway._registered_commands for required in required_commands])
if not requirements_met:
log.debug("found gateway, but it does not implement required soap commands")
continue
else:
log.debug('found gateway device %s', datagram.location)
return gateway
except (asyncio.TimeoutError, UPnPError) as err: