mirror of
https://github.com/slackhq/nebula.git
synced 2025-11-08 23:23:58 +01:00
Make DNS queries case insensitive (#793)
This commit is contained in:
parent
b7e73da943
commit
c44da3abee
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
@ -33,11 +34,10 @@ func newDnsRecords(hostMap *HostMap) *dnsRecords {
|
|||||||
|
|
||||||
func (d *dnsRecords) Query(data string) string {
|
func (d *dnsRecords) Query(data string) string {
|
||||||
d.RLock()
|
d.RLock()
|
||||||
if r, ok := d.dnsMap[data]; ok {
|
defer d.RUnlock()
|
||||||
d.RUnlock()
|
if r, ok := d.dnsMap[strings.ToLower(data)]; ok {
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
d.RUnlock()
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,8 +62,8 @@ func (d *dnsRecords) QueryCert(data string) string {
|
|||||||
|
|
||||||
func (d *dnsRecords) Add(host, data string) {
|
func (d *dnsRecords) Add(host, data string) {
|
||||||
d.Lock()
|
d.Lock()
|
||||||
d.dnsMap[host] = data
|
defer d.Unlock()
|
||||||
d.Unlock()
|
d.dnsMap[strings.ToLower(host)] = data
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseQuery(l *logrus.Logger, m *dns.Msg, w dns.ResponseWriter) {
|
func parseQuery(l *logrus.Logger, m *dns.Msg, w dns.ResponseWriter) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user