Replace logged_qtypes with ignored_qtypes

This commit is contained in:
Frank Denis 2018-01-20 13:27:37 +01:00
parent 5080502381
commit 066db6a080
4 changed files with 15 additions and 20 deletions

View File

@ -76,9 +76,9 @@ type SourceConfig struct {
} }
type QueryLogConfig struct { type QueryLogConfig struct {
File string File string
Format string Format string
LoggedQtypes []string `toml:"logged_qtypes"` IgnoredQtypes []string `toml:"ignored_qtypes"`
} }
type BlockNameConfig struct { type BlockNameConfig struct {
@ -139,7 +139,7 @@ func ConfigLoad(proxy *Proxy, svcFlag *string, config_file string) error {
} }
proxy.queryLogFile = config.QueryLog.File proxy.queryLogFile = config.QueryLog.File
proxy.queryLogFormat = config.QueryLog.Format proxy.queryLogFormat = config.QueryLog.Format
proxy.queryLogLoggedQtypes = config.QueryLog.LoggedQtypes proxy.queryLogIgnoredQtypes = config.QueryLog.IgnoredQtypes
if len(config.BlockName.Format) == 0 { if len(config.BlockName.Format) == 0 {
config.BlockName.Format = "tsv" config.BlockName.Format = "tsv"

View File

@ -150,9 +150,9 @@ cache_neg_ttl = 60
format = 'tsv' format = 'tsv'
## Only log these query types, to reduce verbosity. Keep empty to log everything. ## Do not log these query types, to reduce verbosity. Keep empty to log everything.
# logged_qtypes = ['A', 'MX'] # ignored_qtypes = ['DNSKEY', 'NS']
###################################################### ######################################################

View File

@ -38,7 +38,7 @@ type Proxy struct {
cacheMaxTTL uint32 cacheMaxTTL uint32
queryLogFile string queryLogFile string
queryLogFormat string queryLogFormat string
queryLogLoggedQtypes []string queryLogIgnoredQtypes []string
blockNameFile string blockNameFile string
blockNameLogFile string blockNameLogFile string
blockNameFormat string blockNameFormat string

View File

@ -15,9 +15,9 @@ import (
type PluginQueryLog struct { type PluginQueryLog struct {
sync.Mutex sync.Mutex
outFd *os.File outFd *os.File
format string format string
loggedQTypes []string ignoredQtypes []string
} }
func (plugin *PluginQueryLog) Name() string { func (plugin *PluginQueryLog) Name() string {
@ -37,7 +37,7 @@ func (plugin *PluginQueryLog) Init(proxy *Proxy) error {
} }
plugin.outFd = outFd plugin.outFd = outFd
plugin.format = proxy.queryLogFormat plugin.format = proxy.queryLogFormat
plugin.loggedQTypes = proxy.queryLogLoggedQtypes plugin.ignoredQtypes = proxy.queryLogIgnoredQtypes
return nil return nil
} }
@ -60,17 +60,12 @@ func (plugin *PluginQueryLog) Eval(pluginsState *PluginsState, msg *dns.Msg) err
if !ok { if !ok {
qType = string(qType) qType = string(qType)
} }
if len(plugin.loggedQTypes) > 0 { if len(plugin.ignoredQtypes) > 0 {
found := false for _, ignoredQtype := range plugin.ignoredQtypes {
for _, loggedQtype := range plugin.loggedQTypes { if strings.EqualFold(ignoredQtype, qType) {
if strings.EqualFold(loggedQtype, qType) { return nil
found = true
break
} }
} }
if !found {
return nil
}
} }
var clientIPStr string var clientIPStr string
if pluginsState.clientProto == "udp" { if pluginsState.clientProto == "udp" {