diff options
author | 2017-06-21 23:46:20 -0700 | |
---|---|---|
committer | 2017-06-21 23:46:20 -0700 | |
commit | 9fb266aebeabf626d9b34659cd96b31e4111a600 (patch) | |
tree | 431f688b56add4c9f498283e607cbe8a3a957c7f /middleware/file/zone.go | |
parent | 9e463e0bca3f7c4275150dd36d1d4a020293ff90 (diff) | |
download | coredns-9fb266aebeabf626d9b34659cd96b31e4111a600.tar.gz coredns-9fb266aebeabf626d9b34659cd96b31e4111a600.tar.zst coredns-9fb266aebeabf626d9b34659cd96b31e4111a600.zip |
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.
Diffstat (limited to 'middleware/file/zone.go')
-rw-r--r-- | middleware/file/zone.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/middleware/file/zone.go b/middleware/file/zone.go index 7592798f0..a216f8af8 100644 --- a/middleware/file/zone.go +++ b/middleware/file/zone.go @@ -2,6 +2,7 @@ package file import ( "fmt" + "net" "path" "strings" "sync" @@ -55,12 +56,12 @@ func NewZone(name, file string) *Zone { return z } -// Copy copies a zone *without* copying the zone's content. It is not a deep copy. func (z *Zone) Copy() *Zone { z1 := NewZone(z.origin, z.file) z1.TransferTo = z.TransferTo z1.TransferFrom = z.TransferFrom z1.Expired = z.Expired + z1.Apex = z.Apex return z1 } @@ -113,11 +114,20 @@ func (z *Zone) Insert(r dns.RR) error { func (z *Zone) Delete(r dns.RR) { z.Tree.Delete(r) } // TransferAllowed checks if incoming request for transferring the zone is allowed according to the ACLs. -func (z *Zone) TransferAllowed(req request.Request) bool { +func (z *Zone) TransferAllowed(state request.Request) bool { for _, t := range z.TransferTo { if t == "*" { return true } + // If remote IP matches we accept. + remote := state.IP() + to, _, err := net.SplitHostPort(t) + if err != nil { + continue + } + if to == remote { + return true + } } // TODO(miek): future matching against IP/CIDR notations return false |