aboutsummaryrefslogtreecommitdiff
path: root/middleware/file/zone.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2016-04-03 09:02:34 +0100
committerGravatar Miek Gieben <miek@miek.nl> 2016-04-03 09:02:34 +0100
commitf58f1e4285ab9725a317ac7b38f5905fb497c7b0 (patch)
treeb44eead7ca9f687bea1813cfe7247123d8929026 /middleware/file/zone.go
parent7fb959470e95517967c4f0bcf85f1adf9a77a42f (diff)
downloadcoredns-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/zone.go')
-rw-r--r--middleware/file/zone.go27
1 files changed, 13 insertions, 14 deletions
diff --git a/middleware/file/zone.go b/middleware/file/zone.go
index 8c56b6bf9..c3567b45f 100644
--- a/middleware/file/zone.go
+++ b/middleware/file/zone.go
@@ -7,23 +7,22 @@ import (
"github.com/miekg/dns"
)
-type Transfer struct {
- Out bool
- In bool
-}
-
type Zone struct {
SOA *dns.SOA
SIG []dns.RR
name string
*tree.Tree
- Peers []string
- Transfer *Transfer
+
+ TransferTo []string
+ TransferFrom []string
+ Expired *bool
}
// NewZone returns a new zone.
func NewZone(name string) *Zone {
- return &Zone{name: dns.Fqdn(name), Tree: &tree.Tree{}, Transfer: &Transfer{}}
+ z := &Zone{name: dns.Fqdn(name), Tree: &tree.Tree{}, Expired: new(bool)}
+ *z.Expired = false
+ return z
}
// Insert inserts r into z.
@@ -32,12 +31,14 @@ func (z *Zone) Insert(r dns.RR) { z.Tree.Insert(r) }
// Delete deletes r from z.
func (z *Zone) Delete(r dns.RR) { z.Tree.Delete(r) }
-// It the transfer request allowed.
+// TransferAllowed checks if incoming request for transferring the zone is allowed according to the ACLs.
func (z *Zone) TransferAllowed(state middleware.State) bool {
- if z.Transfer == nil {
- return false
+ for _, t := range z.TransferTo {
+ if t == "*" {
+ return true
+ }
}
- return z.Transfer.Out
+ return false
}
// All returns all records from the zone, the first record will be the SOA record,
@@ -54,5 +55,3 @@ func (z *Zone) All() []dns.RR {
}
return append([]dns.RR{z.SOA}, records...)
}
-
-// Apex function?