diff --git a/README.md b/README.md index d8dbba1..d2dcd1c 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ aioupnp --HOST=239.255.255.250:1900 --MAN=\"ssdp:discover\" --MX=1 --ST=upnp:roo ``` ### Commands - add_port_mapping | delete_port_mapping | get_external_ip | get_next_mapping | get_port_mapping_by_index | get_redirects | get_soap_commands | get_specific_port_mapping | m_search + add_port_mapping | delete_port_mapping | get_external_ip | get_next_mapping | get_port_mapping_by_index | get_redirects | debug_gateway | generate_test_data | get_specific_port_mapping | m_search ### Examples diff --git a/aioupnp/gateway.py b/aioupnp/gateway.py index 68c6dbd..6bbf48d 100644 --- a/aioupnp/gateway.py +++ b/aioupnp/gateway.py @@ -132,13 +132,15 @@ class Gateway: def debug_gateway(self) -> Dict: return { 'gateway_address': self.base_ip, - 'soap_port': self.port, - 'm_search_args': self._m_search_args, + 'gateway_descriptor': self.gateway_descriptor(), + 'gateway_xml': self._xml_response, + 'services_xml': self._service_descriptors, + 'services': {service.SCPDURL: service.as_dict() for service in self._services}, + 'm_search_args': [(k, v) for (k, v) in self._m_search_args.items()], 'reply': self._ok_packet.as_dict(), + 'soap_port': self.port, 'registered_soap_commands': self._registered_commands, 'unsupported_soap_commands': self._unsupported_actions, - 'gateway_xml': self._xml_response, - 'service_descriptors': self._service_descriptors, 'soap_requests': self._soap_requests } diff --git a/aioupnp/upnp.py b/aioupnp/upnp.py index 215aca5..f7703d7 100644 --- a/aioupnp/upnp.py +++ b/aioupnp/upnp.py @@ -182,11 +182,11 @@ class UPnP: return port @cli - async def get_soap_commands(self) -> Dict: - return { - 'supported': list(self.gateway._registered_commands.keys()), - 'unsupported': self.gateway._unsupported_actions - } + async def debug_gateway(self) -> str: + return json.dumps({ + "gateway": self.gateway.debug_gateway(), + "client_address": self.lan_address, + }, default=_encode, indent=2) @cli async def generate_test_data(self): @@ -201,7 +201,6 @@ class UPnP: print("got redirects:\n%s" % redirects) except (UPnPError, NotImplementedError): print("failed to get redirects") - try: ext_port = await self.get_next_mapping(4567, "UDP", "aioupnp test mapping") print("set up external mapping to port %i" % ext_port) @@ -217,10 +216,7 @@ class UPnP: else: device_path = os.path.join(os.getcwd(), "UNKNOWN GATEWAY") with open(device_path, "w") as f: - f.write(json.dumps({ - "gateway": self.gateway.debug_gateway(), - "client_address": self.lan_address, - }, default=_encode, indent=2)) + f.write(await self.debug_gateway()) return "Generated test data! -> %s" % device_path @classmethod