Don't fail when resolving zone transfer IP addresses since a nameserver may not have an IPv6 address

This commit is contained in:
Joshua Tauberer 2019-11-19 09:57:27 -05:00
parent 2f54f39f31
commit f6f75f6fab
1 changed files with 4 additions and 2 deletions

View File

@ -875,11 +875,13 @@ def get_secondary_dns(custom_dns, mode=None):
# This is a hostname. Before including in zone xfr lines,
# resolve to an IP address. Otherwise just return the hostname.
# It may not resolve to IPv6, so don't throw an exception if it
# doesn't.
if not hostname.startswith("xfr:"):
if mode == "xfr":
response = dns.resolver.query(hostname+'.', "A")
response = dns.resolver.query(hostname+'.', "A", raise_on_no_answer=False)
values.extend(map(str, response))
response = dns.resolver.query(hostname+'.', "AAAA")
response = dns.resolver.query(hostname+'.', "AAAA", raise_on_no_answer=False)
values.extend(map(str, response))
continue
values.append(hostname)