diff options
author | 2022-08-15 22:16:15 +0800 | |
---|---|---|
committer | 2022-08-15 10:16:15 -0400 | |
commit | 4033d7aebab8918f92a49fc85cb2b37ef831294e (patch) | |
tree | f85e8f9f12b2a8aa8cf6b20f1e0b18bfba782912 /plugin/forward/setup.go | |
parent | 22e77b2cf2c9f468a9073ce2fa6d012a839927a8 (diff) | |
download | coredns-4033d7aebab8918f92a49fc85cb2b37ef831294e.tar.gz coredns-4033d7aebab8918f92a49fc85cb2b37ef831294e.tar.zst coredns-4033d7aebab8918f92a49fc85cb2b37ef831294e.zip |
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>
Diffstat (limited to 'plugin/forward/setup.go')
-rw-r--r-- | plugin/forward/setup.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/plugin/forward/setup.go b/plugin/forward/setup.go index 0e317bf9f..dfae70d37 100644 --- a/plugin/forward/setup.go +++ b/plugin/forward/setup.go @@ -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) } |