diff options
Diffstat (limited to 'plugin/pkg/dnsutil/monitor.go')
-rw-r--r-- | plugin/pkg/dnsutil/monitor.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/plugin/pkg/dnsutil/monitor.go b/plugin/pkg/dnsutil/monitor.go new file mode 100644 index 000000000..b86f8e43a --- /dev/null +++ b/plugin/pkg/dnsutil/monitor.go @@ -0,0 +1,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 +} |