mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 10:43:17 -04:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user