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.synthResponse = respMsg
pluginsState.action = PluginsActionSynth pluginsState.action = PluginsActionSynth
pluginsState.returnCode = PluginsReturnCodeForward
return nil return nil
} }

View File

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