-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtypes.js
232 lines (228 loc) · 4.89 KB
/
types.js
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*
* Copyright (c) 2021 RethinkDNS and its authors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Mathias Buus
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
//forked with minor changes from https://github.com/mafintosh/dns-packet
"use strict";
export function toString(type) {
switch (type) {
case 1:
return "A";
case 10:
return "NULL";
case 28:
return "AAAA";
case 18:
return "AFSDB";
case 42:
return "APL";
case 257:
return "CAA";
case 60:
return "CDNSKEY";
case 59:
return "CDS";
case 37:
return "CERT";
case 5:
return "CNAME";
case 49:
return "DHCID";
case 32769:
return "DLV";
case 39:
return "DNAME";
case 48:
return "DNSKEY";
case 43:
return "DS";
case 55:
return "HIP";
case 13:
return "HINFO";
case 45:
return "IPSECKEY";
case 25:
return "KEY";
case 36:
return "KX";
case 29:
return "LOC";
case 15:
return "MX";
case 35:
return "NAPTR";
case 2:
return "NS";
case 47:
return "NSEC";
case 50:
return "NSEC3";
case 51:
return "NSEC3PARAM";
case 12:
return "PTR";
case 46:
return "RRSIG";
case 17:
return "RP";
case 24:
return "SIG";
case 6:
return "SOA";
case 99:
return "SPF";
case 33:
return "SRV";
case 44:
return "SSHFP";
case 32768:
return "TA";
case 249:
return "TKEY";
case 52:
return "TLSA";
case 250:
return "TSIG";
case 16:
return "TXT";
case 252:
return "AXFR";
case 251:
return "IXFR";
case 41:
return "OPT";
case 255:
return "ANY";
case 64: // https svcb code change
return "SVCB";
case 65: // https svcb code change
return "HTTPS";
}
return "UNKNOWN_" + type;
}
export function toType(name) {
switch (name.toUpperCase()) {
case "A":
return 1;
case "NULL":
return 10;
case "AAAA":
return 28;
case "AFSDB":
return 18;
case "APL":
return 42;
case "CAA":
return 257;
case "CDNSKEY":
return 60;
case "CDS":
return 59;
case "CERT":
return 37;
case "CNAME":
return 5;
case "DHCID":
return 49;
case "DLV":
return 32769;
case "DNAME":
return 39;
case "DNSKEY":
return 48;
case "DS":
return 43;
case "HIP":
return 55;
case "HINFO":
return 13;
case "IPSECKEY":
return 45;
case "KEY":
return 25;
case "KX":
return 36;
case "LOC":
return 29;
case "MX":
return 15;
case "NAPTR":
return 35;
case "NS":
return 2;
case "NSEC":
return 47;
case "NSEC3":
return 50;
case "NSEC3PARAM":
return 51;
case "PTR":
return 12;
case "RRSIG":
return 46;
case "RP":
return 17;
case "SIG":
return 24;
case "SOA":
return 6;
case "SPF":
return 99;
case "SRV":
return 33;
case "SSHFP":
return 44;
case "TA":
return 32768;
case "TKEY":
return 249;
case "TLSA":
return 52;
case "TSIG":
return 250;
case "TXT":
return 16;
case "AXFR":
return 252;
case "IXFR":
return 251;
case "OPT":
return 41;
case "ANY":
return 255;
case "*":
return 255;
case "SVCB": // https svcb code change
return 64;
case "HTTPS": // https svcb code change
return 65;
}
if (name.toUpperCase().startsWith("UNKNOWN_")) return parseInt(name.slice(8));
return 0;
}