mail-in-a-box / mailinabox

Mail-in-a-Box helps individuals take back control of their email by defining a one-click, easy-to-deploy SMTP+everything else server: a mail server in a box.

Home Page:https://mailinabox.email/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DNS timeout passing empty string causing error

julesfarrow opened this issue · comments

Receiving the following error via email once every few days since updating to v57

multiprocessing.pool.RemoteTraceback:

"""
Traceback (most recent call last):
File "/usr/local/lib/mailinabox/env/lib/python3.6/site-packages/dns/resolver.py", line 982, in nameservers
raise NotImplementedError
NotImplementedError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.6/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/usr/lib/python3.6/multiprocessing/pool.py", line 47, in starmapstar
return list(itertools.starmap(args[0], args[1]))
File "management/status_checks.py", line 380, in run_domain_checks_on_domain
check_dns_zone(domain, env, output, dns_zonefiles)
File "management/status_checks.py", line 551, in check_dns_zone
ip = query_dns(domain, "A", at=ns_ip, nxdomain=None)
File "management/status_checks.py", line 793, in query_dns
resolver.nameservers = [at]
File "/usr/local/lib/mailinabox/env/lib/python3.6/site-packages/dns/resolver.py", line 984, in nameservers
raise ValueError(f'nameserver {nameserver} is not an '
ValueError: nameserver [timeout] is not an IP address or valid https URL
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "management/status_checks.py", line 1100, in
run_and_output_changes(env, pool)
File "management/status_checks.py", line 945, in run_and_output_changes
run_checks(True, env, cur, pool)
File "management/status_checks.py", line 67, in run_checks
run_domain_checks(rounded_values, env, output, pool, domains_to_check=domains_to_check)
File "management/status_checks.py", line 351, in run_domain_checks
ret = pool.starmap(run_domain_checks_on_domain, args, chunksize=1)
File "/usr/lib/python3.6/multiprocessing/pool.py", line 274, in starmap
return self._map_async(func, iterable, starmapstar, chunksize).get()
File "/usr/lib/python3.6/multiprocessing/pool.py", line 644, in get
raise self._value
ValueError: nameserver [timeout] is not an IP address or valid https URL

Looks like the code does not check if the value returned from query_dns is valid. Maybe something like this would solve it? See the changed if statement.

                      ns_ips = query_dns(ns, "A")  
                      if not ns_ips or ns_ips in {'[Not Set]', '[timeout]'}:  
                              output.print_error("Secondary nameserver %s is not valid (it doesn't resolve to an IP address)." % ns)    
                              continue  
                      # Choose the first IP if nameserver returns multiple