aboutsummaryrefslogtreecommitdiff
path: root/plugin/forward/setup.go
diff options
context:
space:
mode:
authorGravatar Pat Downey <patdowney@users.noreply.github.com> 2023-03-24 12:55:51 +0000
committerGravatar GitHub <noreply@github.com> 2023-03-24 08:55:51 -0400
commitf823825f8a34edb85d5d18cd5d2f6f850adf408e (patch)
tree79d241ab9b4c7c343d806f4041c8efccbe3f9ca0 /plugin/forward/setup.go
parent47dceabfc6465ba6c5d41472d6602d4ad5c9fb1b (diff)
downloadcoredns-f823825f8a34edb85d5d18cd5d2f6f850adf408e.tar.gz
coredns-f823825f8a34edb85d5d18cd5d2f6f850adf408e.tar.zst
coredns-f823825f8a34edb85d5d18cd5d2f6f850adf408e.zip
plugin/forward: Allow Proxy to be used outside of forward plugin. (#5951)
* plugin/forward: Move Proxy into pkg/plugin/proxy, to allow forward.Proxy to be used outside of forward plugin. Signed-off-by: Patrick Downey <patrick.downey@dioadconsulting.com>
Diffstat (limited to 'plugin/forward/setup.go')
-rw-r--r--plugin/forward/setup.go25
1 files changed, 13 insertions, 12 deletions
diff --git a/plugin/forward/setup.go b/plugin/forward/setup.go
index 7ca24df4d..6de0c870f 100644
--- a/plugin/forward/setup.go
+++ b/plugin/forward/setup.go
@@ -12,6 +12,7 @@ import (
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/dnstap"
"github.com/coredns/coredns/plugin/pkg/parse"
+ "github.com/coredns/coredns/plugin/pkg/proxy"
pkgtls "github.com/coredns/coredns/plugin/pkg/tls"
"github.com/coredns/coredns/plugin/pkg/transport"
@@ -67,7 +68,7 @@ func setup(c *caddy.Controller) error {
// OnStartup starts a goroutines for all proxies.
func (f *Forward) OnStartup() (err error) {
for _, p := range f.proxies {
- p.start(f.hcInterval)
+ p.Start(f.hcInterval)
}
return nil
}
@@ -75,7 +76,7 @@ func (f *Forward) OnStartup() (err error) {
// OnShutdown stops all configured proxies.
func (f *Forward) OnShutdown() error {
for _, p := range f.proxies {
- p.stop()
+ p.Stop()
}
return nil
}
@@ -127,7 +128,7 @@ func parseStanza(c *caddy.Controller) (*Forward, error) {
if !allowedTrans[trans] {
return f, fmt.Errorf("'%s' is not supported as a destination protocol in forward: %s", trans, host)
}
- p := NewProxy(h, trans)
+ p := proxy.NewProxy(h, trans)
f.proxies = append(f.proxies, p)
transports[i] = trans
}
@@ -152,12 +153,12 @@ func parseStanza(c *caddy.Controller) (*Forward, error) {
f.proxies[i].SetTLSConfig(f.tlsConfig)
}
f.proxies[i].SetExpire(f.expire)
- f.proxies[i].health.SetRecursionDesired(f.opts.hcRecursionDesired)
+ f.proxies[i].GetHealthchecker().SetRecursionDesired(f.opts.HCRecursionDesired)
// when TLS is used, checks are set to tcp-tls
- if f.opts.forceTCP && transports[i] != transport.TLS {
- f.proxies[i].health.SetTCPTransport()
+ if f.opts.ForceTCP && transports[i] != transport.TLS {
+ f.proxies[i].GetHealthchecker().SetTCPTransport()
}
- f.proxies[i].health.SetDomain(f.opts.hcDomain)
+ f.proxies[i].GetHealthchecker().SetDomain(f.opts.HCDomain)
}
return f, nil
@@ -194,12 +195,12 @@ func parseBlock(c *caddy.Controller, f *Forward) error {
return fmt.Errorf("health_check can't be negative: %d", dur)
}
f.hcInterval = dur
- f.opts.hcDomain = "."
+ f.opts.HCDomain = "."
for c.NextArg() {
switch hcOpts := c.Val(); hcOpts {
case "no_rec":
- f.opts.hcRecursionDesired = false
+ f.opts.HCRecursionDesired = false
case "domain":
if !c.NextArg() {
return c.ArgErr()
@@ -208,7 +209,7 @@ func parseBlock(c *caddy.Controller, f *Forward) error {
if _, ok := dns.IsDomainName(hcDomain); !ok {
return fmt.Errorf("health_check: invalid domain name %s", hcDomain)
}
- f.opts.hcDomain = plugin.Name(hcDomain).Normalize()
+ f.opts.HCDomain = plugin.Name(hcDomain).Normalize()
default:
return fmt.Errorf("health_check: unknown option %s", hcOpts)
}
@@ -218,12 +219,12 @@ func parseBlock(c *caddy.Controller, f *Forward) error {
if c.NextArg() {
return c.ArgErr()
}
- f.opts.forceTCP = true
+ f.opts.ForceTCP = true
case "prefer_udp":
if c.NextArg() {
return c.ArgErr()
}
- f.opts.preferUDP = true
+ f.opts.PreferUDP = true
case "tls":
args := c.RemainingArgs()
if len(args) > 3 {