Fix panic when DNS query doesn't have questions.

Closes #491.
This commit is contained in:
Eugene Bujak 2018-12-29 17:47:50 +03:00
parent 413bc75320
commit 243603e04c
1 changed files with 5 additions and 0 deletions

View File

@ -158,6 +158,11 @@ func (r *dayTop) addEntry(entry *logEntry, q *dns.Msg, now time.Time) error {
return nil
}
// if a DNS query doesn't have questions, do nothing
if len(q.Question) == 0 {
return nil
}
hostname := strings.ToLower(strings.TrimSuffix(q.Question[0].Name, "."))
// get value, if not set, crate one