Fixed DNS api, works now with glue records + cleanup

This commit is contained in:
Sebastian Lohff 2017-05-02 02:42:25 +02:00
parent eda76052dd
commit 708d5e1a73
1 changed files with 3 additions and 8 deletions

View File

@ -32,7 +32,6 @@ def compareRecords(rrset, expected):
result["nameMissing"].append((domain, rrtype))
success = not any(len(_x) > 0 for _x in result.values())
print("NARF", success, result)
return success, result
@ -50,7 +49,6 @@ def dnsQuery(domain, rrType, nameserverIp):
def checkDomain(domain, tldNameserver, nameservers):
print(domain, tldNameserver, nameservers)
result = []
# build record set
@ -66,13 +64,10 @@ def checkDomain(domain, tldNameserver, nameservers):
else:
result.append(("err", "Nameserver %s is under domain %s, but has no glue entries." % (ns.name, domain)))
print(nsRecords, glueRecords)
# 1. TLD nameserver
try:
found, rrset = dnsQuery(domain, "ANY", tldNameserver)
if found:
#print(rrset, nsRecords, glueRecords)
success, errors = compareRecords(rrset, nsRecords + glueRecords)
if success:
result.append(("succ", "All records present in TLD nameserver"))
@ -109,7 +104,8 @@ def checkDomain(domain, tldNameserver, nameservers):
for rec in (nsRecords + glueRecords):
found, rrset = dnsQuery(rec[0], rec[1], addr)
success, errors = compareRecords(rrset, nsRecords + glueRecords)
#success, errors = compareRecords(rrset, nsRecords + glueRecords)
success, errors = compareRecords(rrset, [rec])
if not success:
err = True
for k in errors.keys():
@ -118,8 +114,7 @@ def checkDomain(domain, tldNameserver, nameservers):
if not err:
result.append(("succ", "Nameserver %s is configured correctly" % ns.name))
else:
print(" ==> ", errDict, addr)
result.append(("err", "Nameserver %s recordset does not match the database" % (ns.name,), errDict))
result.append(("err", "Nameserver %s (via %s) recordset does not match the database" % (ns.name, addr), errDict))
except (dns.exception.DNSException, OSError):
result.append(("err", "Nameserver %s is not reachable (via %s)" % (ns.name, addr)))