aboutsummaryrefslogtreecommitdiff
path: root/plugin/file/rrutil/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/file/rrutil/util.go')
-rw-r--r--plugin/file/rrutil/util.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/plugin/file/rrutil/util.go b/plugin/file/rrutil/util.go
new file mode 100644
index 000000000..63e447196
--- /dev/null
+++ b/plugin/file/rrutil/util.go
@@ -0,0 +1,29 @@
+// Package rrutil provides function to find certain RRs in slices.
+package rrutil
+
+import "github.com/miekg/dns"
+
+// SubTypeSignature returns the RRSIG for the subtype.
+func SubTypeSignature(rrs []dns.RR, subtype uint16) []dns.RR {
+ sigs := []dns.RR{}
+ // there may be multiple keys that have signed this subtype
+ for _, sig := range rrs {
+ if s, ok := sig.(*dns.RRSIG); ok {
+ if s.TypeCovered == subtype {
+ sigs = append(sigs, s)
+ }
+ }
+ }
+ return sigs
+}
+
+// CNAMEForType returns the RR that have the qtype from targets.
+func CNAMEForType(rrs []dns.RR, qtype uint16) []dns.RR {
+ ret := []dns.RR{}
+ for _, target := range rrs {
+ if target.Header().Rrtype == qtype {
+ ret = append(ret, target)
+ }
+ }
+ return ret
+}