Browse Source

dnspython: fix deprecation warnings when using dnspython 2.0

related: #6828
patch-4
SomberNight 4 years ago
parent
commit
8c5601a172
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 4
      electrum/dns_hacks.py
  2. 3
      electrum/dnssec.py
  3. 2
      electrum/lnworker.py
  4. 2
      electrum/util.py

4
electrum/dns_hacks.py

@ -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()

3
electrum/dnssec.py

@ -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

2
electrum/lnworker.py

@ -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

2
electrum/util.py

@ -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))

Loading…
Cancel
Save