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