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:
parent
22e77b2cf2
commit
4033d7aeba
3 changed files with 19 additions and 8 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue