fix: make nameservers configurable

This commit is contained in:
Michael Hinz 2026-02-12 15:48:10 +01:00
commit e4735b197e
2 changed files with 4 additions and 4 deletions

View file

@ -4,5 +4,6 @@ DB_PORT=3306
DB_USER=test
DB_PASS=testpass
DB_DB=pdns
NAMESERVERS=localhost:10053
DNS_MASTER=wile
LOG_LEVEL=DEBUG

View file

@ -25,19 +25,18 @@ def main():
# try to resolve dnskey.{zone} on all nameservers
# dammit, my testserver is running on a weird port
r = dns.resolver.Resolver()
nsarr = ['127.0.0.1:10053']
ns_str = config('NAMESERVERS', 'localhost:10053')
nsarr = ns_str.split(',')
expected = None
for ns in nsarr:
# r.nameservers = [ns]
try:
answer = r.resolve(qname=zone, rdtype='DNSKEY', tcp=False, search=ns)
print(f"{answer=}")
if not expected:
expected = answer.rrset.to_text()
# print(f"set {expected=}")
else:
if answer.rrset.to_text() != expected:
print(f"{answer.rrset.to_text()=} differs from {expected=}")
logging.debug(f"{answer.rrset.to_text()=} differs from {expected=}")
# I'm very confident this is more complicated than it needs to be...
db.query(f"""SELECT id,content FROM records WHERE type='SOA' AND name='{zone}'""")
result = db.store_result()