resovle reflector IP before adding it
This commit is contained in:
parent
cfbf0dbe0f
commit
5c217f1544
1 changed files with 13 additions and 11 deletions
|
@ -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
|
||||
])
|
||||
if self.config.reflector_servers:
|
||||
self.fixed_peers_handle = self.loop.call_later(
|
||||
self.config.fixed_peer_delay if (
|
||||
]
|
||||
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,
|
||||
lambda: self.loop.create_task(_add_fixed_peers())
|
||||
)
|
||||
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.loop.create_task(_add_fixed_peers())
|
||||
|
||||
def download(self, node: typing.Optional['Node'] = None):
|
||||
self.node = node
|
||||
|
|
Loading…
Reference in a new issue