Don't log a server for blocked names by pattern (#1218)

* Update plugins.go

* reason update moved after reject confirmed

added boolean for direct rejects

* remove server with direct rejects

name pattern blocked cases
This commit is contained in:
Dragonfir3 2020-03-13 17:50:38 +01:00 committed by GitHub
parent a8db53e36f
commit c17637c026
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View File

@ -26,9 +26,6 @@ var blockedNames *BlockedNames
func (blockedNames *BlockedNames) check(pluginsState *PluginsState, qName string, aliasFor *string) (bool, error) {
reject, reason, xweeklyRanges := blockedNames.patternMatcher.Eval(qName)
if aliasFor != nil {
reason = reason + " (alias for [" + *aliasFor + "])"
}
var weeklyRanges *WeeklyRanges
if xweeklyRanges != nil {
weeklyRanges = xweeklyRanges.(*WeeklyRanges)
@ -43,6 +40,11 @@ func (blockedNames *BlockedNames) check(pluginsState *PluginsState, qName string
}
pluginsState.action = PluginsActionReject
pluginsState.returnCode = PluginsReturnCodeReject
if aliasFor != nil {
reason = reason + " (alias for [" + *aliasFor + "])"
} else {
pluginsState.noServed = true
}
if blockedNames.logger != nil {
var clientIPStr string
if pluginsState.clientProto == "udp" {

View File

@ -63,7 +63,7 @@ func (plugin *PluginQueryLog) Eval(pluginsState *PluginsState, msg *dns.Msg) err
}
qName := pluginsState.qName
if pluginsState.cacheHit {
if pluginsState.cacheHit || pluginsState.noServed {
pluginsState.serverName = "-"
} else {
switch pluginsState.returnCode {

View File

@ -84,6 +84,7 @@ type PluginsState struct {
requestStart time.Time
requestEnd time.Time
cacheHit bool
noServed bool
returnCode PluginsReturnCode
serverName string
}