Merge pull request #160 in DNS/adguard-dns from fix/597 to master

* commit '53d680a5dfb027831bdbfc91bde5272d4d849a1a':
  Fix #597 - [bugfix] querylog_top: Empty domain gets to the Top Queried domains
This commit is contained in:
Alexey Dmitrievskiy 2019-02-28 18:05:19 +03:00
commit 681fb4e705
1 changed files with 6 additions and 1 deletions

View File

@ -9,8 +9,8 @@ import (
"sync" "sync"
"time" "time"
"github.com/bluele/gcache"
"github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/log"
"github.com/bluele/gcache"
"github.com/miekg/dns" "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, ".")) 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 // get value, if not set, crate one
d.hoursReadLock() d.hoursReadLock()
defer d.hoursReadUnlock() defer d.hoursReadUnlock()