Merge pull request #2590 from lbryio/fix-upnp-external-ip-fallback

fix setting the external ip in `status` if upnp fails
This commit is contained in:
Jack Robison 2019-10-28 14:34:51 -04:00 committed by GitHub
commit 59adcfe1a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -339,7 +339,6 @@ class DHTComponent(Component):
self.external_udp_port = upnp_component.upnp_redirects.get("UDP", self.conf.udp_port) self.external_udp_port = upnp_component.upnp_redirects.get("UDP", self.conf.udp_port)
external_ip = upnp_component.external_ip external_ip = upnp_component.external_ip
if not external_ip: if not external_ip:
log.warning("UPnP component failed to get external ip")
external_ip = await utils.get_external_ip() external_ip = await utils.get_external_ip()
if not external_ip: if not external_ip:
log.warning("failed to get external ip") log.warning("failed to get external ip")
@ -577,6 +576,10 @@ class UPnPComponent(Component):
log.debug("set up upnp port redirects for gateway: %s", self.upnp.gateway.manufacturer_string) log.debug("set up upnp port redirects for gateway: %s", self.upnp.gateway.manufacturer_string)
else: else:
log.error("failed to setup upnp") log.error("failed to setup upnp")
if not self.external_ip:
self.external_ip = await utils.get_external_ip()
if self.external_ip:
log.info("detected external ip using lbry.com fallback")
if self.component_manager.analytics_manager: if self.component_manager.analytics_manager:
await self.component_manager.analytics_manager.send_upnp_setup_success_fail( await self.component_manager.analytics_manager.send_upnp_setup_success_fail(
success, await self.get_status() success, await self.get_status()