blob: bac4206696979560d78a016a2aa71d3b281abd26 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
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.RR
name string
*tree.Tree
Masters []string
Transfer *Transfer
}
func NewZone(name string) *Zone {
return &Zone{name: dns.Fqdn(name), Tree: &tree.Tree{}, Transfer: &Transfer{}}
}
func (z *Zone) Insert(r dns.RR) {
z.Tree.Insert(r)
}
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?
|