This commit is contained in:
2022-03-01 14:08:53 +01:00
parent 1f55516c59
commit 21b2396076
11 changed files with 1167 additions and 895 deletions

View File

@@ -81,6 +81,7 @@ class DnsServer:
self.debug = False
self.ttl = 60 * 5
self.logging = False
self.not_found_handler = None
def addEntry(self, type, domain, value):
if type not in self.entries:
@@ -135,6 +136,8 @@ class DnsServer:
reply.add_answer(RR(rname=qname, rtype=getattr(QTYPE, rqt), rclass=1, ttl=self.ttl, rdata=entry))
if self.logging:
print(f"Request: {qt} {qn} -> {entry}")
elif self.not_found_handler:
self.not_found_handler(request, reply)
if self.debug:
print("DNS RESPONSE:", reply)