From 243603e04c0fc8009c3832aa525ffcf99b04ba69 Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Sat, 29 Dec 2018 17:47:50 +0300 Subject: [PATCH] Fix panic when DNS query doesn't have questions. Closes #491. --- dnsforward/querylog_top.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dnsforward/querylog_top.go b/dnsforward/querylog_top.go index 26c896fa..8ca5f24d 100644 --- a/dnsforward/querylog_top.go +++ b/dnsforward/querylog_top.go @@ -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