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

@@ -23,7 +23,7 @@ A working syntax would be:
secondary [zones...] {
transfer from ADDRESS
transfer to ADDRESS
upstream ADDRESS...
upstream [ADDRESS...]
}
~~~
@@ -34,6 +34,7 @@ secondary [zones...] {
pointing to external names. This is only really useful when CoreDNS is configured as a proxy, for
normal authoritative serving you don't need *or* want to use this. **ADDRESS** can be an IP
address, and IP:port or a string pointing to a file that is structured as /etc/resolv.conf.
If no **ADDRESS** is given, CoreDNS will resolve CNAMEs against itself.
When a zone is due to be refreshed (Refresh timer fires) a random jitter of 5 seconds is
applied, before fetching. In the case of retry this will be 2 seconds. If there are any errors

View File

@@ -4,10 +4,9 @@ import (
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/file"
"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"
)
@@ -51,7 +50,7 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
z := make(map[string]*file.Zone)
names := []string{}
origins := []string{}
prxy := proxy.Proxy{}
upstr := upstream.Upstream{}
for c.Next() {
if c.Val() == "secondary" {
@@ -81,14 +80,11 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
}
case "upstream":
args := c.RemainingArgs()
if len(args) == 0 {
return file.Zones{}, c.ArgErr()
}
ups, err := dnsutil.ParseHostPortOrFile(args...)
var err error
upstr, err = upstream.NewUpstream(args)
if err != nil {
return file.Zones{}, err
}
prxy = proxy.NewLookup(ups)
default:
return file.Zones{}, c.Errf("unknown property '%s'", c.Val())
}
@@ -100,7 +96,7 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
if f != nil {
z[origin].TransferFrom = append(z[origin].TransferFrom, f...)
}
z[origin].Proxy = prxy
z[origin].Upstream = upstr
}
}
}