| 1 |
package dnszone |
| 2 |
|
| 3 |
import "codeberg.org/miekg/dns" |
| 4 |
|
| 5 |
// Interface defines the methods for each db* implementation. This is currently unused, and if used |
| 6 |
// this needs to live in the pkg/db or something, not tucked away here. |
| 7 |
// |
| 8 |
// This is the interface dbfile implements on top of the b-tree. And dbsqlite on top of an SQLite database. |
| 9 |
type Interface interface { |
| 10 |
// Load loads a zone. |
| 11 |
Load() error |
| 12 |
// Get returns the node under key. The boolean is true when something is found. |
| 13 |
Get(string) (*Node, bool) |
| 14 |
// Previous returns the previous node for string. If the node under key exists that one is returned. |
| 15 |
Previous(string) *Node |
| 16 |
// Set sets a node in the zone. It must take care to also fill out any empty non-terminals that are |
| 17 |
// needed. |
| 18 |
Set(*Node) string |
| 19 |
// Apex returns the apex of the zone. If the apex/zone is not there yet, this method must return an empty |
| 20 |
// node, not nil. |
| 21 |
Apex() *Node |
| 22 |
// Origin returns the origin of the zone as string. |
| 23 |
Origin() string |
| 24 |
// Labels returns the number of labels from the origin. This is method to allow the implementation some |
| 25 |
// head room for optimizations. |
| 26 |
Labels() int |
| 27 |
// Walk walks the entire walk starting at the apex. |
| 28 |
Walk(func(*Node) bool) |
| 29 |
// AuthoritativeWalk walks the entire zone starting at the apex, but skips non-authoritative records: |
| 30 |
// delegated (or should have been delegated) and glue recors. |
| 31 |
AuthoritativeWalk(func(*Node, bool) bool) |
| 32 |
} |
| 33 |
|
| 34 |
// Serial returns the SOA serial number of z, 0 is returned if there is none. |
| 35 |
func Serial(z Interface) uint32 { |
| 36 |
apex := z.Apex() |
| 37 |
for _, rr := range apex.RRs { |
| 38 |
if s, ok := rr.(*dns.SOA); ok { |
| 39 |
return s.Serial |
| 40 |
} |
| 41 |
} |
| 42 |
return 0 |
| 43 |
} |