Add a NOT_READY return code

This commit is contained in:
Frank Denis 2021-01-03 18:09:03 +01:00
parent f9ec0a9c09
commit daa1f3d3b1
2 changed files with 7 additions and 1 deletions

View File

@ -46,6 +46,7 @@ const (
PluginsReturnCodeNetworkError PluginsReturnCodeNetworkError
PluginsReturnCodeCloak PluginsReturnCodeCloak
PluginsReturnCodeServerTimeout PluginsReturnCodeServerTimeout
PluginsReturnCodeNotReady
) )
var PluginsReturnCodeToString = map[PluginsReturnCode]string{ var PluginsReturnCodeToString = map[PluginsReturnCode]string{
@ -61,6 +62,7 @@ var PluginsReturnCodeToString = map[PluginsReturnCode]string{
PluginsReturnCodeNetworkError: "NETWORK_ERROR", PluginsReturnCodeNetworkError: "NETWORK_ERROR",
PluginsReturnCodeCloak: "CLOAK", PluginsReturnCodeCloak: "CLOAK",
PluginsReturnCodeServerTimeout: "SERVER_TIMEOUT", PluginsReturnCodeServerTimeout: "SERVER_TIMEOUT",
PluginsReturnCodeNotReady: "NOT_READY",
} }
type PluginsState struct { type PluginsState struct {

View File

@ -716,7 +716,11 @@ func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string,
} }
} }
if len(response) < MinDNSPacketSize || len(response) > MaxDNSPacketSize { if len(response) < MinDNSPacketSize || len(response) > MaxDNSPacketSize {
pluginsState.returnCode = PluginsReturnCodeParseError if len(response) == 0 {
pluginsState.returnCode = PluginsReturnCodeNotReady
} else {
pluginsState.returnCode = PluginsReturnCodeParseError
}
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals) pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
if serverInfo != nil { if serverInfo != nil {
serverInfo.noticeFailure(proxy) serverInfo.noticeFailure(proxy)