From dc1042c3e9ab8a9ae2cc2dd034f42a5dee8eff91 Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Sun, 7 Oct 2018 02:17:57 +0300 Subject: [PATCH] Querylog -- Omit empty fields when writing json --- coredns_plugin/querylog.go | 2 +- dnsfilter/dnsfilter.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/coredns_plugin/querylog.go b/coredns_plugin/querylog.go index 381ac16a..d064ea08 100644 --- a/coredns_plugin/querylog.go +++ b/coredns_plugin/querylog.go @@ -30,7 +30,7 @@ var ( type logEntry struct { Question []byte - Answer []byte + Answer []byte `json:",omitempty"` // sometimes empty answers happen like binerdunt.top or rev2.globalrootservers.net Result dnsfilter.Result Time time.Time Elapsed time.Duration diff --git a/dnsfilter/dnsfilter.go b/dnsfilter/dnsfilter.go index 3060b297..1344ea9f 100644 --- a/dnsfilter/dnsfilter.go +++ b/dnsfilter/dnsfilter.go @@ -136,9 +136,9 @@ var ( // Result holds state of hostname check type Result struct { - IsFiltered bool - Reason Reason - Rule string + IsFiltered bool `json:",omitempty"` + Reason Reason `json:",omitempty"` + Rule string `json:",omitempty"` } // Matched can be used to see if any match at all was found, no matter filtered or not