resovle reflector IP before adding it

This commit is contained in:
Victor Shyba 2019-02-15 18:56:57 -03:00
parent cfbf0dbe0f
commit 5c217f1544

View file

@ -74,19 +74,21 @@ class StreamDownloader(StreamAssembler):
def add_fixed_peers(self):
async def _add_fixed_peers():
self.peer_queue.put_nowait([
KademliaPeer(self.loop, address=(await resolve_host(url, port + 1, proto='tcp')), tcp_port=port + 1)
addresses = [
(await resolve_host(url, port + 1, proto='tcp'), port)
for url, port in self.config.reflector_servers
])
]
delay = self.config.fixed_peer_delay if (
'dht' not in self.config.components_to_skip
and self.node and len(self.node.protocol.routing_table.get_peers())
) else 0.0
self.loop.call_later(delay, lambda:
self.peer_queue.put_nowait([
KademliaPeer(self.loop, address=address, tcp_port=port + 1)
for address, port in addresses
]))
if self.config.reflector_servers:
self.fixed_peers_handle = self.loop.call_later(
self.config.fixed_peer_delay if (
'dht' not in self.config.components_to_skip
and self.node
and len(self.node.protocol.routing_table.get_peers())
) else 0.0,
lambda: self.loop.create_task(_add_fixed_peers())
)
self.loop.create_task(_add_fixed_peers())
def download(self, node: typing.Optional['Node'] = None):
self.node = node