Browse Source

lnworker: don't query DNS for .onion hosts (fixes #9002)

master
Sander van Grieken 2 years ago
parent
commit
e0e00da004
No known key found for this signature in database
GPG Key ID: 9BCF8209EA402EBA
  1. 20
      electrum/lnworker.py

20
electrum/lnworker.py

@ -542,12 +542,20 @@ class LNWorker(Logger, EventListener, NetworkRetryManager[LNPeerAddr]):
raise ConnStringFormatError(_('Don\'t know any addresses for node:') + ' ' + node_id.hex()) raise ConnStringFormatError(_('Don\'t know any addresses for node:') + ' ' + node_id.hex())
host, port, timestamp = self.choose_preferred_address(list(addrs)) host, port, timestamp = self.choose_preferred_address(list(addrs))
port = int(port) port = int(port)
# Try DNS-resolving the host (if needed). This is simply so that
# the caller gets a nice exception if it cannot be resolved. if host.endswith('.onion'):
try: if not self.network.proxy:
await asyncio.get_running_loop().getaddrinfo(host, port) raise ConnStringFormatError(_('.onion address, but no proxy configured'))
except socket.gaierror: if not self.network.is_proxy_tor:
raise ConnStringFormatError(_('Hostname does not resolve (getaddrinfo failed)')) raise ConnStringFormatError(_('.onion address, but proxy is not a TOR proxy'))
else:
# Try DNS-resolving the host (if needed). This is simply so that
# the caller gets a nice exception if it cannot be resolved.
try:
await asyncio.get_running_loop().getaddrinfo(host, port)
except socket.gaierror:
raise ConnStringFormatError(_('Hostname does not resolve (getaddrinfo failed)'))
# add peer # add peer
peer = await self._add_peer(host, port, node_id) peer = await self._add_peer(host, port, node_id)
return peer return peer

Loading…
Cancel
Save