aboutsummaryrefslogtreecommitdiff
path: root/plugin/pkg/dnsutil/monitor.go
blob: b86f8e43a0d622b369d465f85dc04abeb9b09be9 (plain) (blame)
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
package dnsutil

import (
	"github.com/miekg/dns"
)

var monitorType = map[uint16]struct{}{
	dns.TypeAAAA:   {},
	dns.TypeA:      {},
	dns.TypeCNAME:  {},
	dns.TypeDNSKEY: {},
	dns.TypeDS:     {},
	dns.TypeMX:     {},
	dns.TypeNSEC3:  {},
	dns.TypeNSEC:   {},
	dns.TypeNS:     {},
	dns.TypePTR:    {},
	dns.TypeRRSIG:  {},
	dns.TypeSOA:    {},
	dns.TypeSRV:    {},
	dns.TypeTXT:    {},
	// Meta Qtypes
	dns.TypeIXFR: {},
	dns.TypeAXFR: {},
	dns.TypeANY:  {},
}

const other = "other"

// QTypeMonitorLabel returns dns type label based on a list of monitored types.
// Will return "other" for unmonitored ones.
func QTypeMonitorLabel(qtype uint16) string {
	if _, known := monitorType[qtype]; known {
		return dns.Type(qtype).String()
	}
	return other
}