mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-12-24 07:37:04 +00:00
more resilient nameserver usage in query dns
This commit is contained in:
parent
0058583913
commit
b051137f36
@ -563,7 +563,7 @@ def check_dns_zone(domain, env, output, dns_zonefiles):
|
|||||||
# Choose the first IP if nameserver returns multiple
|
# Choose the first IP if nameserver returns multiple
|
||||||
ns_ip = ns_ips.split('; ')[0]
|
ns_ip = ns_ips.split('; ')[0]
|
||||||
|
|
||||||
if ns_ip == '[Not Set]':
|
if ns_ip in {'[Not Set]', '[timeout]'}:
|
||||||
output.print_error("Secondary nameserver %s could not be resolved correctly. (dns result: %s used %s)" % (ns, ns_ips, ns_ip))
|
output.print_error("Secondary nameserver %s could not be resolved correctly. (dns result: %s used %s)" % (ns, ns_ips, ns_ip))
|
||||||
else:
|
else:
|
||||||
# Now query it to see what it says about this domain.
|
# Now query it to see what it says about this domain.
|
||||||
@ -809,9 +809,14 @@ def query_dns(qname, rtype, nxdomain='[Not Set]', at=None, as_list=False, retry=
|
|||||||
# running unbound server), or if the 'at' argument is specified, use that host
|
# running unbound server), or if the 'at' argument is specified, use that host
|
||||||
# as the nameserver.
|
# as the nameserver.
|
||||||
resolver = dns.resolver.get_default_resolver()
|
resolver = dns.resolver.get_default_resolver()
|
||||||
|
|
||||||
|
# Make sure at is not a string that cannot be used as a nameserver
|
||||||
if at:
|
if at:
|
||||||
|
if at not in {'[Not set]', '[timeout]'}:
|
||||||
resolver = dns.resolver.Resolver()
|
resolver = dns.resolver.Resolver()
|
||||||
resolver.nameservers = [at]
|
resolver.nameservers = [at]
|
||||||
|
else:
|
||||||
|
logging.error("at not set to a usable nameserver, %s", at)
|
||||||
|
|
||||||
# Set a timeout so that a non-responsive server doesn't hold us back.
|
# Set a timeout so that a non-responsive server doesn't hold us back.
|
||||||
resolver.timeout = 5
|
resolver.timeout = 5
|
||||||
|
Loading…
Reference in New Issue
Block a user