diff options
Diffstat (limited to 'plugin/forward/health.go')
-rw-r--r-- | plugin/forward/health.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/plugin/forward/health.go b/plugin/forward/health.go index f4cfab834..ec0b48143 100644 --- a/plugin/forward/health.go +++ b/plugin/forward/health.go @@ -16,6 +16,8 @@ type HealthChecker interface { SetTLSConfig(*tls.Config) SetRecursionDesired(bool) GetRecursionDesired() bool + SetDomain(domain string) + GetDomain() string SetTCPTransport() } @@ -23,6 +25,7 @@ type HealthChecker interface { type dnsHc struct { c *dns.Client recursionDesired bool + domain string } var ( @@ -31,7 +34,7 @@ var ( ) // NewHealthChecker returns a new HealthChecker based on transport. -func NewHealthChecker(trans string, recursionDesired bool) HealthChecker { +func NewHealthChecker(trans string, recursionDesired bool, domain string) HealthChecker { switch trans { case transport.DNS, transport.TLS: c := new(dns.Client) @@ -39,7 +42,7 @@ func NewHealthChecker(trans string, recursionDesired bool) HealthChecker { c.ReadTimeout = hcReadTimeout c.WriteTimeout = hcWriteTimeout - return &dnsHc{c: c, recursionDesired: recursionDesired} + return &dnsHc{c: c, recursionDesired: recursionDesired, domain: domain} } log.Warningf("No healthchecker for transport %q", trans) @@ -58,6 +61,13 @@ func (h *dnsHc) GetRecursionDesired() bool { return h.recursionDesired } +func (h *dnsHc) SetDomain(domain string) { + h.domain = domain +} +func (h *dnsHc) GetDomain() string { + return h.domain +} + func (h *dnsHc) SetTCPTransport() { h.c.Net = "tcp" } @@ -80,7 +90,7 @@ func (h *dnsHc) Check(p *Proxy) error { func (h *dnsHc) send(addr string) error { ping := new(dns.Msg) - ping.SetQuestion(".", dns.TypeNS) + ping.SetQuestion(h.domain, dns.TypeNS) ping.MsgHdr.RecursionDesired = h.recursionDesired m, _, err := h.c.Exchange(ping, addr) |