@nictool/dns-resource-record 1.1.7 → 1.2.1
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/CHANGELOG.md +26 -43
- package/README.md +48 -48
- package/index.js +83 -29
- package/lib/tinydns.js +68 -61
- package/package.json +1 -2
- package/rr/a.js +32 -23
- package/rr/aaaa.js +49 -35
- package/rr/caa.js +56 -44
- package/rr/cert.js +21 -19
- package/rr/cname.js +22 -23
- package/rr/dname.js +23 -23
- package/rr/dnskey.js +45 -43
- package/rr/ds.js +40 -40
- package/rr/hinfo.js +29 -28
- package/rr/https.js +62 -0
- package/rr/ipseckey.js +69 -50
- package/rr/key.js +23 -23
- package/rr/loc.js +71 -58
- package/rr/mx.js +41 -27
- package/rr/naptr.js +52 -53
- package/rr/ns.js +26 -23
- package/rr/nsec.js +24 -20
- package/rr/nsec3.js +59 -46
- package/rr/nsec3param.js +24 -26
- package/rr/nxt.js +65 -0
- package/rr/openpgpkey.js +18 -15
- package/rr/ptr.js +20 -21
- package/rr/rrsig.js +28 -23
- package/rr/sig.js +25 -20
- package/rr/smimea.js +36 -31
- package/rr/soa.js +56 -42
- package/rr/spf.js +21 -18
- package/rr/srv.js +45 -45
- package/rr/sshfp.js +30 -31
- package/rr/svcb.js +64 -0
- package/rr/tlsa.js +50 -45
- package/rr/tsig.js +56 -0
- package/rr/txt.js +42 -35
- package/rr/uri.js +33 -33
- package/rr/wks.js +45 -0
- package/rr.js +133 -87
- 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/nsec.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
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) this.throwHelp(`NSEC: 'next domain' is required:`)
|
|
13
12
|
|
|
14
13
|
this.isFullyQualified('NSEC', 'next domain', val)
|
|
15
14
|
this.isValidHostname('NSEC', 'next domain', val)
|
|
@@ -18,44 +17,49 @@ export default class NSEC extends RR {
|
|
|
18
17
|
this.set('next domain', val.toLowerCase())
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
setTypeBitMaps
|
|
22
|
-
if (!val)
|
|
20
|
+
setTypeBitMaps(val) {
|
|
21
|
+
if (!val) this.throwHelp(`NSEC: 'type bit maps' is required`)
|
|
23
22
|
|
|
24
23
|
this.set('type bit maps', val)
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
getDescription
|
|
26
|
+
getDescription() {
|
|
28
27
|
return 'Next Secure'
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
getRdataFields
|
|
32
|
-
return [
|
|
30
|
+
getRdataFields(arg) {
|
|
31
|
+
return ['next domain', 'type bit maps']
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
getRFCs
|
|
36
|
-
return [
|
|
34
|
+
getRFCs() {
|
|
35
|
+
return [4034]
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
getTypeId
|
|
38
|
+
getTypeId() {
|
|
40
39
|
return 47
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
/****** IMPORTERS *******/
|
|
44
43
|
|
|
45
|
-
fromBind
|
|
44
|
+
fromBind(opts) {
|
|
46
45
|
// test.example.com 3600 IN NSEC NextDomain TypeBitMaps
|
|
47
|
-
const [
|
|
46
|
+
const [owner, ttl, c, type, next] = opts.bindline.split(/\s+/)
|
|
48
47
|
return new NSEC({
|
|
49
48
|
owner,
|
|
50
|
-
ttl
|
|
51
|
-
class
|
|
52
|
-
type
|
|
53
|
-
'next domain'
|
|
54
|
-
'type bit maps': opts.bindline
|
|
49
|
+
ttl: parseInt(ttl, 10),
|
|
50
|
+
class: c,
|
|
51
|
+
type: type,
|
|
52
|
+
'next domain': next,
|
|
53
|
+
'type bit maps': opts.bindline
|
|
54
|
+
.split(/\s+/)
|
|
55
|
+
.slice(5)
|
|
56
|
+
.filter(removeParens)
|
|
57
|
+
.join(' ')
|
|
58
|
+
.trim(),
|
|
55
59
|
})
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
/****** EXPORTERS *******/
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
const removeParens = a => ![
|
|
65
|
+
const removeParens = (a) => !['(', ')'].includes(a)
|
package/rr/nsec3.js
CHANGED
|
@@ -1,44 +1,43 @@
|
|
|
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) this.throwHelp(`NSEC3: 'hash algorithm' is required`)
|
|
17
16
|
|
|
18
17
|
this.is8bitInt('NSEC3', 'hash algorithm', val)
|
|
19
18
|
|
|
20
19
|
this.set('hash algorithm', val)
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
setFlags
|
|
22
|
+
setFlags(val) {
|
|
24
23
|
// The Flags field is represented as an unsigned decimal integer.
|
|
25
|
-
if (!val)
|
|
24
|
+
if (!val) this.throwHelp(`NSEC3: 'flags' is required`)
|
|
26
25
|
|
|
27
26
|
this.is8bitInt('NSEC3', 'flags', val)
|
|
28
27
|
|
|
29
28
|
this.set('flags', val)
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
setIterations
|
|
31
|
+
setIterations(val) {
|
|
33
32
|
// The Iterations field is represented as an unsigned decimal integer. 0-65535
|
|
34
|
-
if (!val)
|
|
33
|
+
if (!val) this.throwHelp(`NSEC3: 'iterations' is required`)
|
|
35
34
|
|
|
36
35
|
this.is16bitInt('NSEC3', 'flags', val)
|
|
37
36
|
|
|
38
37
|
this.set('iterations', val)
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
setSalt
|
|
40
|
+
setSalt(val) {
|
|
42
41
|
// The Salt field is represented as a sequence of case-insensitive
|
|
43
42
|
// hexadecimal digits. Whitespace is not allowed within the
|
|
44
43
|
// sequence. The Salt field is represented as "-" (without the
|
|
@@ -46,95 +45,109 @@ export default class NSEC3 extends RR {
|
|
|
46
45
|
this.set('salt', val)
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
setNextHashedOwnerName
|
|
48
|
+
setNextHashedOwnerName(val) {
|
|
50
49
|
// The Next Hashed Owner Name field is represented as an unpadded
|
|
51
50
|
// sequence of case-insensitive base32 digits, without whitespace
|
|
52
|
-
if (!val)
|
|
51
|
+
if (!val) this.throwHelp(`NSEC3: 'next hashed owner name' is required`)
|
|
53
52
|
|
|
54
53
|
this.set('next hashed owner name', val)
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
setTypeBitMaps
|
|
56
|
+
setTypeBitMaps(val) {
|
|
58
57
|
// The Type Bit Maps field is represented as a sequence of RR type mnemonics.
|
|
59
|
-
if (!val)
|
|
58
|
+
if (!val) this.throwHelp(`NSEC3: 'type bit maps' is required`)
|
|
60
59
|
|
|
61
60
|
this.set('type bit maps', val)
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
getDescription
|
|
63
|
+
getDescription() {
|
|
65
64
|
return 'Next Secure'
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
getRdataFields
|
|
69
|
-
return [
|
|
67
|
+
getRdataFields(arg) {
|
|
68
|
+
return [
|
|
69
|
+
'hash algorithm',
|
|
70
|
+
'flags',
|
|
71
|
+
'iterations',
|
|
72
|
+
'salt',
|
|
73
|
+
'next hashed owner name',
|
|
74
|
+
'type bit maps',
|
|
75
|
+
]
|
|
70
76
|
}
|
|
71
77
|
|
|
72
|
-
getRFCs
|
|
73
|
-
return [
|
|
78
|
+
getRFCs() {
|
|
79
|
+
return [5155, 9077]
|
|
74
80
|
}
|
|
75
81
|
|
|
76
|
-
getTypeId
|
|
82
|
+
getTypeId() {
|
|
77
83
|
return 50
|
|
78
84
|
}
|
|
79
85
|
|
|
80
86
|
/****** IMPORTERS *******/
|
|
81
87
|
|
|
82
|
-
fromBind
|
|
88
|
+
fromBind(opts) {
|
|
83
89
|
// test.example.com. 3600 IN NSEC3 1 1 12 aabbccdd (2vptu5timamqttgl4luu9kg21e0aor3s A RRSIG)
|
|
84
|
-
const [
|
|
90
|
+
const [owner, ttl, c, type, ha, flags, iterations, salt] =
|
|
91
|
+
opts.bindline.split(/\s+/)
|
|
85
92
|
const rdata = opts.bindline.split(/\(|\)/)[1]
|
|
86
93
|
|
|
87
94
|
return new NSEC3({
|
|
88
95
|
owner,
|
|
89
|
-
ttl
|
|
90
|
-
class
|
|
91
|
-
type
|
|
92
|
-
'hash algorithm'
|
|
93
|
-
flags
|
|
94
|
-
iterations
|
|
96
|
+
ttl: parseInt(ttl, 10),
|
|
97
|
+
class: c,
|
|
98
|
+
type: type,
|
|
99
|
+
'hash algorithm': parseInt(ha, 10),
|
|
100
|
+
flags: parseInt(flags, 10),
|
|
101
|
+
iterations: parseInt(iterations, 10),
|
|
95
102
|
salt,
|
|
96
103
|
'next hashed owner name': rdata.split(/\s+/)[0],
|
|
97
|
-
'type bit maps'
|
|
104
|
+
'type bit maps': rdata.split(/\s+/).slice(1).join('\t'),
|
|
98
105
|
})
|
|
99
106
|
}
|
|
100
107
|
|
|
101
|
-
fromTinydns
|
|
102
|
-
const [
|
|
103
|
-
if (n != 50)
|
|
108
|
+
fromTinydns(opts) {
|
|
109
|
+
const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
|
|
110
|
+
if (n != 50) this.throwHelp('NSEC3 fromTinydns, invalid n')
|
|
104
111
|
|
|
105
112
|
const bytes = Buffer.from(TINYDNS.octalToChar(rdata), 'binary')
|
|
106
113
|
|
|
107
114
|
return new NSEC3({
|
|
108
|
-
owner
|
|
109
|
-
ttl
|
|
110
|
-
type
|
|
115
|
+
owner: this.fullyQualify(fqdn),
|
|
116
|
+
ttl: parseInt(ttl, 10),
|
|
117
|
+
type: 'NSEC3',
|
|
111
118
|
'hash algorithm': bytes.readUInt8(0),
|
|
112
|
-
flags
|
|
113
|
-
iterations
|
|
119
|
+
flags: bytes.readUInt8(1),
|
|
120
|
+
iterations: bytes.readUInt16BE(2),
|
|
114
121
|
// salt : ,
|
|
115
122
|
// 'next hashed owner name': ,
|
|
116
123
|
// 'type bit maps' : ,
|
|
117
|
-
timestamp
|
|
118
|
-
location
|
|
124
|
+
timestamp: ts,
|
|
125
|
+
location: loc !== '' && loc !== '\n' ? loc : '',
|
|
119
126
|
})
|
|
120
127
|
}
|
|
121
128
|
|
|
122
129
|
/****** EXPORTERS *******/
|
|
123
130
|
|
|
124
|
-
toBind
|
|
125
|
-
return `${this.getFQDN('owner', zone_opts)}\t${this.get('ttl')}\t${this.get('class')}\tNSEC3${this.getRdataFields()
|
|
131
|
+
toBind(zone_opts) {
|
|
132
|
+
return `${this.getFQDN('owner', zone_opts)}\t${this.get('ttl')}\t${this.get('class')}\tNSEC3${this.getRdataFields()
|
|
133
|
+
.slice(0, 4)
|
|
134
|
+
.map((f) => '\t' + this.get(f))
|
|
135
|
+
.join('')}\t(${this.getRdataFields()
|
|
136
|
+
.slice(4)
|
|
137
|
+
.map((f) => this.get(f))
|
|
138
|
+
.join('\t')})\n`
|
|
126
139
|
}
|
|
127
140
|
|
|
128
|
-
toTinydns
|
|
141
|
+
toTinydns() {
|
|
129
142
|
const dataRe = new RegExp(/[\r\n\t:\\/]/, 'g')
|
|
130
143
|
|
|
131
144
|
return this.getTinydnsGeneric(
|
|
132
145
|
TINYDNS.UInt8toOctal(this.get('hash algorithm')) +
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
146
|
+
TINYDNS.UInt8toOctal(this.get('flags')) +
|
|
147
|
+
TINYDNS.UInt16toOctal(this.get('iterations')) +
|
|
148
|
+
TINYDNS.escapeOctal(dataRe, this.get('salt')) +
|
|
149
|
+
TINYDNS.escapeOctal(dataRe, this.get('next hashed owner name')) +
|
|
150
|
+
TINYDNS.escapeOctal(dataRe, this.get('type bit maps')),
|
|
138
151
|
)
|
|
139
152
|
}
|
|
140
153
|
}
|
package/rr/nsec3param.js
CHANGED
|
@@ -1,42 +1,41 @@
|
|
|
1
|
-
|
|
2
1
|
import RR from '../rr.js'
|
|
3
2
|
|
|
4
3
|
export default class NSEC3PARAM 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
|
-
|
|
10
|
+
setHashAlgorithm(val) {
|
|
12
11
|
// Hash Algorithm is a single octet.
|
|
13
12
|
// The Hash Algorithm field is represented as an unsigned decimal integer.
|
|
14
|
-
if (!val)
|
|
13
|
+
if (!val) this.throwHelp(`NSEC3PARAM: 'hash algorithm' is required`)
|
|
15
14
|
|
|
16
15
|
this.is8bitInt('NSEC3PARAM', 'hash algorithm', val)
|
|
17
16
|
|
|
18
17
|
this.set('hash algorithm', val)
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
setFlags
|
|
20
|
+
setFlags(val) {
|
|
22
21
|
// The Flags field is represented as an unsigned decimal integer.
|
|
23
|
-
if (!val)
|
|
22
|
+
if (!val) this.throwHelp(`NSEC3PARAM: 'flags' is required`)
|
|
24
23
|
|
|
25
24
|
this.is8bitInt('NSEC3PARAM', 'flags', val)
|
|
26
25
|
|
|
27
26
|
this.set('flags', val)
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
setIterations
|
|
29
|
+
setIterations(val) {
|
|
31
30
|
// The Iterations field is represented as an unsigned decimal integer. 0-65535
|
|
32
|
-
if (!val)
|
|
31
|
+
if (!val) this.throwHelp(`NSEC3PARAM: 'iterations' is required`)
|
|
33
32
|
|
|
34
33
|
this.is16bitInt('NSEC3PARAM', 'iterations', val)
|
|
35
34
|
|
|
36
35
|
this.set('iterations', val)
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
setSalt
|
|
38
|
+
setSalt(val) {
|
|
40
39
|
// The Salt field is represented as a sequence of case-insensitive
|
|
41
40
|
// hexadecimal digits. Whitespace is not allowed within the
|
|
42
41
|
// sequence. The Salt field is represented as "-" (without the
|
|
@@ -44,41 +43,40 @@ export default class NSEC3PARAM extends RR {
|
|
|
44
43
|
this.set('salt', val)
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
getDescription
|
|
46
|
+
getDescription() {
|
|
48
47
|
return 'Next Secure Parameters'
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
getRdataFields
|
|
52
|
-
return [
|
|
50
|
+
getRdataFields(arg) {
|
|
51
|
+
return ['hash algorithm', 'flags', 'iterations', 'salt']
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
getRFCs
|
|
56
|
-
return [
|
|
54
|
+
getRFCs() {
|
|
55
|
+
return [5155]
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
getTypeId
|
|
58
|
+
getTypeId() {
|
|
60
59
|
return 51
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
/****** IMPORTERS *******/
|
|
64
63
|
|
|
65
|
-
fromBind
|
|
64
|
+
fromBind(str) {
|
|
66
65
|
// test.example.com 3600 IN NSEC3PARAM
|
|
67
|
-
const [
|
|
66
|
+
const [owner, ttl, c, type] = str.split(/\s+/)
|
|
68
67
|
return new NSEC3PARAM({
|
|
69
68
|
owner,
|
|
70
|
-
ttl
|
|
71
|
-
class
|
|
72
|
-
type
|
|
73
|
-
'hash algorithm'
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
ttl: parseInt(ttl, 10),
|
|
70
|
+
class: c,
|
|
71
|
+
type: type,
|
|
72
|
+
'hash algorithm': '',
|
|
73
|
+
flags: '',
|
|
74
|
+
iterations: '',
|
|
75
|
+
salt: '',
|
|
77
76
|
'next hashed owner name': '',
|
|
78
|
-
'type bit maps'
|
|
77
|
+
'type bit maps': '',
|
|
79
78
|
})
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
/****** EXPORTERS *******/
|
|
83
|
-
|
|
84
82
|
}
|
package/rr/nxt.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import RR from '../rr.js'
|
|
2
|
+
|
|
3
|
+
export default class NXT extends RR {
|
|
4
|
+
constructor(opts) {
|
|
5
|
+
super(opts)
|
|
6
|
+
if (opts === null) return
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/****** Resource record specific setters *******/
|
|
10
|
+
setNextDomain(val) {
|
|
11
|
+
if (!val) this.throwHelp(`NXT: 'next domain' is required`)
|
|
12
|
+
|
|
13
|
+
this.isFullyQualified('NXT', 'next domain', val)
|
|
14
|
+
this.isValidHostname('NXT', 'next domain', val)
|
|
15
|
+
|
|
16
|
+
// RFC 4034: letters in the DNS names are lower cased
|
|
17
|
+
this.set('next domain', val.toLowerCase())
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
setTypeBitMap(val) {
|
|
21
|
+
if (!val) this.throwHelp(`NXT: 'type bit map' is required`)
|
|
22
|
+
|
|
23
|
+
this.set('type bit map', val)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getDescription() {
|
|
27
|
+
return 'Next Secure'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getRdataFields(arg) {
|
|
31
|
+
return ['next domain', 'type bit map']
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getRFCs() {
|
|
35
|
+
return [2065]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getTypeId() {
|
|
39
|
+
return 30
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/****** IMPORTERS *******/
|
|
43
|
+
|
|
44
|
+
fromBind(opts) {
|
|
45
|
+
// test.example.com 3600 IN NXT NextDomain TypeBitMap
|
|
46
|
+
const [owner, ttl, c, type, next] = opts.bindline.split(/\s+/)
|
|
47
|
+
return new NXT({
|
|
48
|
+
owner,
|
|
49
|
+
ttl: parseInt(ttl, 10),
|
|
50
|
+
class: c,
|
|
51
|
+
type: type,
|
|
52
|
+
'next domain': next,
|
|
53
|
+
'type bit map': opts.bindline
|
|
54
|
+
.split(/\s+/)
|
|
55
|
+
.slice(5)
|
|
56
|
+
.filter(removeParens)
|
|
57
|
+
.join(' ')
|
|
58
|
+
.trim(),
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/****** EXPORTERS *******/
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const removeParens = (a) => !['(', ')'].includes(a)
|
package/rr/openpgpkey.js
CHANGED
|
@@ -1,42 +1,45 @@
|
|
|
1
|
-
|
|
2
1
|
import RR from '../rr.js'
|
|
3
2
|
|
|
4
3
|
export default class OPENPGPKEY extends RR {
|
|
5
|
-
constructor
|
|
4
|
+
constructor(opts) {
|
|
6
5
|
super(opts)
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
/****** Resource record specific setters *******/
|
|
10
|
-
setPublicKey
|
|
9
|
+
setPublicKey(val) {
|
|
11
10
|
this.set('public key', val)
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
getDescription
|
|
13
|
+
getDescription() {
|
|
15
14
|
return 'OpenPGP Public Key'
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
getRdataFields
|
|
19
|
-
return [
|
|
17
|
+
getRdataFields() {
|
|
18
|
+
return ['public key']
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
getRFCs
|
|
23
|
-
return [
|
|
21
|
+
getRFCs() {
|
|
22
|
+
return [4880, 7929]
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
getTypeId
|
|
25
|
+
getTypeId() {
|
|
27
26
|
return 61
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
/****** IMPORTERS *******/
|
|
31
|
-
fromBind
|
|
30
|
+
fromBind(obj) {
|
|
32
31
|
// test.example.com 3600 IN OPENPGPKEY <base64 public key>
|
|
33
|
-
|
|
32
|
+
// eslint-disable-next-line no-unused-vars
|
|
33
|
+
const [ignore, owner, ttl, c, type, publickey] = obj.bindline.match(
|
|
34
|
+
/^([\S]+)\s+(\d+)\s+(\w+)\s+(\w+)\s+([\W\w]*)$/,
|
|
35
|
+
)
|
|
36
|
+
|
|
34
37
|
return new OPENPGPKEY({
|
|
35
38
|
owner,
|
|
36
|
-
ttl
|
|
37
|
-
class
|
|
38
|
-
type
|
|
39
|
-
'
|
|
39
|
+
ttl: parseInt(ttl, 10),
|
|
40
|
+
class: c,
|
|
41
|
+
type: type,
|
|
42
|
+
'public key': publickey.trim(),
|
|
40
43
|
})
|
|
41
44
|
}
|
|
42
45
|
|
package/rr/ptr.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
1
|
import RR from '../rr.js'
|
|
3
2
|
|
|
4
3
|
export default class PTR extends RR {
|
|
5
|
-
constructor
|
|
4
|
+
constructor(opts) {
|
|
6
5
|
super(opts)
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
/****** Resource record specific setters *******/
|
|
10
|
-
setDname
|
|
9
|
+
setDname(val) {
|
|
11
10
|
this.isFullyQualified('PTR', 'dname', val)
|
|
12
11
|
this.isValidHostname('PTR', 'dname', val)
|
|
13
12
|
|
|
@@ -15,51 +14,51 @@ export default class PTR extends RR {
|
|
|
15
14
|
this.set('dname', val.toLowerCase())
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
getDescription
|
|
17
|
+
getDescription() {
|
|
19
18
|
return 'Pointer'
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
getRdataFields
|
|
23
|
-
return [
|
|
21
|
+
getRdataFields(arg) {
|
|
22
|
+
return ['dname']
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
getRFCs
|
|
27
|
-
return [
|
|
25
|
+
getRFCs() {
|
|
26
|
+
return [1035]
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
getTypeId
|
|
29
|
+
getTypeId() {
|
|
31
30
|
return 12
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
/****** IMPORTERS *******/
|
|
35
|
-
fromTinydns
|
|
34
|
+
fromTinydns(opts) {
|
|
36
35
|
// ^fqdn:p:ttl:timestamp:lo
|
|
37
|
-
const [
|
|
36
|
+
const [fqdn, p, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
|
|
38
37
|
|
|
39
38
|
return new PTR({
|
|
40
|
-
owner
|
|
41
|
-
ttl
|
|
42
|
-
type
|
|
43
|
-
dname
|
|
39
|
+
owner: this.fullyQualify(fqdn),
|
|
40
|
+
ttl: parseInt(ttl, 10),
|
|
41
|
+
type: 'PTR',
|
|
42
|
+
dname: this.fullyQualify(p),
|
|
44
43
|
timestamp: ts,
|
|
45
|
-
location
|
|
44
|
+
location: loc !== '' && loc !== '\n' ? loc : '',
|
|
46
45
|
})
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
fromBind
|
|
48
|
+
fromBind(opts) {
|
|
50
49
|
// test.example.com 3600 IN PTR dname
|
|
51
|
-
const [
|
|
50
|
+
const [owner, ttl, c, type, dname] = opts.bindline.split(/\s+/)
|
|
52
51
|
return new PTR({
|
|
53
52
|
owner,
|
|
54
|
-
ttl
|
|
53
|
+
ttl: parseInt(ttl, 10),
|
|
55
54
|
class: c,
|
|
56
|
-
type
|
|
55
|
+
type: type,
|
|
57
56
|
dname: dname,
|
|
58
57
|
})
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
/****** EXPORTERS *******/
|
|
62
|
-
toTinydns
|
|
61
|
+
toTinydns() {
|
|
63
62
|
return `^${this.getTinyFQDN('owner')}:${this.getTinyFQDN('dname')}:${this.getTinydnsPostamble()}\n`
|
|
64
63
|
}
|
|
65
64
|
}
|