Skip to content

Commit

Permalink
Support "ANY" for resolving (iphelix/dnschef#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
byt3bl33d3r committed Sep 28, 2023
1 parent d5716ba commit e1daa02
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions dnschef/kitchen.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,24 +162,17 @@ def datagram_received(self, data, addr):
fake_record = fake_records[qtype]
logger.info(f"cooking response", type=qtype, name=qname, record=fake_record)

try:
response_func = getattr(self.dnsresponses, f"do_{qtype}")
except AttributeError:
response_func = getattr(self.dnsresponses, "do_default")
response_func = getattr(self.dnsresponses, f"do_{qtype}", "do_default")

task = asyncio.create_task(response_func(addr, fake_record, qname, qtype))
task.add_done_callback(functools.partial(self.send_response, response=response, addr=addr))

elif qtype == "*" and None not in list(fake_records.values()):
elif (qtype == "*" or qtype == "ANY") and None not in list(fake_records.values()):
logger.info("cooking response with all known fake records", type='ANY', name=qname)

for qtype, fake_record in list(fake_records.items()):
if fake_record:
try:
response_func = getattr(self.dnsresponses, f"do_{qtype}")
except AttributeError:
response_func = getattr(self.dnsresponses, "do_default")

response_func = getattr(self.dnsresponses, f"do_{qtype}", "do_default")
response.add_answer(response_func(addr, fake_record, qname, qtype))

self.transport.sendto(response.pack(), addr)
Expand Down

0 comments on commit e1daa02

Please sign in to comment.