aboutsummaryrefslogtreecommitdiff
path: root/middleware/proxy/dns.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-02-06 19:32:48 +0000
committerGravatar GitHub <noreply@github.com> 2017-02-06 19:32:48 +0000
commit123a76c91ead7fb57e801f974a16fc3ab8312c0d (patch)
tree0b84ec261ad06e8e747c154264fca84043d07aaa /middleware/proxy/dns.go
parent77f957d443f9c287abc1f315cebc0c725e9e4ba0 (diff)
downloadcoredns-123a76c91ead7fb57e801f974a16fc3ab8312c0d.tar.gz
coredns-123a76c91ead7fb57e801f974a16fc3ab8312c0d.tar.zst
coredns-123a76c91ead7fb57e801f974a16fc3ab8312c0d.zip
middleware/proxy: absorb httpproxy (#481)
* middleware/proxy: absorb httpproxy Move the httproxy into proxy. This adds and Exchanger interface which is used to exchange the messages with the upstream. The https_google upstream will re-resolve itself and update the upstream hosts used every 300s. * Remove and add TODO
Diffstat (limited to 'middleware/proxy/dns.go')
-rw-r--r--middleware/proxy/dns.go21
1 files changed, 8 insertions, 13 deletions
diff --git a/middleware/proxy/dns.go b/middleware/proxy/dns.go
index 51633c268..4fde48e40 100644
--- a/middleware/proxy/dns.go
+++ b/middleware/proxy/dns.go
@@ -12,23 +12,20 @@ import (
type dnsEx struct {
Timeout time.Duration
- Address string // address/name of this upstream
-
- group *singleflight.Group
+ group *singleflight.Group
}
-func newDNSEx(address string) *dnsEx {
- return &dnsEx{Address: address, group: new(singleflight.Group), Timeout: defaultTimeout * time.Second}
+func newDNSEx() *dnsEx {
+ return &dnsEx{group: new(singleflight.Group), Timeout: defaultTimeout * time.Second}
}
-func (d *dnsEx) OnStartup() error { return nil }
-func (d *dnsEx) OnShutdown() error { return nil }
-func (d *dnsEx) SetUpstream(u Upstream) error { return nil }
-func (d *dnsEx) Protocol() protocol { return dnsProto }
+func (g *dnsEx) Protocol() string { return "dns" }
+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(state request.Request) (*dns.Msg, error) {
- co, err := net.DialTimeout(state.Proto(), d.Address, d.Timeout)
+func (d *dnsEx) Exchange(addr string, state request.Request) (*dns.Msg, error) {
+ co, err := net.DialTimeout(state.Proto(), addr, d.Timeout)
if err != nil {
return nil, err
}
@@ -101,5 +98,3 @@ func exchange(m *dns.Msg, co net.Conn) (dns.Msg, error) {
}
return *r, err
}
-
-const dnsProto protocol = "dns"