diff options
Diffstat (limited to 'plugin/etcd')
-rw-r--r-- | plugin/etcd/README.md | 7 | ||||
-rw-r--r-- | plugin/etcd/etcd.go | 5 | ||||
-rw-r--r-- | plugin/etcd/handler.go | 2 | ||||
-rw-r--r-- | plugin/etcd/lookup_test.go | 4 | ||||
-rw-r--r-- | plugin/etcd/setup.go | 10 |
5 files changed, 16 insertions, 12 deletions
diff --git a/plugin/etcd/README.md b/plugin/etcd/README.md index fcc99a93d..085173981 100644 --- a/plugin/etcd/README.md +++ b/plugin/etcd/README.md @@ -32,7 +32,7 @@ etcd [ZONES...] { fallthrough [ZONES...] path PATH endpoint ENDPOINT... - upstream ADDRESS... + upstream [ADDRESS...] tls CERT KEY CACERT } ~~~ @@ -47,8 +47,9 @@ etcd [ZONES...] { * **ENDPOINT** the etcd endpoints. Defaults to "http://localhost:2379". * `upstream` upstream resolvers to be used resolve external names found in etcd (think CNAMEs) pointing to external names. If you want CoreDNS to act as a proxy for clients, you'll need to add - the proxy plugin. **ADDRESS** can be an IP address, and IP:port or a string pointing to a file - that is structured as /etc/resolv.conf. + the proxy plugin. If no **ADDRESS** is given, CoreDNS will resolve CNAMEs against itself. + **ADDRESS** can be an IP address, and IP:port or a string pointing to a file that is structured + as /etc/resolv.conf. * `tls` followed by: * no arguments, if the server certificate is signed by a system-installed CA and no client cert is needed diff --git a/plugin/etcd/etcd.go b/plugin/etcd/etcd.go index fc0b60774..5fa66b90a 100644 --- a/plugin/etcd/etcd.go +++ b/plugin/etcd/etcd.go @@ -13,6 +13,7 @@ import ( "github.com/coredns/coredns/plugin/proxy" "github.com/coredns/coredns/request" + "github.com/coredns/coredns/plugin/pkg/upstream" etcdc "github.com/coreos/etcd/client" "github.com/miekg/dns" "golang.org/x/net/context" @@ -24,7 +25,7 @@ type Etcd struct { Fall fall.F Zones []string PathPrefix string - Proxy proxy.Proxy // Proxy for looking up names during the resolution process + Upstream upstream.Upstream // Proxy for looking up names during the resolution process Client etcdc.KeysAPI Ctx context.Context Stubmap *map[string]proxy.Proxy // list of proxies for stub resolving. @@ -50,7 +51,7 @@ func (e *Etcd) Reverse(state request.Request, exact bool, opt plugin.Options) (s // Lookup implements the ServiceBackend interface. func (e *Etcd) Lookup(state request.Request, name string, typ uint16) (*dns.Msg, error) { - return e.Proxy.Lookup(state, name, typ) + return e.Upstream.Lookup(state, name, typ) } // IsNameError implements the ServiceBackend interface. diff --git a/plugin/etcd/handler.go b/plugin/etcd/handler.go index 6d2a7a2bf..a2f7fb7b9 100644 --- a/plugin/etcd/handler.go +++ b/plugin/etcd/handler.go @@ -12,7 +12,7 @@ import ( // ServeDNS implements the plugin.Handler interface. func (e *Etcd) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { opt := plugin.Options{} - state := request.Request{W: w, Req: r} + state := request.Request{W: w, Req: r, Context: ctx} name := state.Name() diff --git a/plugin/etcd/lookup_test.go b/plugin/etcd/lookup_test.go index a44f0dcd7..b25637fd8 100644 --- a/plugin/etcd/lookup_test.go +++ b/plugin/etcd/lookup_test.go @@ -10,6 +10,7 @@ import ( "github.com/coredns/coredns/plugin/etcd/msg" "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/pkg/tls" + "github.com/coredns/coredns/plugin/pkg/upstream" "github.com/coredns/coredns/plugin/proxy" "github.com/coredns/coredns/plugin/test" @@ -227,8 +228,9 @@ func newEtcdPlugin() *Etcd { tlsc, _ := tls.NewTLSConfigFromArgs() client, _ := newEtcdClient(endpoints, tlsc) + p := proxy.NewLookup([]string{"8.8.8.8:53"}) return &Etcd{ - Proxy: proxy.NewLookup([]string{"8.8.8.8:53"}), + Upstream: upstream.Upstream{Forward: &p}, PathPrefix: "skydns", Ctx: context.Background(), Zones: []string{"skydns.test.", "skydns_extra.test.", "in-addr.arpa."}, diff --git a/plugin/etcd/setup.go b/plugin/etcd/setup.go index 7d34c43f6..e9a1e013e 100644 --- a/plugin/etcd/setup.go +++ b/plugin/etcd/setup.go @@ -5,8 +5,8 @@ import ( "github.com/coredns/coredns/core/dnsserver" "github.com/coredns/coredns/plugin" - "github.com/coredns/coredns/plugin/pkg/dnsutil" mwtls "github.com/coredns/coredns/plugin/pkg/tls" + "github.com/coredns/coredns/plugin/pkg/upstream" "github.com/coredns/coredns/plugin/proxy" etcdc "github.com/coreos/etcd/client" @@ -90,13 +90,13 @@ func etcdParse(c *caddy.Controller) (*Etcd, bool, error) { case "upstream": args := c.RemainingArgs() if len(args) == 0 { - return &Etcd{}, false, c.ArgErr() + return nil, false, c.ArgErr() } - ups, err := dnsutil.ParseHostPortOrFile(args...) + u, err := upstream.NewUpstream(args) if err != nil { - return &Etcd{}, false, err + return nil, false, err } - etc.Proxy = proxy.NewLookup(ups) + etc.Upstream = u case "tls": // cert key cacertfile args := c.RemainingArgs() tlsConfig, err = mwtls.NewTLSConfigFromArgs(args...) |