From c44da3abeec3dede8460bdb51a06bc64b844a3ca Mon Sep 17 00:00:00 2001 From: John Maguire Date: Tue, 20 Dec 2022 16:59:11 -0500 Subject: [PATCH] Make DNS queries case insensitive (#793) --- dns_server.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dns_server.go b/dns_server.go index 60cceae..19bc5ce 100644 --- a/dns_server.go +++ b/dns_server.go @@ -4,6 +4,7 @@ import ( "fmt" "net" "strconv" + "strings" "sync" "github.com/miekg/dns" @@ -33,11 +34,10 @@ func newDnsRecords(hostMap *HostMap) *dnsRecords { func (d *dnsRecords) Query(data string) string { d.RLock() - if r, ok := d.dnsMap[data]; ok { - d.RUnlock() + defer d.RUnlock() + if r, ok := d.dnsMap[strings.ToLower(data)]; ok { return r } - d.RUnlock() return "" } @@ -62,8 +62,8 @@ func (d *dnsRecords) QueryCert(data string) string { func (d *dnsRecords) Add(host, data string) { d.Lock() - d.dnsMap[host] = data - d.Unlock() + defer d.Unlock() + d.dnsMap[strings.ToLower(host)] = data } func parseQuery(l *logrus.Logger, m *dns.Msg, w dns.ResponseWriter) {