diff options
author | 2016-04-05 10:53:23 +0100 | |
---|---|---|
committer | 2016-04-05 10:53:23 +0100 | |
commit | c961acbb6e9e06279d3dca077ba47d8a6170da20 (patch) | |
tree | 8cbcb55515965a94d3fb0395a7d54e7e4e84c2a0 /middleware/file/notify.go | |
parent | 20e16491ec7495adc07aef7d506463f15a2b6733 (diff) | |
download | coredns-c961acbb6e9e06279d3dca077ba47d8a6170da20.tar.gz coredns-c961acbb6e9e06279d3dca077ba47d8a6170da20.tar.zst coredns-c961acbb6e9e06279d3dca077ba47d8a6170da20.zip |
Add complete secondary support
Respond to notifies and allow a secondary to follow the SOA parameters
to update a zone from a primary. Also sprinkle it with logging.
Also extend monitoring to include qtype in more metrics.
Diffstat (limited to 'middleware/file/notify.go')
-rw-r--r-- | middleware/file/notify.go | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/middleware/file/notify.go b/middleware/file/notify.go index 6667fb05d..a88ca9192 100644 --- a/middleware/file/notify.go +++ b/middleware/file/notify.go @@ -9,7 +9,26 @@ import ( "github.com/miekg/dns" ) -// Notify will send notifies to all configured IP addresses. +// isNotify checks if state is a notify message and if so, will *also* check if it +// is from one of the configured masters. If not it will not be a valid notify +// message. If the zone z is not a secondary zone the message will also be ignored. +func (z *Zone) isNotify(state middleware.State) bool { + if state.Req.Opcode != dns.OpcodeNotify { + return false + } + if len(z.TransferFrom) == 0 { + return false + } + remote := middleware.Addr(state.IP()).Normalize() + for _, from := range z.TransferFrom { + if from == remote { + return true + } + } + return false +} + +// Notify will send notifies to all configured TransferTo IP addresses. func (z *Zone) Notify() { go notify(z.name, z.TransferTo) } @@ -23,6 +42,10 @@ func notify(zone string, to []string) error { c := new(dns.Client) for _, t := range to { + // TODO(miek): these ACLs thingies not to be formalized. + if t == "*" { + continue + } if err := notifyAddr(c, m, t); err != nil { log.Printf("[ERROR] " + err.Error()) } else { @@ -35,7 +58,10 @@ func notify(zone string, to []string) error { func notifyAddr(c *dns.Client, m *dns.Msg, s string) error { for i := 0; i < 3; i++ { ret, err := middleware.Exchange(c, m, s) - if err == nil && ret.Rcode == dns.RcodeSuccess || ret.Rcode == dns.RcodeNotImplemented { + if err != nil { + continue + } + if ret.Rcode == dns.RcodeSuccess || ret.Rcode == dns.RcodeNotImplemented { return nil } } |