plugin/auto/file/secondary: Use new upstream resolver (#1534)

* move file, auto, secondary to new upstream

* include context in request
This commit is contained in:
Chris O'Haver
2018-02-16 03:44:50 -05:00
committed by Miek Gieben
parent fc1d73ffa9
commit ba573c0f40
12 changed files with 30 additions and 36 deletions

View File

@@ -17,7 +17,7 @@ zonefile. New or changed zones are automatically picked up from disk.
auto [ZONES...] {
directory DIR [REGEXP ORIGIN_TEMPLATE [TIMEOUT]]
no_reload
upstream ADDRESS...
upstream [ADDRESS...]
}
~~~
@@ -35,7 +35,8 @@ are used.
SOA's serial has changed. This option disables that behavior.
* `upstream` defines upstream resolvers to be used resolve external names found (think CNAMEs)
pointing to external names. **ADDRESS** can be an IP address, an IP:port or a string pointing to
a file that is structured as /etc/resolv.conf.
a file that is structured as /etc/resolv.conf. If no **ADDRESS** is given, CoreDNS will resolve CNAMEs
against itself.
All directives from the *file* plugin are supported. Note that *auto* will load all zones found,
even though the directive might only receive queries for a specific zone. I.e:

View File

@@ -8,7 +8,7 @@ import (
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/file"
"github.com/coredns/coredns/plugin/metrics"
"github.com/coredns/coredns/plugin/proxy"
"github.com/coredns/coredns/plugin/pkg/upstream"
"github.com/coredns/coredns/request"
"github.com/miekg/dns"
@@ -33,7 +33,7 @@ type (
// In the future this should be something like ZoneMeta that contains all this stuff.
transferTo []string
noReload bool
proxy proxy.Proxy // Proxy for looking up names during the resolution process
upstream upstream.Upstream // Upstream for looking up names during the resolution process
duration time.Duration
}
@@ -41,7 +41,7 @@ type (
// ServeDNS implements the plugin.Handle interface.
func (a Auto) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
state := request.Request{W: w, Req: r}
state := request.Request{W: w, Req: r, Context: ctx}
qname := state.Name()
// TODO(miek): match the qname better in the map

View File

@@ -11,9 +11,8 @@ import (
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/metrics"
"github.com/coredns/coredns/plugin/pkg/dnsutil"
"github.com/coredns/coredns/plugin/pkg/parse"
"github.com/coredns/coredns/plugin/proxy"
"github.com/coredns/coredns/plugin/pkg/upstream"
"github.com/mholt/caddy"
)
@@ -151,11 +150,11 @@ func autoParse(c *caddy.Controller) (Auto, error) {
if len(args) == 0 {
return a, c.ArgErr()
}
ups, err := dnsutil.ParseHostPortOrFile(args...)
var err error
a.loader.upstream, err = upstream.NewUpstream(args)
if err != nil {
return a, err
}
a.loader.proxy = proxy.NewLookup(ups)
default:
t, _, e := parse.Transfer(c, false)

View File

@@ -53,7 +53,7 @@ func (a Auto) Walk() error {
}
zo.NoReload = a.loader.noReload
zo.Proxy = a.loader.proxy
zo.Upstream = a.loader.upstream
zo.TransferTo = a.loader.transferTo
a.Zones.Add(zo, origin)