diff options
author | 2016-04-03 09:02:34 +0100 | |
---|---|---|
committer | 2016-04-03 09:02:34 +0100 | |
commit | f58f1e4285ab9725a317ac7b38f5905fb497c7b0 (patch) | |
tree | b44eead7ca9f687bea1813cfe7247123d8929026 /middleware/file/secondary.go | |
parent | 7fb959470e95517967c4f0bcf85f1adf9a77a42f (diff) | |
download | coredns-f58f1e4285ab9725a317ac7b38f5905fb497c7b0.tar.gz coredns-f58f1e4285ab9725a317ac7b38f5905fb497c7b0.tar.zst coredns-f58f1e4285ab9725a317ac7b38f5905fb497c7b0.zip |
Add secondary support
Allow specifying a primary server and retrieve the zone's content.
Add tests and an Expired bool to zone struct, to stop server zones
that are expired. The zone is retrieved on Startup, no updates of
changed content are done. We also don't respond to notifies yet.
Diffstat (limited to 'middleware/file/secondary.go')
-rw-r--r-- | middleware/file/secondary.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/middleware/file/secondary.go b/middleware/file/secondary.go new file mode 100644 index 000000000..95c063a9b --- /dev/null +++ b/middleware/file/secondary.go @@ -0,0 +1,63 @@ +package file + +import ( + "log" + + "github.com/miekg/dns" +) + +// TransferIn retrieves the zone from the masters, parses it and sets it live. +func (z *Zone) TransferIn() error { + if len(z.TransferFrom) == 0 { + return nil + } + t := new(dns.Transfer) + m := new(dns.Msg) + m.SetAxfr(z.name) + /* + t.TsigSecret = map[string]string{"axfr.": "so6ZGir4GPAqINNh9U5c3A=="} + m.SetTsig("axfr.", dns.HmacMD5, 300, time.Now().Unix()) + */ + + var Err error +Transfer: + for _, tr := range z.TransferFrom { + c, err := t.In(m, tr) + if err != nil { + log.Printf("[ERROR] failed to setup transfer %s with %s: %v", z.name, z.TransferFrom[0], err) + Err = err + continue Transfer + } + for env := range c { + if env.Error != nil { + log.Printf("[ERROR] failed to parse transfer %s: %v", z.name, env.Error) + Err = env.Error + continue Transfer + } + for _, rr := range env.RR { + if rr.Header().Rrtype == dns.TypeSOA { + z.SOA = rr.(*dns.SOA) + continue + } + if rr.Header().Rrtype == dns.TypeRRSIG { + if x, ok := rr.(*dns.RRSIG); ok && x.TypeCovered == dns.TypeSOA { + z.SIG = append(z.SIG, x) + } + } + z.Insert(rr) + } + } + } + return Err +} + +/* + + 28800 ; refresh (8 hours) + 7200 ; retry (2 hours) + 604800 ; expire (1 week) + 3600 ; minimum (1 hour) +// Check SOA +// Just check every refresh hours, if fail set to retry until succeeds +// expire is need: to give SERVFAIL. +*/ |