forked from mafintosh/dns-packet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.js
103 lines (101 loc) · 2.61 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
'use strict'
exports.toString = function (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'
}
return 'UNKNOWN_' + type
}
exports.toType = function (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
}
if (name.toUpperCase().startsWith('UNKNOWN_')) return parseInt(name.slice(8))
return 0
}