fix: No failover to next upstream when receiving SERVFAIL or REFUSED response codes(#7457) (#7458)

This commit is contained in:
Fitz_dev
2025-09-13 05:45:01 +08:00
committed by GitHub
parent 155f451957
commit 9683de0feb
5 changed files with 166 additions and 0 deletions

View File

@@ -312,6 +312,27 @@ func parseBlock(c *caddy.Controller, f *Forward) error {
return c.ArgErr()
}
f.failfastUnhealthyUpstreams = true
case "failover":
args := c.RemainingArgs()
if len(args) == 0 {
return c.ArgErr()
}
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")
}
return fmt.Errorf("%s is not a valid rcode", rcode)
}
f.failoverRcodes = append(f.failoverRcodes, rc)
}
default:
return c.Errf("unknown property '%s'", c.Val())
}