fix(forward): disallow NOERROR in failover (#7622)

Previously the parsing logic in the forward plugin setup failed to
recognise when NOERROR was used as a failover RCODE criteria. The
check was in the wrong code branch. This PR fixes it and adds
validation tests. Also updates the plugin README.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
This commit is contained in:
Ville Vesilehto
2025-10-17 14:37:02 +03:00
committed by GitHub
parent 38c020941b
commit f4ab631ae4
3 changed files with 42 additions and 9 deletions

View File

@@ -320,16 +320,13 @@ func parseBlock(c *caddy.Controller, f *Forward) error {
toRcode := dns.StringToRcode
for _, rcode := range args {
var rc int
var ok bool
if rc, ok = toRcode[strings.ToUpper(rcode)]; !ok {
if rc == dns.RcodeSuccess {
return fmt.Errorf("NoError cannot be used in failover")
}
rc, ok := toRcode[strings.ToUpper(rcode)]
if !ok {
return fmt.Errorf("%s is not a valid rcode", rcode)
}
if rc == dns.RcodeSuccess {
return fmt.Errorf("NoError cannot be used in failover")
}
f.failoverRcodes = append(f.failoverRcodes, rc)
}