diff options
Diffstat (limited to 'middleware')
-rw-r--r-- | middleware/proxy/dns.go | 3 | ||||
-rw-r--r-- | middleware/proxy/exchanger.go | 4 | ||||
-rw-r--r-- | middleware/proxy/google.go | 3 | ||||
-rw-r--r-- | middleware/proxy/lookup.go | 3 | ||||
-rw-r--r-- | middleware/proxy/proxy.go | 2 |
5 files changed, 10 insertions, 5 deletions
diff --git a/middleware/proxy/dns.go b/middleware/proxy/dns.go index 4fde48e40..45d8e3e2e 100644 --- a/middleware/proxy/dns.go +++ b/middleware/proxy/dns.go @@ -1,6 +1,7 @@ package proxy import ( + "context" "net" "time" @@ -24,7 +25,7 @@ func (d *dnsEx) OnShutdown(p *Proxy) error { return nil } func (d *dnsEx) OnStartup(p *Proxy) error { return nil } // Exchange implements the Exchanger interface. -func (d *dnsEx) Exchange(addr string, state request.Request) (*dns.Msg, error) { +func (d *dnsEx) Exchange(ctx context.Context, addr string, state request.Request) (*dns.Msg, error) { co, err := net.DialTimeout(state.Proto(), addr, d.Timeout) if err != nil { return nil, err diff --git a/middleware/proxy/exchanger.go b/middleware/proxy/exchanger.go index 78c80b8b6..d5c17e349 100644 --- a/middleware/proxy/exchanger.go +++ b/middleware/proxy/exchanger.go @@ -1,6 +1,8 @@ package proxy import ( + "context" + "github.com/miekg/coredns/request" "github.com/miekg/dns" ) @@ -8,7 +10,7 @@ import ( // Exchanger is an interface that specifies a type implementing a DNS resolver that // can use whatever transport it likes. type Exchanger interface { - Exchange(addr string, state request.Request) (*dns.Msg, error) + Exchange(ctx context.Context, addr string, state request.Request) (*dns.Msg, error) Protocol() string OnStartup(*Proxy) error diff --git a/middleware/proxy/google.go b/middleware/proxy/google.go index 5efb84960..4d82ec914 100644 --- a/middleware/proxy/google.go +++ b/middleware/proxy/google.go @@ -1,6 +1,7 @@ package proxy import ( + "context" "crypto/tls" "encoding/json" "fmt" @@ -42,7 +43,7 @@ func newGoogle(endpoint string, bootstrap []string) *google { return &google{client: client, endpoint: dns.Fqdn(endpoint), bootstrapProxy: boot, quit: make(chan bool)} } -func (g *google) Exchange(addr string, state request.Request) (*dns.Msg, error) { +func (g *google) Exchange(ctx context.Context, addr string, state request.Request) (*dns.Msg, error) { v := url.Values{} v.Set("name", state.Name()) diff --git a/middleware/proxy/lookup.go b/middleware/proxy/lookup.go index 56dc0eb4c..9c736aa63 100644 --- a/middleware/proxy/lookup.go +++ b/middleware/proxy/lookup.go @@ -3,6 +3,7 @@ package proxy // functions other middleware might want to use to do lookup in the same style as the proxy. import ( + "context" "sync/atomic" "time" @@ -91,7 +92,7 @@ func (p Proxy) lookup(state request.Request) (*dns.Msg, error) { atomic.AddInt64(&host.Conns, 1) - reply, backendErr := upstream.Exchanger().Exchange(host.Name, state) + reply, backendErr := upstream.Exchanger().Exchange(context.TODO(), host.Name, state) atomic.AddInt64(&host.Conns, -1) diff --git a/middleware/proxy/proxy.go b/middleware/proxy/proxy.go index 1a595d99e..ca57d7575 100644 --- a/middleware/proxy/proxy.go +++ b/middleware/proxy/proxy.go @@ -105,7 +105,7 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ( atomic.AddInt64(&host.Conns, 1) - reply, backendErr := upstream.Exchanger().Exchange(host.Name, state) + reply, backendErr := upstream.Exchanger().Exchange(ctx, host.Name, state) atomic.AddInt64(&host.Conns, -1) |