From 389f05f3160f2ab173a6476a15a5fb45c64cfc71 Mon Sep 17 00:00:00 2001 From: mawalu Date: Sun, 6 Feb 2022 18:59:39 +0100 Subject: [PATCH] Log queries --- src/apiserver.nim | 4 ++++ src/dnsserver.nim | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/apiserver.nim b/src/apiserver.nim index c6eb6e1..730609d 100644 --- a/src/apiserver.nim +++ b/src/apiserver.nim @@ -42,6 +42,8 @@ proc present(req: Request, auth: Auth, base: string): Future[void] {.async.} = let record = to(parseJson(req.body), NewRecordReq) let name = trimName(record.fqdn) & "." & auth.name & "." & base + echo &"Adding TXT record for {name} with value {record.value}" + addRecord( records, (name: name, dtype: DnsType.TXT), @@ -54,6 +56,8 @@ proc cleanup(req: Request, auth: Auth, base: string): Future[void] {.async.} = let record = to(parseJson(req.body), NewRecordReq) let name = trimName(record.fqdn) & "." & auth.name & "." & base + echo &"Deleting TXT record for {name} with value {record.value}" + delRecord( records, (name: name, dtype: DnsType.TXT), diff --git a/src/dnsserver.nim b/src/dnsserver.nim index 5d59043..cc9a284 100644 --- a/src/dnsserver.nim +++ b/src/dnsserver.nim @@ -5,6 +5,8 @@ import ../lib/dns, state proc handleDnsRequest(records: RecordsTable, data: string): Option[string] = let msg = parseMessage(data) + echo msg + if len(msg.questions) == 0: return @@ -15,6 +17,8 @@ proc handleDnsRequest(records: RecordsTable, data: string): Option[string] = records.getOrDefault((name: question.qname, dtype: question.qtype), @[]) ) + echo response + return some(packMessage(response)) proc serveDns*(config: AppConfig) {.async.} =