Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/protocols/protocols.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package protocols

import (
"strings"
"time"

"github.com/miekg/dns"
Expand Down Expand Up @@ -101,10 +102,11 @@ func NewQnameEvent(msg *dns.Msg, ts time.Time) NewQnameJSON {

qType := int(msg.Question[0].Qtype)
qClass := int(msg.Question[0].Qclass)
qname := strings.ToLower(strings.ToValidUTF8(msg.Question[0].Name, ""))

return NewQnameJSON{
Type: NewQnameJSONType,
Qname: msg.Question[0].Name,
Qname: qname,
Qtype: &qType,
Qclass: &qClass,
Timestamp: &ts,
Expand Down
10 changes: 6 additions & 4 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1831,19 +1831,21 @@ func (edm *dnstapMinimiser) qnameSeen(msg *dns.Msg, seenQnameLRU *lru.Cache[stri
// only move an already added entry to the front of the
// eviction list which should be OK.

_, ok := seenQnameLRU.Get(msg.Question[0].Name)
qname := strings.ToLower(strings.ToValidUTF8(msg.Question[0].Name, ""))

_, ok := seenQnameLRU.Get(qname)
if ok {
// It exists in the LRU cache
return true
}
// Add it to the LRU
evicted := seenQnameLRU.Add(msg.Question[0].Name, struct{}{})
evicted := seenQnameLRU.Add(qname, struct{}{})
if evicted {
edm.promSeenQnameLRUEvicted.Inc()
}

// It was not in the LRU cache, does it exist in pebble (on disk)?
_, closer, err := pdb.Get([]byte(msg.Question[0].Name))
_, closer, err := pdb.Get([]byte(qname))
if err == nil {
// The value exists in pebble
if err := closer.Close(); err != nil {
Expand All @@ -1854,7 +1856,7 @@ func (edm *dnstapMinimiser) qnameSeen(msg *dns.Msg, seenQnameLRU *lru.Cache[stri

// If the key does not exist in pebble we insert it
if errors.Is(err, pebble.ErrNotFound) {
if err := pdb.Set([]byte(msg.Question[0].Name), []byte{}, pebble.Sync); err != nil {
if err := pdb.Set([]byte(qname), []byte{}, pebble.Sync); err != nil {
edm.log.Error("unable to insert key in pebble", "error", err)
}
return false
Expand Down