-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
171 lines (167 loc) · 3.12 KB
/
types.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// Package qry [general utility functions for the dnsblast package]
package qry
import "github.com/miekg/dns"
// ResponseCode converts numerical response code value to string.
func ResponseCode(rc int) string {
rcodes := map[int]string{
0: "NOERROR",
1: "FORMERR",
2: "SERVFAIL",
3: "NXDOMAIN",
4: "NOTIMP",
5: "REFUSED",
6: "YXDOMAIN",
7: "YXRRSET",
8: "NOTAUTH",
9: "NOTZONE",
}
return rcodes[rc]
}
// Qtype converts string representation of query type into a proper DNS format.
//nolint:cyclop,gocyclo,maintidx,funlen // The string map alternative is orders of magnitude slower
func Qtype(qt string) uint16 {
switch qt {
case "None":
return dns.TypeNone
case "A":
return dns.TypeA
case "NS":
return dns.TypeNS
case "MD":
return dns.TypeMD
case "MF":
return dns.TypeMF
case "CNAME":
return dns.TypeCNAME
case "SOA":
return dns.TypeSOA
case "MB":
return dns.TypeMB
case "MG":
return dns.TypeMG
case "MR":
return dns.TypeMR
case "NULL":
return dns.TypeNULL
case "PTR":
return dns.TypePTR
case "HINFO":
return dns.TypeHINFO
case "MINFO":
return dns.TypeMINFO
case "MX":
return dns.TypeMX
case "TXT":
return dns.TypeTXT
case "RP":
return dns.TypeRP
case "AFSDB":
return dns.TypeAFSDB
case "X25":
return dns.TypeX25
case "ISDN":
return dns.TypeISDN
case "RT":
return dns.TypeRT
case "NSAPPTR":
return dns.TypeNSAPPTR
case "SIG":
return dns.TypeSIG
case "KEY":
return dns.TypeKEY
case "PX":
return dns.TypePX
case "GPOS":
return dns.TypeGPOS
case "AAAA":
return dns.TypeAAAA
case "LOC":
return dns.TypeLOC
case "NXT":
return dns.TypeNXT
case "EID":
return dns.TypeEID
case "NIMLOC":
return dns.TypeNIMLOC
case "SRV":
return dns.TypeSRV
case "ATMA":
return dns.TypeATMA
case "NAPTR":
return dns.TypeNAPTR
case "KX":
return dns.TypeKX
case "CERT":
return dns.TypeCERT
case "DNAME":
return dns.TypeDNAME
case "OPT":
return dns.TypeOPT
case "DS":
return dns.TypeDS
case "SSHFP":
return dns.TypeSSHFP
case "RRSIG":
return dns.TypeRRSIG
case "NSEC":
return dns.TypeNSEC
case "DNSKEY":
return dns.TypeDNSKEY
case "DHCID":
return dns.TypeDHCID
case "NSEC3":
return dns.TypeNSEC3
case "NSEC3PARAM":
return dns.TypeNSEC3PARAM
case "TLSA":
return dns.TypeTLSA
case "SMIMEA":
return dns.TypeSMIMEA
case "HIP":
return dns.TypeHIP
case "NINFO":
return dns.TypeNINFO
case "RKEY":
return dns.TypeRKEY
case "TALINK":
return dns.TypeTALINK
case "CDS":
return dns.TypeCDS
case "CDNSKEY":
return dns.TypeCDNSKEY
case "OPENPGPKEY":
return dns.TypeOPENPGPKEY
case "CSYNC":
return dns.TypeCSYNC
case "SPF":
return dns.TypeSPF
case "UINFO":
return dns.TypeUINFO
case "UID":
return dns.TypeUID
case "GID":
return dns.TypeGID
case "UNSPEC":
return dns.TypeUNSPEC
case "NID":
return dns.TypeNID
case "L32":
return dns.TypeL32
case "L64":
return dns.TypeL64
case "LP":
return dns.TypeLP
case "EUI48":
return dns.TypeEUI48
case "EUI64":
return dns.TypeEUI64
case "URI":
return dns.TypeURI
case "CAA":
return dns.TypeCAA
case "AVC":
return dns.TypeAVC
default:
return dns.TypeA
}
}