Merge pull request #3356 from lbryio/propagate_external_ip_change

This commit is contained in:
Alex Grin 2021-07-19 14:12:26 -04:00 committed by GitHub
commit ac671a065b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -481,6 +481,10 @@ class UPnPComponent(Component):
log.info("external ip changed from %s to %s", self.external_ip, external_ip) log.info("external ip changed from %s to %s", self.external_ip, external_ip)
if external_ip: if external_ip:
self.external_ip = external_ip self.external_ip = external_ip
dht_component = self.component_manager.get_component(DHT_COMPONENT)
if dht_component:
dht_node = dht_component.component
dht_node.protocol.external_ip = external_ip
# assert self.external_ip is not None # TODO: handle going/starting offline # assert self.external_ip is not None # TODO: handle going/starting offline
if not self.upnp_redirects and self.upnp: # setup missing redirects if not self.upnp_redirects and self.upnp: # setup missing redirects

View file

@ -1,4 +1,5 @@
import asyncio import asyncio
import time
import unittest import unittest
import typing import typing
from lbry.testcase import AsyncioTestCase from lbry.testcase import AsyncioTestCase
@ -92,11 +93,11 @@ class TestNodePingQueueDiscover(AsyncioTestCase):
class TestTemporarilyLosingConnection(AsyncioTestCase): class TestTemporarilyLosingConnection(AsyncioTestCase):
@unittest.SkipTest TIMEOUT = None # not supported as it advances time
async def test_losing_connection(self): async def test_losing_connection(self):
async def wait_for(check_ok, insist, timeout=20): async def wait_for(check_ok, insist, timeout=20):
start = loop.time() start = time.time()
while loop.time() - start < timeout: while time.time() - start < timeout:
if check_ok(): if check_ok():
break break
await asyncio.sleep(0) await asyncio.sleep(0)