middleware/log: allows logging based on response classes (#325)

Add the ability to add a class of responses to be logged; success,
denial or error. The default is to log everything (all).

Fixes #258
This commit is contained in:
Miek Gieben
2016-10-10 12:09:29 +01:00
committed by GitHub
parent caa3976bfe
commit c22b7b2252
13 changed files with 348 additions and 108 deletions

View File

@@ -87,7 +87,7 @@ func setMsgTTL(m *dns.Msg, ttl uint32) {
}
func minMsgTTL(m *dns.Msg, mt response.Type) time.Duration {
if mt != response.Success && mt != response.NameError && mt != response.NoData {
if mt != response.NoError && mt != response.NameError && mt != response.NoData {
return 0
}
@@ -98,7 +98,7 @@ func minMsgTTL(m *dns.Msg, mt response.Type) time.Duration {
if r.Header().Rrtype == dns.TypeSOA {
return time.Duration(r.(*dns.SOA).Minttl) * time.Second
}
case response.Success, response.Delegation:
case response.NoError, response.Delegation:
if r.Header().Ttl < uint32(minTTL.Seconds()) {
minTTL = time.Duration(r.Header().Ttl) * time.Second
}