Skip to content

Commit

Permalink
Make DNS queries case insensitive (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmaguire committed Dec 20, 2022
1 parent b7e73da commit c44da3a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions dns_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net"
"strconv"
"strings"
"sync"

"github.com/miekg/dns"
Expand Down Expand Up @@ -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 ""
}

Expand All @@ -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) {
Expand Down

0 comments on commit c44da3a

Please sign in to comment.