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/file.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/file.go')
-rw-r--r-- | middleware/file/file.go | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/middleware/file/file.go b/middleware/file/file.go index a647f9d12..473b55574 100644 --- a/middleware/file/file.go +++ b/middleware/file/file.go @@ -28,7 +28,6 @@ func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i if state.QClass() != dns.ClassINET { return dns.RcodeServerFailure, fmt.Errorf("file: can only deal with ClassINET") } - qname := state.Name() zone := middleware.Zones(f.Zones.Names).Matches(qname) if zone == "" { @@ -41,7 +40,26 @@ func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i if z == nil { return dns.RcodeServerFailure, nil } + if r.Opcode == dns.OpcodeNotify { + if z.isNotify(state) { + m := new(dns.Msg) + m.SetReply(r) + m.Authoritative, m.RecursionAvailable, m.Compress = true, true, true + w.WriteMsg(m) + + if ok, _ := z.shouldTransfer(); ok { + log.Printf("[INFO] Valid notify from %s for %s: initiating transfer", state.IP(), zone) + z.TransferIn() + } + + return dns.RcodeSuccess, nil + } + log.Printf("[INFO] Dropping notify from %s for %s", state.IP(), zone) + return dns.RcodeSuccess, nil + } + if z.Expired != nil && *z.Expired { + log.Printf("[ERROR] Zone %s is expired", zone) return dns.RcodeServerFailure, nil } @@ -81,7 +99,7 @@ func Parse(f io.Reader, origin, fileName string) (*Zone, error) { z := NewZone(origin) for x := range tokens { if x.Error != nil { - log.Printf("[ERROR] failed to parse %s: %v", origin, x.Error) + log.Printf("[ERROR] Failed to parse %s: %v", origin, x.Error) return nil, x.Error } if x.RR.Header().Rrtype == dns.TypeSOA { |