lnworker: add_peer: no DNS lookup if a proxy is set, to avoid a DNS-leak
closes https://github.com/spesmilo/electrum/issues/9002
This commit is contained in:
@@ -543,14 +543,12 @@ class LNWorker(Logger, EventListener, NetworkRetryManager[LNPeerAddr]):
|
|||||||
host, port, timestamp = self.choose_preferred_address(list(addrs))
|
host, port, timestamp = self.choose_preferred_address(list(addrs))
|
||||||
port = int(port)
|
port = int(port)
|
||||||
|
|
||||||
if host.endswith('.onion'):
|
if not self.network.proxy:
|
||||||
if not self.network.proxy:
|
|
||||||
raise ConnStringFormatError(_('.onion address, but no proxy configured'))
|
|
||||||
if not self.network.is_proxy_tor:
|
|
||||||
raise ConnStringFormatError(_('.onion address, but proxy is not a TOR proxy'))
|
|
||||||
else:
|
|
||||||
# Try DNS-resolving the host (if needed). This is simply so that
|
# Try DNS-resolving the host (if needed). This is simply so that
|
||||||
# the caller gets a nice exception if it cannot be resolved.
|
# the caller gets a nice exception if it cannot be resolved.
|
||||||
|
# (we don't do the DNS lookup if a proxy is set, to avoid a DNS-leak)
|
||||||
|
if host.endswith('.onion'):
|
||||||
|
raise ConnStringFormatError(_('.onion address, but no proxy configured'))
|
||||||
try:
|
try:
|
||||||
await asyncio.get_running_loop().getaddrinfo(host, port)
|
await asyncio.get_running_loop().getaddrinfo(host, port)
|
||||||
except socket.gaierror:
|
except socket.gaierror:
|
||||||
|
|||||||
Reference in New Issue
Block a user