@nictool/dns-resource-record 1.1.7 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.yml +3 -0
- package/CHANGELOG.md +17 -43
- package/README.md +45 -47
- package/index.js +77 -29
- package/lib/tinydns.js +68 -61
- package/package.json +1 -2
- package/rr/a.js +19 -20
- package/rr/aaaa.js +35 -31
- package/rr/caa.js +41 -39
- package/rr/cert.js +21 -19
- package/rr/cname.js +19 -20
- package/rr/dname.js +19 -19
- package/rr/dnskey.js +48 -41
- package/rr/ds.js +38 -36
- package/rr/hinfo.js +26 -25
- package/rr/ipseckey.js +53 -45
- package/rr/key.js +21 -21
- package/rr/loc.js +67 -54
- package/rr/mx.js +26 -24
- package/rr/naptr.js +51 -52
- package/rr/ns.js +25 -22
- package/rr/nsec.js +26 -20
- package/rr/nsec3.js +63 -44
- package/rr/nsec3param.js +29 -26
- package/rr/nxt.js +67 -0
- package/rr/openpgpkey.js +13 -14
- package/rr/ptr.js +20 -21
- package/rr/rrsig.js +27 -21
- package/rr/sig.js +24 -19
- package/rr/smimea.js +35 -28
- package/rr/soa.js +57 -42
- package/rr/spf.js +20 -17
- package/rr/srv.js +41 -41
- package/rr/sshfp.js +29 -30
- package/rr/tlsa.js +47 -40
- package/rr/tsig.js +48 -0
- package/rr/txt.js +40 -33
- package/rr/uri.js +31 -31
- package/rr/wks.js +44 -0
- package/rr.js +111 -77
- package/.codeclimate.yml +0 -25
- package/DEVELOP.md +0 -23
- package/test/a.js +0 -76
- package/test/aaaa.js +0 -79
- package/test/base.js +0 -138
- package/test/caa.js +0 -104
- package/test/cert.js +0 -48
- package/test/cname.js +0 -41
- package/test/dname.js +0 -53
- package/test/dnskey.js +0 -44
- package/test/ds.js +0 -44
- package/test/fake.js +0 -26
- package/test/hinfo.js +0 -75
- package/test/ipseckey.js +0 -115
- package/test/key.js +0 -37
- package/test/loc.js +0 -71
- package/test/mx.js +0 -75
- package/test/naptr.js +0 -40
- package/test/ns.js +0 -53
- package/test/nsec.js +0 -38
- package/test/nsec3.js +0 -40
- package/test/nsec3param.js +0 -26
- package/test/openpgpkey.js +0 -35
- package/test/ptr.js +0 -54
- package/test/rr.js +0 -196
- package/test/smimea.js +0 -45
- package/test/soa.js +0 -77
- package/test/spf.js +0 -48
- package/test/srv.js +0 -81
- package/test/sshfp.js +0 -62
- package/test/tinydns.js +0 -140
- package/test/tlsa.js +0 -54
- package/test/txt.js +0 -70
- package/test/uri.js +0 -61
package/rr/naptr.js
CHANGED
|
@@ -1,136 +1,135 @@
|
|
|
1
|
-
|
|
2
1
|
import RR from '../rr.js'
|
|
3
2
|
import * as TINYDNS from '../lib/tinydns.js'
|
|
4
3
|
|
|
5
4
|
const rdataRe = /[\r\n\t:\\/]/
|
|
6
5
|
|
|
7
6
|
export default class NAPTR extends RR {
|
|
8
|
-
constructor
|
|
7
|
+
constructor(opts) {
|
|
9
8
|
super(opts)
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
getDescription
|
|
11
|
+
getDescription() {
|
|
13
12
|
return 'Naming Authority Pointer'
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
getQuotedFields
|
|
17
|
-
return [
|
|
15
|
+
getQuotedFields() {
|
|
16
|
+
return ['flags', 'service', 'regexp']
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
getRdataFields
|
|
21
|
-
return [
|
|
19
|
+
getRdataFields(arg) {
|
|
20
|
+
return ['order', 'preference', 'flags', 'service', 'regexp', 'replacement']
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
getRFCs
|
|
25
|
-
return [
|
|
23
|
+
getRFCs() {
|
|
24
|
+
return [2915, 3403]
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
getTypeId
|
|
27
|
+
getTypeId() {
|
|
29
28
|
return 35
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
/****** Resource record specific setters *******/
|
|
33
|
-
setOrder
|
|
32
|
+
setOrder(val) {
|
|
34
33
|
this.is16bitInt('NAPTR', 'order', val)
|
|
35
34
|
this.set('order', val)
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
setPreference
|
|
37
|
+
setPreference(val) {
|
|
39
38
|
this.is16bitInt('NAPTR', 'preference', val)
|
|
40
39
|
this.set('preference', val)
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
setFlags
|
|
44
|
-
if (![
|
|
45
|
-
throw new Error
|
|
42
|
+
setFlags(val) {
|
|
43
|
+
if (!['', 'S', 'A', 'U', 'P'].includes(val.toUpperCase()))
|
|
44
|
+
throw new Error(`NAPTR flags are invalid, ${this.citeRFC()}`)
|
|
46
45
|
|
|
47
46
|
this.set('flags', val.toUpperCase())
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
setService
|
|
49
|
+
setService(val) {
|
|
51
50
|
this.set('service', val)
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
setRegexp
|
|
53
|
+
setRegexp(val) {
|
|
55
54
|
this.set('regexp', val)
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
setReplacement
|
|
57
|
+
setReplacement(val) {
|
|
59
58
|
this.set('replacement', val)
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
/****** IMPORTERS *******/
|
|
63
|
-
fromTinydns
|
|
62
|
+
fromTinydns(opts) {
|
|
64
63
|
// NAPTR via generic, :fqdn:n:rdata:ttl:timestamp:lo
|
|
65
|
-
const [
|
|
64
|
+
const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
|
|
66
65
|
if (n != 35) throw new Error('NAPTR fromTinydns, invalid n')
|
|
67
66
|
|
|
68
67
|
const binRdata = Buffer.from(TINYDNS.octalToChar(rdata), 'binary')
|
|
69
68
|
|
|
70
69
|
const rec = {
|
|
71
|
-
type
|
|
72
|
-
owner
|
|
73
|
-
ttl
|
|
74
|
-
timestamp
|
|
75
|
-
location
|
|
76
|
-
order
|
|
77
|
-
preference: binRdata.readUInt16BE(2,4),
|
|
70
|
+
type: 'NAPTR',
|
|
71
|
+
owner: this.fullyQualify(fqdn),
|
|
72
|
+
ttl: parseInt(ttl, 10),
|
|
73
|
+
timestamp: ts,
|
|
74
|
+
location: loc !== '' && loc !== '\n' ? loc : '',
|
|
75
|
+
order: binRdata.readUInt16BE(0, 2),
|
|
76
|
+
preference: binRdata.readUInt16BE(2, 4),
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
let idx = 4
|
|
81
|
-
const flagsLength = binRdata.readUInt8(idx)
|
|
82
|
-
|
|
80
|
+
const flagsLength = binRdata.readUInt8(idx)
|
|
81
|
+
idx++
|
|
82
|
+
rec.flags = binRdata.slice(idx, flagsLength).toString()
|
|
83
83
|
idx += flagsLength
|
|
84
84
|
|
|
85
|
-
const serviceLen
|
|
86
|
-
|
|
85
|
+
const serviceLen = binRdata.readUInt8(idx)
|
|
86
|
+
idx++
|
|
87
|
+
rec.service = binRdata.slice(idx, idx + serviceLen).toString()
|
|
87
88
|
idx += serviceLen
|
|
88
89
|
|
|
89
|
-
const regexpLen
|
|
90
|
-
|
|
90
|
+
const regexpLen = binRdata.readUInt8(idx)
|
|
91
|
+
idx++
|
|
92
|
+
rec.regexp = binRdata.slice(idx, idx + regexpLen).toString()
|
|
91
93
|
idx += regexpLen
|
|
92
94
|
|
|
93
|
-
const replaceLen
|
|
94
|
-
|
|
95
|
+
const replaceLen = binRdata.readUInt8(idx)
|
|
96
|
+
idx++
|
|
97
|
+
rec.replacement = binRdata.slice(idx, idx + replaceLen).toString()
|
|
95
98
|
|
|
96
99
|
return new NAPTR(rec)
|
|
97
100
|
}
|
|
98
101
|
|
|
99
|
-
fromBind
|
|
102
|
+
fromBind(opts) {
|
|
100
103
|
const str = opts.bindline
|
|
101
104
|
// test.example.com 3600 IN NAPTR order, preference, "flags", "service", "regexp", replacement
|
|
102
|
-
const [
|
|
103
|
-
const [
|
|
105
|
+
const [owner, ttl, c, type, order, preference] = str.split(/\s+/)
|
|
106
|
+
const [flags, service, regexp] = str.match(/(?:").*?(?:"\s)/g)
|
|
104
107
|
const replacement = str.trim().split(/\s+/).pop()
|
|
105
108
|
|
|
106
109
|
const bits = {
|
|
107
|
-
owner
|
|
108
|
-
ttl
|
|
109
|
-
class
|
|
110
|
-
type
|
|
111
|
-
order
|
|
112
|
-
preference
|
|
113
|
-
flags
|
|
114
|
-
service
|
|
115
|
-
regexp
|
|
110
|
+
owner: owner,
|
|
111
|
+
ttl: parseInt(ttl, 10),
|
|
112
|
+
class: c,
|
|
113
|
+
type: type,
|
|
114
|
+
order: parseInt(order, 10),
|
|
115
|
+
preference: parseInt(preference, 10),
|
|
116
|
+
flags: flags.trim().replace(/^['"]|['"]$/g, ''),
|
|
117
|
+
service: service.trim().replace(/^['"]|['"]$/g, ''),
|
|
118
|
+
regexp: regexp.trim().replace(/^['"]|['"]/g, ''),
|
|
116
119
|
replacement: replacement,
|
|
117
120
|
}
|
|
118
121
|
return new NAPTR(bits)
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
/****** EXPORTERS *******/
|
|
122
|
-
toTinydns
|
|
123
|
-
|
|
125
|
+
toTinydns() {
|
|
124
126
|
let rdata =
|
|
125
127
|
TINYDNS.UInt16toOctal(this.get('order')) +
|
|
126
128
|
TINYDNS.UInt16toOctal(this.get('preference')) +
|
|
127
|
-
|
|
128
129
|
TINYDNS.UInt8toOctal(this.get('flags').length) +
|
|
129
130
|
this.get('flags') +
|
|
130
|
-
|
|
131
131
|
TINYDNS.UInt8toOctal(this.get('service').length) +
|
|
132
132
|
TINYDNS.escapeOctal(rdataRe, this.get('service')) +
|
|
133
|
-
|
|
134
133
|
TINYDNS.UInt8toOctal(this.get('regexp').length) +
|
|
135
134
|
TINYDNS.escapeOctal(rdataRe, this.get('regexp'))
|
|
136
135
|
|
package/rr/ns.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
1
|
import RR from '../rr.js'
|
|
3
2
|
|
|
4
3
|
export default class NS extends RR {
|
|
5
|
-
constructor
|
|
4
|
+
constructor(opts) {
|
|
6
5
|
super(opts)
|
|
7
6
|
if (opts === null) return
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
/****** Resource record specific setters *******/
|
|
11
|
-
setDname
|
|
10
|
+
setDname(val) {
|
|
12
11
|
if (!val) throw new Error(`NS: dname is required, ${this.citeRFC()}`)
|
|
13
12
|
|
|
14
13
|
this.isFullyQualified('NS', 'dname', val)
|
|
@@ -18,57 +17,61 @@ export default class NS extends RR {
|
|
|
18
17
|
this.set('dname', val.toLowerCase())
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
getDescription
|
|
20
|
+
getDescription() {
|
|
22
21
|
return 'Name Server'
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
getRdataFields
|
|
26
|
-
return [
|
|
24
|
+
getRdataFields(arg) {
|
|
25
|
+
return ['dname']
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
getRFCs
|
|
30
|
-
return [
|
|
28
|
+
getRFCs() {
|
|
29
|
+
return [1035]
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
getTypeId
|
|
32
|
+
getTypeId() {
|
|
34
33
|
return 2
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
/****** IMPORTERS *******/
|
|
38
|
-
fromTinydns
|
|
37
|
+
fromTinydns(opts) {
|
|
39
38
|
// &fqdn:ip:x:ttl:timestamp:lo
|
|
40
39
|
// eslint-disable-next-line no-unused-vars
|
|
41
|
-
const [
|
|
40
|
+
const [fqdn, ip, dname, ttl, ts, loc] = opts.tinyline
|
|
41
|
+
.substring(1)
|
|
42
|
+
.split(':')
|
|
42
43
|
|
|
43
44
|
return new NS({
|
|
44
|
-
type
|
|
45
|
-
owner
|
|
46
|
-
dname
|
|
47
|
-
|
|
45
|
+
type: 'NS',
|
|
46
|
+
owner: this.fullyQualify(fqdn),
|
|
47
|
+
dname: this.fullyQualify(
|
|
48
|
+
/\./.test(dname) ? dname : `${dname}.ns.${fqdn}`,
|
|
49
|
+
),
|
|
50
|
+
ttl: parseInt(ttl, 10),
|
|
48
51
|
timestamp: ts,
|
|
49
|
-
location
|
|
52
|
+
location: loc !== '' && loc !== '\n' ? loc : '',
|
|
50
53
|
})
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
fromBind
|
|
56
|
+
fromBind(opts) {
|
|
54
57
|
// test.example.com 3600 IN NS dname
|
|
55
|
-
const [
|
|
58
|
+
const [owner, ttl, c, type, dname] = opts.bindline.split(/\s+/)
|
|
56
59
|
|
|
57
60
|
return new NS({
|
|
58
61
|
owner,
|
|
59
|
-
ttl
|
|
62
|
+
ttl: parseInt(ttl, 10),
|
|
60
63
|
class: c,
|
|
61
|
-
type
|
|
64
|
+
type: type,
|
|
62
65
|
dname: dname,
|
|
63
66
|
})
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
/****** EXPORTERS *******/
|
|
67
|
-
toBind
|
|
70
|
+
toBind(zone_opts) {
|
|
68
71
|
return `${this.getPrefix(zone_opts)}\t${this.getFQDN('dname', zone_opts)}\n`
|
|
69
72
|
}
|
|
70
73
|
|
|
71
|
-
toTinydns
|
|
74
|
+
toTinydns() {
|
|
72
75
|
return `&${this.getTinyFQDN('owner')}::${this.getTinyFQDN('dname')}:${this.getTinydnsPostamble()}\n`
|
|
73
76
|
}
|
|
74
77
|
}
|
package/rr/nsec.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
1
|
import RR from '../rr.js'
|
|
3
2
|
|
|
4
3
|
export default class NSEC extends RR {
|
|
5
|
-
constructor
|
|
4
|
+
constructor(opts) {
|
|
6
5
|
super(opts)
|
|
7
6
|
if (opts === null) return
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
/****** Resource record specific setters *******/
|
|
11
|
-
setNextDomain
|
|
12
|
-
if (!val)
|
|
10
|
+
setNextDomain(val) {
|
|
11
|
+
if (!val)
|
|
12
|
+
throw new Error(`NSEC: 'next domain' is required:, ${this.citeRFC()}`)
|
|
13
13
|
|
|
14
14
|
this.isFullyQualified('NSEC', 'next domain', val)
|
|
15
15
|
this.isValidHostname('NSEC', 'next domain', val)
|
|
@@ -18,44 +18,50 @@ export default class NSEC extends RR {
|
|
|
18
18
|
this.set('next domain', val.toLowerCase())
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
setTypeBitMaps
|
|
22
|
-
if (!val)
|
|
21
|
+
setTypeBitMaps(val) {
|
|
22
|
+
if (!val)
|
|
23
|
+
throw new Error(`NSEC: 'type bit maps' is required, ${this.citeRFC()}`)
|
|
23
24
|
|
|
24
25
|
this.set('type bit maps', val)
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
getDescription
|
|
28
|
+
getDescription() {
|
|
28
29
|
return 'Next Secure'
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
getRdataFields
|
|
32
|
-
return [
|
|
32
|
+
getRdataFields(arg) {
|
|
33
|
+
return ['next domain', 'type bit maps']
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
getRFCs
|
|
36
|
-
return [
|
|
36
|
+
getRFCs() {
|
|
37
|
+
return [4034]
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
getTypeId
|
|
40
|
+
getTypeId() {
|
|
40
41
|
return 47
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
/****** IMPORTERS *******/
|
|
44
45
|
|
|
45
|
-
fromBind
|
|
46
|
+
fromBind(opts) {
|
|
46
47
|
// test.example.com 3600 IN NSEC NextDomain TypeBitMaps
|
|
47
|
-
const [
|
|
48
|
+
const [owner, ttl, c, type, next] = opts.bindline.split(/\s+/)
|
|
48
49
|
return new NSEC({
|
|
49
50
|
owner,
|
|
50
|
-
ttl
|
|
51
|
-
class
|
|
52
|
-
type
|
|
53
|
-
'next domain'
|
|
54
|
-
'type bit maps': opts.bindline
|
|
51
|
+
ttl: parseInt(ttl, 10),
|
|
52
|
+
class: c,
|
|
53
|
+
type: type,
|
|
54
|
+
'next domain': next,
|
|
55
|
+
'type bit maps': opts.bindline
|
|
56
|
+
.split(/\s+/)
|
|
57
|
+
.slice(5)
|
|
58
|
+
.filter(removeParens)
|
|
59
|
+
.join(' ')
|
|
60
|
+
.trim(),
|
|
55
61
|
})
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
/****** EXPORTERS *******/
|
|
59
65
|
}
|
|
60
66
|
|
|
61
|
-
const removeParens = a => ![
|
|
67
|
+
const removeParens = (a) => !['(', ')'].includes(a)
|
package/rr/nsec3.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
|
|
2
1
|
import RR from '../rr.js'
|
|
3
2
|
|
|
4
3
|
import * as TINYDNS from '../lib/tinydns.js'
|
|
5
4
|
|
|
6
5
|
export default class NSEC3 extends RR {
|
|
7
|
-
constructor
|
|
6
|
+
constructor(opts) {
|
|
8
7
|
super(opts)
|
|
9
8
|
if (opts === null) return
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
/****** Resource record specific setters *******/
|
|
13
|
-
setHashAlgorithm
|
|
12
|
+
setHashAlgorithm(val) {
|
|
14
13
|
// Hash Algorithm is a single octet.
|
|
15
14
|
// The Hash Algorithm field is represented as an unsigned decimal integer.
|
|
16
|
-
if (!val)
|
|
15
|
+
if (!val)
|
|
16
|
+
throw new Error(`NSEC3: 'hash algorithm' is required, ${this.citeRFC()}`)
|
|
17
17
|
|
|
18
18
|
this.is8bitInt('NSEC3', 'hash algorithm', val)
|
|
19
19
|
|
|
20
20
|
this.set('hash algorithm', val)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
setFlags
|
|
23
|
+
setFlags(val) {
|
|
24
24
|
// The Flags field is represented as an unsigned decimal integer.
|
|
25
25
|
if (!val) throw new Error(`NSEC3: 'flags' is required, ${this.citeRFC()}`)
|
|
26
26
|
|
|
@@ -29,16 +29,17 @@ export default class NSEC3 extends RR {
|
|
|
29
29
|
this.set('flags', val)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
setIterations
|
|
32
|
+
setIterations(val) {
|
|
33
33
|
// The Iterations field is represented as an unsigned decimal integer. 0-65535
|
|
34
|
-
if (!val)
|
|
34
|
+
if (!val)
|
|
35
|
+
throw new Error(`NSEC3: 'iterations' is required, ${this.citeRFC()}`)
|
|
35
36
|
|
|
36
37
|
this.is16bitInt('NSEC3', 'flags', val)
|
|
37
38
|
|
|
38
39
|
this.set('iterations', val)
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
setSalt
|
|
42
|
+
setSalt(val) {
|
|
42
43
|
// The Salt field is represented as a sequence of case-insensitive
|
|
43
44
|
// hexadecimal digits. Whitespace is not allowed within the
|
|
44
45
|
// sequence. The Salt field is represented as "-" (without the
|
|
@@ -46,95 +47,113 @@ export default class NSEC3 extends RR {
|
|
|
46
47
|
this.set('salt', val)
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
setNextHashedOwnerName
|
|
50
|
+
setNextHashedOwnerName(val) {
|
|
50
51
|
// The Next Hashed Owner Name field is represented as an unpadded
|
|
51
52
|
// sequence of case-insensitive base32 digits, without whitespace
|
|
52
|
-
if (!val)
|
|
53
|
+
if (!val)
|
|
54
|
+
throw new Error(
|
|
55
|
+
`NSEC3: 'next hashed owner name' is required, ${this.citeRFC()}`,
|
|
56
|
+
)
|
|
53
57
|
|
|
54
58
|
this.set('next hashed owner name', val)
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
setTypeBitMaps
|
|
61
|
+
setTypeBitMaps(val) {
|
|
58
62
|
// The Type Bit Maps field is represented as a sequence of RR type mnemonics.
|
|
59
|
-
if (!val)
|
|
63
|
+
if (!val)
|
|
64
|
+
throw new Error(`NSEC3: 'type bit maps' is required, ${this.citeRFC()}`)
|
|
60
65
|
|
|
61
66
|
this.set('type bit maps', val)
|
|
62
67
|
}
|
|
63
68
|
|
|
64
|
-
getDescription
|
|
69
|
+
getDescription() {
|
|
65
70
|
return 'Next Secure'
|
|
66
71
|
}
|
|
67
72
|
|
|
68
|
-
getRdataFields
|
|
69
|
-
return [
|
|
73
|
+
getRdataFields(arg) {
|
|
74
|
+
return [
|
|
75
|
+
'hash algorithm',
|
|
76
|
+
'flags',
|
|
77
|
+
'iterations',
|
|
78
|
+
'salt',
|
|
79
|
+
'next hashed owner name',
|
|
80
|
+
'type bit maps',
|
|
81
|
+
]
|
|
70
82
|
}
|
|
71
83
|
|
|
72
|
-
getRFCs
|
|
73
|
-
return [
|
|
84
|
+
getRFCs() {
|
|
85
|
+
return [5155, 9077]
|
|
74
86
|
}
|
|
75
87
|
|
|
76
|
-
getTypeId
|
|
88
|
+
getTypeId() {
|
|
77
89
|
return 50
|
|
78
90
|
}
|
|
79
91
|
|
|
80
92
|
/****** IMPORTERS *******/
|
|
81
93
|
|
|
82
|
-
fromBind
|
|
94
|
+
fromBind(opts) {
|
|
83
95
|
// test.example.com. 3600 IN NSEC3 1 1 12 aabbccdd (2vptu5timamqttgl4luu9kg21e0aor3s A RRSIG)
|
|
84
|
-
const [
|
|
96
|
+
const [owner, ttl, c, type, ha, flags, iterations, salt] =
|
|
97
|
+
opts.bindline.split(/\s+/)
|
|
85
98
|
const rdata = opts.bindline.split(/\(|\)/)[1]
|
|
86
99
|
|
|
87
100
|
return new NSEC3({
|
|
88
101
|
owner,
|
|
89
|
-
ttl
|
|
90
|
-
class
|
|
91
|
-
type
|
|
92
|
-
'hash algorithm'
|
|
93
|
-
flags
|
|
94
|
-
iterations
|
|
102
|
+
ttl: parseInt(ttl, 10),
|
|
103
|
+
class: c,
|
|
104
|
+
type: type,
|
|
105
|
+
'hash algorithm': parseInt(ha, 10),
|
|
106
|
+
flags: parseInt(flags, 10),
|
|
107
|
+
iterations: parseInt(iterations, 10),
|
|
95
108
|
salt,
|
|
96
109
|
'next hashed owner name': rdata.split(/\s+/)[0],
|
|
97
|
-
'type bit maps'
|
|
110
|
+
'type bit maps': rdata.split(/\s+/).slice(1).join('\t'),
|
|
98
111
|
})
|
|
99
112
|
}
|
|
100
113
|
|
|
101
|
-
fromTinydns
|
|
102
|
-
const [
|
|
114
|
+
fromTinydns(opts) {
|
|
115
|
+
const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
|
|
103
116
|
if (n != 50) throw new Error('NSEC3 fromTinydns, invalid n')
|
|
104
117
|
|
|
105
118
|
const bytes = Buffer.from(TINYDNS.octalToChar(rdata), 'binary')
|
|
106
119
|
|
|
107
120
|
return new NSEC3({
|
|
108
|
-
owner
|
|
109
|
-
ttl
|
|
110
|
-
type
|
|
121
|
+
owner: this.fullyQualify(fqdn),
|
|
122
|
+
ttl: parseInt(ttl, 10),
|
|
123
|
+
type: 'NSEC3',
|
|
111
124
|
'hash algorithm': bytes.readUInt8(0),
|
|
112
|
-
flags
|
|
113
|
-
iterations
|
|
125
|
+
flags: bytes.readUInt8(1),
|
|
126
|
+
iterations: bytes.readUInt16BE(2),
|
|
114
127
|
// salt : ,
|
|
115
128
|
// 'next hashed owner name': ,
|
|
116
129
|
// 'type bit maps' : ,
|
|
117
|
-
timestamp
|
|
118
|
-
location
|
|
130
|
+
timestamp: ts,
|
|
131
|
+
location: loc !== '' && loc !== '\n' ? loc : '',
|
|
119
132
|
})
|
|
120
133
|
}
|
|
121
134
|
|
|
122
135
|
/****** EXPORTERS *******/
|
|
123
136
|
|
|
124
|
-
toBind
|
|
125
|
-
return `${this.getFQDN('owner', zone_opts)}\t${this.get('ttl')}\t${this.get('class')}\tNSEC3${this.getRdataFields()
|
|
137
|
+
toBind(zone_opts) {
|
|
138
|
+
return `${this.getFQDN('owner', zone_opts)}\t${this.get('ttl')}\t${this.get('class')}\tNSEC3${this.getRdataFields()
|
|
139
|
+
.slice(0, 4)
|
|
140
|
+
.map((f) => '\t' + this.get(f))
|
|
141
|
+
.join('')}\t(${this.getRdataFields()
|
|
142
|
+
.slice(4)
|
|
143
|
+
.map((f) => this.get(f))
|
|
144
|
+
.join('\t')})\n`
|
|
126
145
|
}
|
|
127
146
|
|
|
128
|
-
toTinydns
|
|
147
|
+
toTinydns() {
|
|
129
148
|
const dataRe = new RegExp(/[\r\n\t:\\/]/, 'g')
|
|
130
149
|
|
|
131
150
|
return this.getTinydnsGeneric(
|
|
132
151
|
TINYDNS.UInt8toOctal(this.get('hash algorithm')) +
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
152
|
+
TINYDNS.UInt8toOctal(this.get('flags')) +
|
|
153
|
+
TINYDNS.UInt16toOctal(this.get('iterations')) +
|
|
154
|
+
TINYDNS.escapeOctal(dataRe, this.get('salt')) +
|
|
155
|
+
TINYDNS.escapeOctal(dataRe, this.get('next hashed owner name')) +
|
|
156
|
+
TINYDNS.escapeOctal(dataRe, this.get('type bit maps')),
|
|
138
157
|
)
|
|
139
158
|
}
|
|
140
159
|
}
|