Log whether response was served from cache

This commit is contained in:
Ferdinand Holzer 2019-05-28 22:48:56 +02:00 committed by Frank Denis
parent af096f8488
commit 14b464e56d
3 changed files with 4 additions and 2 deletions

View File

@ -132,6 +132,7 @@ func (plugin *PluginCache) Eval(pluginsState *PluginsState, msg *dns.Msg) error
synth.Question = msg.Question
pluginsState.synthResponse = &synth
pluginsState.action = PluginsActionSynth
pluginsState.cacheHit = true
return nil
}

View File

@ -84,8 +84,8 @@ func (plugin *PluginQueryLog) Eval(pluginsState *PluginsState, msg *dns.Msg) err
tsStr := fmt.Sprintf("[%d-%02d-%02d %02d:%02d:%02d]", year, int(month), day, hour, minute, second)
line = fmt.Sprintf("%s\t%s\t%s\t%s\t%s\t%d\n", tsStr, clientIPStr, StringQuote(qName), qType, returnCode, requestDuration/time.Millisecond)
} else if plugin.format == "ltsv" {
line = fmt.Sprintf("time:%d\thost:%s\tmessage:%s\ttype:%s\treturn:%s\tduration:%d\n",
time.Now().Unix(), clientIPStr, StringQuote(qName), qType, returnCode, requestDuration/time.Millisecond)
line = fmt.Sprintf("time:%d\thost:%s\tmessage:%s\ttype:%s\treturn:%s\tcacheHit:%v\tduration:%d\n",
time.Now().Unix(), clientIPStr, StringQuote(qName), qType, returnCode, pluginsState.cacheHit, requestDuration/time.Millisecond)
} else {
dlog.Fatalf("Unexpected log format: [%s]", plugin.format)
}

View File

@ -73,6 +73,7 @@ type PluginsState struct {
questionMsg *dns.Msg
requestStart time.Time
requestEnd time.Time
cacheHit bool
returnCode PluginsReturnCode
}