middleware/secondary: multiple fixes (#745)

Fix transferring the zone from a master and the matching of notifies
to source and dst IP addresses.

Add `upstream` keyword as well, because it is needed for the same
reasons as in the *file* middlware.
Add some dire warning about upstream in the readme of both middlewares.

Out of band testing, hidden by net build tag was added. Integration
testing still needs to be setup.
This commit is contained in:
Miek Gieben
2017-06-21 23:46:20 -07:00
committed by GitHub
parent 9e463e0bca
commit 9fb266aebe
8 changed files with 171 additions and 12 deletions

View File

@@ -16,13 +16,17 @@ A working syntax would be:
~~~
secondary [zones...] {
transfer from ADDRESS
[transfer to ADDRESS]
transfer to ADDRESS
upstream ADDRESS...
}
~~~
* `transfer from` specifies from which address to fetch the zone. It can be specified multiple times;
if one does not work, another will be tried.
* `transfer to` can be enabled to allow this secondary zone to be transferred again.
* `upstream` defines upstream resolvers to be used resolve external names found (think CNAMEs)
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.
## Examples

View File

@@ -4,6 +4,8 @@ import (
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/middleware"
"github.com/coredns/coredns/middleware/file"
"github.com/coredns/coredns/middleware/pkg/dnsutil"
"github.com/coredns/coredns/middleware/proxy"
"github.com/mholt/caddy"
)
@@ -47,6 +49,7 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
z := make(map[string]*file.Zone)
names := []string{}
origins := []string{}
prxy := proxy.Proxy{}
for c.Next() {
if c.Val() == "secondary" {
@@ -74,6 +77,16 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
if e != nil {
return file.Zones{}, e
}
case "upstream":
args := c.RemainingArgs()
if len(args) == 0 {
return file.Zones{}, c.ArgErr()
}
ups, err := dnsutil.ParseHostPortOrFile(args...)
if err != nil {
return file.Zones{}, err
}
prxy = proxy.NewLookup(ups)
}
for _, origin := range origins {
@@ -83,6 +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
}
}
}