aboutsummaryrefslogtreecommitdiff
path: root/middleware/file/zone.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2016-03-28 12:08:05 +0100
committerGravatar Miek Gieben <miek@miek.nl> 2016-03-28 18:23:17 +0100
commite56d206542c901a48b28c4501fe5805e9e9e1a10 (patch)
tree77a644f6fe28f3de8eaf6f7c766cea73b438b487 /middleware/file/zone.go
parent6324bb1fa7c0516ef3bebfb822a0cdc767764ad2 (diff)
downloadcoredns-e56d206542c901a48b28c4501fe5805e9e9e1a10.tar.gz
coredns-e56d206542c901a48b28c4501fe5805e9e9e1a10.tar.zst
coredns-e56d206542c901a48b28c4501fe5805e9e9e1a10.zip
Support outgoing zone transfers
These can be enabled by adding "transfer out" to the Corefile. Without it no AXFR is allowed. For now only AXFR and no IXFR. No TSIG and no ACLs.
Diffstat (limited to 'middleware/file/zone.go')
-rw-r--r--middleware/file/zone.go38
1 files changed, 36 insertions, 2 deletions
diff --git a/middleware/file/zone.go b/middleware/file/zone.go
index 57eb8d997..bac420669 100644
--- a/middleware/file/zone.go
+++ b/middleware/file/zone.go
@@ -1,20 +1,29 @@
package file
import (
+ "github.com/miekg/coredns/middleware"
"github.com/miekg/coredns/middleware/file/tree"
"github.com/miekg/dns"
)
+type Transfer struct {
+ Out bool
+ In bool
+ // more later
+}
+
type Zone struct {
SOA *dns.SOA
- SIG []*dns.RRSIG
+ SIG []dns.RR
name string
*tree.Tree
+ Masters []string
+ Transfer *Transfer
}
func NewZone(name string) *Zone {
- return &Zone{name: dns.Fqdn(name), Tree: &tree.Tree{}}
+ return &Zone{name: dns.Fqdn(name), Tree: &tree.Tree{}, Transfer: &Transfer{}}
}
func (z *Zone) Insert(r dns.RR) {
@@ -24,3 +33,28 @@ func (z *Zone) Insert(r dns.RR) {
func (z *Zone) Delete(r dns.RR) {
z.Tree.Delete(r)
}
+
+// It the transfer request allowed.
+func (z *Zone) TransferAllowed(state middleware.State) bool {
+ if z.Transfer == nil {
+ return false
+ }
+ return z.Transfer.Out
+}
+
+// All returns all records from the zone, the first record will be the SOA record,
+// otionally followed by all RRSIG(SOA)s.
+func (z *Zone) All() []dns.RR {
+ records := []dns.RR{}
+ allNodes := z.Tree.All()
+ for _, a := range allNodes {
+ records = append(records, a.All()...)
+ }
+
+ if len(z.SIG) > 0 {
+ records = append(z.SIG, records...)
+ }
+ return append([]dns.RR{z.SOA}, records...)
+}
+
+// Apex function?