| 1 |
package dnszone |
| 2 |
|
| 3 |
import ( |
| 4 |
"strings" |
| 5 |
|
| 6 |
"codeberg.org/miekg/dns" |
| 7 |
) |
| 8 |
|
| 9 |
// Restart is used in the (recursive) calling of Retrieve to complete a CNAME chain. The i index is used to avoid loops |
| 10 |
// in the recursion and we break at 8. |
| 11 |
type Restart struct { |
| 12 |
Name string // original qname that started this sequence |
| 13 |
Answer []dns.RR // current set of RRs that need to go in the final response |
| 14 |
I int // break recursion at I > 7 |
| 15 |
} |
| 16 |
|
| 17 |
// A Node is a DNS node in the tree. |
| 18 |
type Node struct { |
| 19 |
Name string |
| 20 |
RRs []dns.RR // all the rrs with owner name 'name'. |
| 21 |
} |
| 22 |
|
| 23 |
func (n *Node) String() string { |
| 24 |
// TODO(miek): builderPool for all of these? |
| 25 |
sb := strings.Builder{} |
| 26 |
for i := range n.RRs { |
| 27 |
sb.WriteString(n.RRs[i].String()) |
| 28 |
sb.WriteByte('\n') |
| 29 |
} |
| 30 |
return sb.String() |
| 31 |
} |
| 32 |
|
| 33 |
// Less compares nodes a, b by Name and returns true if a is less than b. |
| 34 |
func Less(a, b *Node) bool { return dns.CompareName(a.Name, b.Name) == -1 } |