electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit c4fb58cd74089d446f3e1b941909cdca150dd889
parent 1cfac928f9c6f0dec327c261afef26486e226c20
Author: SomberNight <somber.night@protonmail.com>
Date:   Tue, 26 Mar 2019 03:07:11 +0100

windows DNS resolution: follow-up 9b0773cf2bf139eafe4a828c8964461d34ea9e23

related: #5176, #4421

prev was failing on systems where
IPv6 is not available but DNS can resolve AAAA records
(my artificial test environment with IPv6 disabled was also filtering AAAA DNS)

Diffstat:
Melectrum/network.py | 17+++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/electrum/network.py b/electrum/network.py @@ -526,10 +526,11 @@ class Network(PrintError): return False return True def resolve_with_dnspython(host): + addrs = [] # try IPv6 try: answers = dns.resolver.query(host, dns.rdatatype.AAAA) - return str(answers[0]) + addrs += [str(answer) for answer in answers] except dns.exception.DNSException as e: pass except BaseException as e: @@ -537,7 +538,7 @@ class Network(PrintError): # try IPv4 try: answers = dns.resolver.query(host, dns.rdatatype.A) - return str(answers[0]) + addrs += [str(answer) for answer in answers] except dns.exception.DNSException as e: # dns failed for some reason, e.g. dns.resolver.NXDOMAIN # this is normal. Simply report back failure: @@ -545,12 +546,16 @@ class Network(PrintError): except BaseException as e: # Possibly internal error in dnspython :( see #4483 print_error(f'dnspython failed to resolve dns (A) with error: {e}') + if addrs: + return addrs # Fall back to original socket.getaddrinfo to resolve dns. - return host - addr = host + return [host] + addrs = [host] if needs_dns_resolving(host): - addr = resolve_with_dnspython(host) - return socket._getaddrinfo(addr, *args, **kwargs) + addrs = resolve_with_dnspython(host) + list_of_list_of_socketinfos = [socket._getaddrinfo(addr, *args, **kwargs) for addr in addrs] + list_of_socketinfos = [item for lst in list_of_list_of_socketinfos for item in lst] + return list_of_socketinfos @log_exceptions async def set_parameters(self, net_params: NetworkParameters):