From f06f51b247188d2294b1ffe80192eca6f4b4b0eb Mon Sep 17 00:00:00 2001 From: mawalu Date: Sun, 6 Feb 2022 20:12:40 +0100 Subject: [PATCH] Make queries case insensitivie --- src/apiserver.nim | 4 ++-- src/dnsserver.nim | 2 +- src/state.nim | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/apiserver.nim b/src/apiserver.nim index 730609d..08f6907 100644 --- a/src/apiserver.nim +++ b/src/apiserver.nim @@ -46,7 +46,7 @@ proc present(req: Request, auth: Auth, base: string): Future[void] {.async.} = addRecord( records, - (name: name, dtype: DnsType.TXT), + (name: name.toLowerAscii(), dtype: DnsType.TXT), record.value ) @@ -54,7 +54,7 @@ proc present(req: Request, auth: Auth, base: string): Future[void] {.async.} = 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 + let name = trimName(record.fqdn.toLowerAscii()) & "." & auth.name & "." & base echo &"Deleting TXT record for {name} with value {record.value}" diff --git a/src/dnsserver.nim b/src/dnsserver.nim index cc9a284..3b2fca5 100644 --- a/src/dnsserver.nim +++ b/src/dnsserver.nim @@ -14,7 +14,7 @@ proc handleDnsRequest(records: RecordsTable, data: string): Option[string] = let response = mkResponse( msg.header.id, question, - records.getOrDefault((name: question.qname, dtype: question.qtype), @[]) + records.getOrDefault((name: question.qname.toLowerAscii(), dtype: question.qtype), @[]) ) echo response diff --git a/src/state.nim b/src/state.nim index 3b5e467..927c883 100644 --- a/src/state.nim +++ b/src/state.nim @@ -1,4 +1,4 @@ -import tables, strtabs, sequtils, nativesockets +import tables, strtabs, sequtils, nativesockets, strutils import ../lib/dns type