plugin/forward: health_check needs to normalize a specified domain name (#5543)

* plugin/forward: convert the specified domain of health_check to Fqdn
* plugin/forward: update readme for health check

Signed-off-by: vanceli <vanceli@tencent.com>
This commit is contained in:
Vancl 2022-08-15 22:16:15 +08:00 committed by GitHub
parent 22e77b2cf2
commit 4033d7aeba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 8 deletions

View file

@ -14,6 +14,8 @@ import (
"github.com/coredns/coredns/plugin/pkg/parse"
pkgtls "github.com/coredns/coredns/plugin/pkg/tls"
"github.com/coredns/coredns/plugin/pkg/transport"
"github.com/miekg/dns"
)
func init() { plugin.Register("forward", setup) }
@ -204,7 +206,11 @@ func parseBlock(c *caddy.Controller, f *Forward) error {
if !c.NextArg() {
return c.ArgErr()
}
f.opts.hcDomain = c.Val()
hcDomain := c.Val()
if _, ok := dns.IsDomainName(hcDomain); !ok {
return fmt.Errorf("health_check: invalid domain name %s", hcDomain)
}
f.opts.hcDomain = plugin.Name(hcDomain).Normalize()
default:
return fmt.Errorf("health_check: unknown option %s", hcOpts)
}