From 53d680a5dfb027831bdbfc91bde5272d4d849a1a Mon Sep 17 00:00:00 2001 From: Aleksey Dmitrevskiy Date: Thu, 28 Feb 2019 16:19:23 +0300 Subject: [PATCH] Fix #597 - [bugfix] querylog_top: Empty domain gets to the Top Queried domains --- dnsforward/querylog_top.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dnsforward/querylog_top.go b/dnsforward/querylog_top.go index a2ffffdc..43d16699 100644 --- a/dnsforward/querylog_top.go +++ b/dnsforward/querylog_top.go @@ -9,8 +9,8 @@ import ( "sync" "time" - "github.com/bluele/gcache" "github.com/AdguardTeam/golibs/log" + "github.com/bluele/gcache" "github.com/miekg/dns" ) @@ -158,6 +158,11 @@ func (d *dayTop) addEntry(entry *logEntry, q *dns.Msg, now time.Time) error { hostname := strings.ToLower(strings.TrimSuffix(q.Question[0].Name, ".")) + // if question hostname is empty, do nothing + if hostname == "" { + return nil + } + // get value, if not set, crate one d.hoursReadLock() defer d.hoursReadUnlock()