tdnspython: fix deprecation warnings when using dnspython 2.0 - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 8c5601a17263d5e29aeba2b83facd5386d3baed1 DIR parent 6273b4808fc6748d1957e837c736665ce70b5295 HTML Author: SomberNight <somber.night@protonmail.com> Date: Wed, 9 Dec 2020 09:04:04 +0100 dnspython: fix deprecation warnings when using dnspython 2.0 related: #6828 Diffstat: M electrum/dns_hacks.py | 4 ++-- M electrum/dnssec.py | 3 +-- M electrum/lnworker.py | 2 +- M electrum/util.py | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) --- DIR diff --git a/electrum/dns_hacks.py b/electrum/dns_hacks.py t@@ -69,8 +69,8 @@ def _fast_getaddrinfo(host, *args, **kwargs): addrs = [] expected_errors = (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer, concurrent.futures.CancelledError, concurrent.futures.TimeoutError) - ipv6_fut = _dns_threads_executor.submit(dns.resolver.query, host, dns.rdatatype.AAAA) - ipv4_fut = _dns_threads_executor.submit(dns.resolver.query, host, dns.rdatatype.A) + ipv6_fut = _dns_threads_executor.submit(dns.resolver.resolve, host, dns.rdatatype.AAAA) + ipv4_fut = _dns_threads_executor.submit(dns.resolver.resolve, host, dns.rdatatype.A) # try IPv6 try: answers = ipv6_fut.result() DIR diff --git a/electrum/dnssec.py b/electrum/dnssec.py t@@ -151,7 +151,6 @@ def query(url, rtype): validated = True except BaseException as e: _logger.info(f"DNSSEC error: {repr(e)}") - resolver = dns.resolver.get_default_resolver() - out = resolver.query(url, rtype) + out = dns.resolver.resolve(url, rtype) validated = False return out, validated DIR diff --git a/electrum/lnworker.py b/electrum/lnworker.py t@@ -382,7 +382,7 @@ class LNWorker(Logger, NetworkRetryManager[LNPeerAddr]): for srv_ans in srv_answers: try: # note: this might block for several seconds - answers = dns.resolver.query(srv_ans['host']) + answers = dns.resolver.resolve(srv_ans['host']) except dns.exception.DNSException as e: self.logger.info(f'failed querying (2) dns seed "{dns_seed}" for ln peers: {repr(e)}') continue DIR diff --git a/electrum/util.py b/electrum/util.py t@@ -1295,7 +1295,7 @@ def list_enabled_bits(x: int) -> Sequence[int]: def resolve_dns_srv(host: str): - srv_records = dns.resolver.query(host, 'SRV') + srv_records = dns.resolver.resolve(host, 'SRV') # priority: prefer lower # weight: tie breaker; prefer higher srv_records = sorted(srv_records, key=lambda x: (x.priority, -x.weight))