Log queries

This commit is contained in:
Martin 2022-02-06 18:59:39 +01:00
parent 23474bc89a
commit 389f05f316
Signed by: mawalu
GPG Key ID: BF556F989760A7C8
2 changed files with 8 additions and 0 deletions

View File

@ -42,6 +42,8 @@ proc present(req: Request, auth: Auth, base: string): Future[void] {.async.} =
let record = to(parseJson(req.body), NewRecordReq) let record = to(parseJson(req.body), NewRecordReq)
let name = trimName(record.fqdn) & "." & auth.name & "." & base let name = trimName(record.fqdn) & "." & auth.name & "." & base
echo &"Adding TXT record for {name} with value {record.value}"
addRecord( addRecord(
records, records,
(name: name, dtype: DnsType.TXT), (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 record = to(parseJson(req.body), NewRecordReq)
let name = trimName(record.fqdn) & "." & auth.name & "." & base let name = trimName(record.fqdn) & "." & auth.name & "." & base
echo &"Deleting TXT record for {name} with value {record.value}"
delRecord( delRecord(
records, records,
(name: name, dtype: DnsType.TXT), (name: name, dtype: DnsType.TXT),

View File

@ -5,6 +5,8 @@ import ../lib/dns, state
proc handleDnsRequest(records: RecordsTable, data: string): Option[string] = proc handleDnsRequest(records: RecordsTable, data: string): Option[string] =
let msg = parseMessage(data) let msg = parseMessage(data)
echo msg
if len(msg.questions) == 0: if len(msg.questions) == 0:
return return
@ -15,6 +17,8 @@ proc handleDnsRequest(records: RecordsTable, data: string): Option[string] =
records.getOrDefault((name: question.qname, dtype: question.qtype), @[]) records.getOrDefault((name: question.qname, dtype: question.qtype), @[])
) )
echo response
return some(packMessage(response)) return some(packMessage(response))
proc serveDns*(config: AppConfig) {.async.} = proc serveDns*(config: AppConfig) {.async.} =