Rename PluginsActionForward to PluginsActionContinue

Set the correct response code when forwarding
This commit is contained in:
Frank Denis 2019-12-17 19:19:36 +01:00
parent 2c295e3702
commit 3fce30d7a5
2 changed files with 9 additions and 10 deletions

View File

@ -98,5 +98,6 @@ func (plugin *PluginForward) Eval(pluginsState *PluginsState, msg *dns.Msg) erro
}
pluginsState.synthResponse = respMsg
pluginsState.action = PluginsActionSynth
pluginsState.returnCode = PluginsReturnCodeForward
return nil
}

View File

@ -15,7 +15,7 @@ type PluginsAction int
const (
PluginsActionNone = 0
PluginsActionForward = 1
PluginsActionContinue = 1
PluginsActionDrop = 2
PluginsActionReject = 3
PluginsActionSynth = 4
@ -225,7 +225,7 @@ type Plugin interface {
func NewPluginsState(proxy *Proxy, clientProto string, clientAddr *net.Addr, start time.Time) PluginsState {
return PluginsState{
action: PluginsActionForward,
action: PluginsActionContinue,
returnCode: PluginsReturnCodePass,
maxPayloadSize: MaxDNSUDPPacketSize - ResponseOverhead,
clientProto: clientProto,
@ -245,7 +245,6 @@ func NewPluginsState(proxy *Proxy, clientProto string, clientAddr *net.Addr, sta
func (pluginsState *PluginsState) ApplyQueryPlugins(pluginsGlobals *PluginsGlobals, packet []byte, serverName string) ([]byte, error) {
pluginsState.serverName = serverName
pluginsState.action = PluginsActionForward
msg := dns.Msg{}
if err := msg.Unpack(packet); err != nil {
return packet, err
@ -273,7 +272,7 @@ func (pluginsState *PluginsState) ApplyQueryPlugins(pluginsGlobals *PluginsGloba
synth := RefusedResponseFromMessage(&msg, pluginsGlobals.refusedCodeInResponses, pluginsGlobals.respondWithIPv4, pluginsGlobals.respondWithIPv6, pluginsState.rejectTTL)
pluginsState.synthResponse = synth
}
if pluginsState.action != PluginsActionForward {
if pluginsState.action != PluginsActionContinue {
break
}
}
@ -288,7 +287,6 @@ func (pluginsState *PluginsState) ApplyResponsePlugins(pluginsGlobals *PluginsGl
if len(*pluginsGlobals.responsePlugins) == 0 && len(*pluginsGlobals.loggingPlugins) == 0 {
return packet, nil
}
pluginsState.action = PluginsActionForward
msg := dns.Msg{Compress: true}
if err := msg.Unpack(packet); err != nil {
if len(packet) >= MinDNSPacketSize && HasTCFlag(packet) {
@ -317,7 +315,7 @@ func (pluginsState *PluginsState) ApplyResponsePlugins(pluginsGlobals *PluginsGl
synth := RefusedResponseFromMessage(&msg, pluginsGlobals.refusedCodeInResponses, pluginsGlobals.respondWithIPv4, pluginsGlobals.respondWithIPv6, pluginsState.rejectTTL)
pluginsState.synthResponse = synth
}
if pluginsState.action != PluginsActionForward {
if pluginsState.action != PluginsActionContinue {
break
}
}