From fb34476cd7695a01b9b5617f70321b2b1f6d6677 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Thu, 18 Oct 2018 15:10:00 -0400 Subject: [PATCH] add upnp status dictionary to status response -log upnp debugging information as an error --- CHANGELOG.md | 1 + lbrynet/daemon/Components.py | 14 +++++++++++++- lbrynet/daemon/Daemon.py | 6 ++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5220e444f..4dda8bc9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ most commands. * added `address_unused` command to get existing or generate a new unused address. * added pagination support for `address_list`, `channel_list`, `claim_list_mine`, `transaction_list` and `utxo_list`. + * added `upnp` field to `status` response * removed `send_amount_to_address` command previously marked as deprecated * removed `channel_list_mine` command previously marked as deprecated * removed `get_availability` command previously marked as deprecated diff --git a/lbrynet/daemon/Components.py b/lbrynet/daemon/Components.py index f85bcde66..3c2bb95c0 100644 --- a/lbrynet/daemon/Components.py +++ b/lbrynet/daemon/Components.py @@ -718,12 +718,18 @@ class UPnPComponent(Component): else: log.info("got external ip from upnp: %s", self.external_ip) yield self._setup_redirects() - log.info("set up upnp port redirects") except Exception as err: log.warning("error trying to set up upnp: %s", err) self.external_ip = CS.get_external_ip() else: self.external_ip = CS.get_external_ip() + if self.upnp: + if not self.upnp_redirects: + log.error("failed to setup upnp, debugging infomation: %s", self.upnp.zipped_debugging_info) + else: + log.info("set up upnp port redirects for gateway: %s", self.upnp.gateway.manufacturer_string) + else: + log.error("failed to setup upnp") def stop(self): return defer.DeferredList( @@ -731,6 +737,12 @@ class UPnPComponent(Component): for protocol, port in self.upnp_redirects.items()] ) + def get_status(self): + return { + 'redirects': self.upnp_redirects, + 'gateway': '' if not self.upnp else self.upnp.gateway.manufacturer_string, + } + class ExchangeRateManagerComponent(Component): component_name = EXCHANGE_RATE_MANAGER_COMPONENT diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index 3e1c033fd..6738e78c2 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -771,6 +771,12 @@ class Daemon(AuthJSONRPCServer): }, 'file_manager': { 'managed_files': (int) count of files in the file manager, + }, + 'upnp': { + 'redirects': { + : (int) external_port, + }, + 'gateway': (str) manufacturer and model, } } """