improve DNS test output

pull/65/head
Joshua Tauberer 10 years ago
parent 2bbb7a5e7e
commit fff06f7d71
  1. 13
      tests/test_dns.py

@ -51,7 +51,7 @@ def test2(tests, server, description):
response = dns.resolver.query(qname, rtype)
except dns.resolver.NXDOMAIN:
# host did not have an answer for this query
response = ["NOT SET"]
response = ["[no value]"]
response = ";".join(str(r) for r in response)
response = re.sub(r"(\"p=).*(\")", r"\1__KEY__\2", response) # normalize DKIM key
@ -64,9 +64,10 @@ def test2(tests, server, description):
if first:
print("Incorrect DNS Response from", description)
print()
print("QUERY ", "RESPONSE ", "CORRECT VALUE", sep='\t')
first = False
print(qname, rtype, "got", repr(response), "but we should have gotten", repr(expected_answer))
print((qname + "/" + rtype).ljust(20), response.ljust(12), expected_answer, sep='\t')
return first # success
# Test the response from the machine itself.
@ -75,6 +76,9 @@ if not test(ipaddr, "Mail-in-a-Box"):
print ("Please run the Mail-in-a-Box setup script on %s again." % hostname)
sys.exit(1)
else:
print ("The Mail-in-a-Box provided correct DNS answers.")
print ()
# If those settings are OK, also test Google's Public DNS
# to see if the machine is hooked up to recursive DNS properly.
if not test("8.8.8.8", "Google Public DNS"):
@ -82,10 +86,15 @@ else:
print ("Check that the nameserver settings for %s are correct at your domain registrar. It may take a few hours for Google Public DNS to update after changes on your Mail-in-a-Box." % hostname)
sys.exit(1)
else:
print ("Your domain registrar or DNS host appears to be configured correctly as well. Public DNS provides the same answers.")
print ()
# And if that's OK, also check reverse DNS (the PTR record).
if not test_ptr("8.8.8.8", "Google Public DNS (Reverse DNS)"):
print ()
print ("The reverse DNS for %s is not correct. Consult your ISP for how to set the reverse DNS (also called the PTR record) for %s to %s." % (hostname, hostname, ipaddr))
sys.exit(1)
else:
print ("And the reverse DNS for the domain is correct.")
print ()
print ("DNS is OK.")

Loading…
Cancel
Save