-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.go
111 lines (83 loc) · 2.81 KB
/
interface.go
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package dnsutils
import (
"fmt"
"github.com/miekg/dns"
)
var (
// ErrNotSupport returns when method is not implemented.
ErrNotSupport = fmt.Errorf("not support")
// ErrNotChangeAble returns by change methods when can not change values.
ErrNotChangeAble = fmt.Errorf("not changeable")
)
// ZoneInterface manages zone root node
type ZoneInterface interface {
// return canonical zone name
GetName() string
GetRootNode() NameNodeInterface
GetClass() dns.Class
}
// NameNodeInterface manages node of name tree
type NameNodeInterface interface {
// GetName returns canonical name
GetName() string
// GetName returns class
GetClass() dns.Class
// GetNameNode returns NameNode by target name
// if return value isStrict is true, NameNode is target name NameNode. (strict match)
// if isStrict is false and node nos it nil, node is nearly parrent path node. (loose match)
// if isStrict is false and node is nil, target name is not in-domain.
GetNameNode(target string) (node NameNodeInterface, isStrict bool)
// CopyChildNodes returns child name node map
// map key is canonical name
CopyChildNodes() map[string]NameNodeInterface
// CopyRRSetMap returns rrset map
// map key is uint16 rrtype
CopyRRSetMap() map[uint16]RRSetInterface
// GetRRSet returns rrset by rrtype
// if not exist rrset return nil
GetRRSet(rrtype uint16) RRSetInterface
// IterateNameRRSet can iterate function by RRSetInterface
// sort oreder is implementation dependent.
IterateNameRRSet(func(RRSetInterface) error) error
// IterateNameNode can iterate function by NameNodeInterface
// sort oreder is implementation dependent.
IterateNameNode(func(NameNodeInterface) error) error
// IterateNameNode can iterate function by NameNodeInterface
// sort oreder is implementation dependent.
IterateNameNodeWithValue(f func(NameNodeInterface, any) (any, error), v any) error
// AddChildNode adds child node into children.
AddChildNameNode(NameNodeInterface) error
// RemoveNameNode removed child node.
RemoveChildNameNode(name string) error
// SetValue override child and rrsetMap
SetValue(NameNodeInterface) error
// SetRRSet overrides rrset
SetRRSet(RRSetInterface) error
// RemoveRRSet removes rrset
RemoveRRSet(rrtype uint16) error
// RRSetLen returns the number of not empty rrset
RRSetLen() int
}
// RRSetInterface manages rrset
type RRSetInterface interface {
// GetName returns canonical name
GetName() string
// GetRRtype returns rrtype
GetRRtype() uint16
// GetClass returns dns.Class
GetClass() dns.Class
// GetTTL returns rtype
GetTTL() uint32
// SetTTL sets ttl
SetTTL(uint32) error
// GetRRs returns rr slice
GetRRs() []dns.RR
// Len returns number of rdata
Len() int
// AddRR adds dns.RR
AddRR(dns.RR) error
// RemoveRR removes dns.RR
RemoveRR(dns.RR) error
// Copy returns a copy
Copy() RRSetInterface
}