mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user