forked from coredns/unbound
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdnssec.go
46 lines (39 loc) · 766 Bytes
/
dnssec.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
package unbound
import "github.com/miekg/dns"
// filter removes records from m, according to filter function.
func filter(m *dns.Msg, filter func(dns.RR) bool) {
rrs := []dns.RR{}
for _, r := range m.Answer {
if !filter(r) {
rrs = append(rrs, r)
}
}
m.Answer = rrs
rrs = []dns.RR{}
for _, r := range m.Ns {
if !filter(r) {
rrs = append(rrs, r)
}
}
m.Ns = rrs
rrs = []dns.RR{}
for _, r := range m.Extra {
if !filter(r) {
rrs = append(rrs, r)
}
}
m.Extra = rrs
}
// dnssec returns true if rr is an RRSIG, NSEC or NSEC3 record.
func dnssec(rr dns.RR) bool {
if _, ok := rr.(*dns.RRSIG); ok {
return true
}
if _, ok := rr.(*dns.NSEC); ok {
return true
}
if _, ok := rr.(*dns.NSEC3); ok {
return true
}
return false
}