@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/srv.js
CHANGED
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
import net from 'net'
|
|
1
|
+
import net from 'node:net'
|
|
3
2
|
|
|
4
3
|
import RR from '../rr.js'
|
|
5
4
|
import * as TINYDNS from '../lib/tinydns.js'
|
|
6
5
|
|
|
7
6
|
export default class SRV extends RR {
|
|
8
|
-
constructor
|
|
7
|
+
constructor(opts) {
|
|
9
8
|
super(opts)
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
/****** Resource record specific setters *******/
|
|
13
|
-
setPriority
|
|
12
|
+
setPriority(val) {
|
|
14
13
|
this.is16bitInt('SRV', 'priority', val)
|
|
15
14
|
|
|
16
15
|
this.set('priority', val)
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
setPort
|
|
18
|
+
setPort(val) {
|
|
20
19
|
this.is16bitInt('SRV', 'port', val)
|
|
21
20
|
|
|
22
21
|
this.set('port', val)
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
setWeight
|
|
24
|
+
setWeight(val) {
|
|
26
25
|
this.is16bitInt('SRV', 'weight', val)
|
|
27
26
|
|
|
28
27
|
this.set('weight', val)
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
setTarget
|
|
32
|
-
if (!val)
|
|
30
|
+
setTarget(val) {
|
|
31
|
+
if (!val) this.throwHelp(`SRV: target is required`)
|
|
33
32
|
|
|
34
33
|
if (net.isIPv4(val) || net.isIPv6(val))
|
|
35
|
-
|
|
34
|
+
this.throwHelp(`SRV: target must be a FQDN`)
|
|
36
35
|
|
|
37
36
|
this.isFullyQualified('SRV', 'target', val)
|
|
38
37
|
this.isValidHostname('SRV', 'target', val)
|
|
@@ -41,77 +40,78 @@ export default class SRV extends RR {
|
|
|
41
40
|
this.set('target', val.toLowerCase())
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
getDescription
|
|
43
|
+
getDescription() {
|
|
45
44
|
return 'Service'
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
getRdataFields
|
|
49
|
-
return [
|
|
47
|
+
getRdataFields(arg) {
|
|
48
|
+
return ['priority', 'weight', 'port', 'target']
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
getRFCs
|
|
53
|
-
return [
|
|
51
|
+
getRFCs() {
|
|
52
|
+
return [2782]
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
getTypeId
|
|
55
|
+
getTypeId() {
|
|
57
56
|
return 33
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
/****** IMPORTERS *******/
|
|
61
|
-
fromTinydns
|
|
60
|
+
fromTinydns(opts) {
|
|
62
61
|
const str = opts.tinyline
|
|
63
62
|
let fqdn, addr, port, pri, weight, ttl, ts, loc, n, rdata
|
|
64
63
|
|
|
65
64
|
if (str[0] === 'S') {
|
|
66
65
|
// patched tinydns with S records
|
|
67
|
-
[
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
;[fqdn, addr, port, pri, weight, ttl, ts, loc] = str
|
|
67
|
+
.substring(1)
|
|
68
|
+
.split(':')
|
|
69
|
+
} else {
|
|
70
70
|
// tinydns generic record format
|
|
71
|
-
[
|
|
72
|
-
if (n != 33)
|
|
71
|
+
;[fqdn, n, rdata, ttl, ts, loc] = str.substring(1).split(':')
|
|
72
|
+
if (n != 33) this.throwHelp('SRV fromTinydns: invalid n')
|
|
73
73
|
|
|
74
|
-
pri
|
|
74
|
+
pri = TINYDNS.octalToUInt16(rdata.substring(0, 8))
|
|
75
75
|
weight = TINYDNS.octalToUInt16(rdata.substring(8, 16))
|
|
76
|
-
port
|
|
77
|
-
addr
|
|
76
|
+
port = TINYDNS.octalToUInt16(rdata.substring(16, 24))
|
|
77
|
+
addr = TINYDNS.unpackDomainName(rdata.substring(24))[0]
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
return new SRV({
|
|
81
|
-
owner
|
|
82
|
-
ttl
|
|
83
|
-
type
|
|
84
|
-
priority
|
|
85
|
-
weight
|
|
86
|
-
port
|
|
87
|
-
target
|
|
81
|
+
owner: this.fullyQualify(fqdn),
|
|
82
|
+
ttl: parseInt(ttl, 10),
|
|
83
|
+
type: 'SRV',
|
|
84
|
+
priority: parseInt(pri, 10),
|
|
85
|
+
weight: parseInt(weight, 10),
|
|
86
|
+
port: parseInt(port, 10),
|
|
87
|
+
target: this.fullyQualify(addr),
|
|
88
88
|
timestamp: ts,
|
|
89
|
-
location
|
|
89
|
+
location: loc !== '' && loc !== '\n' ? loc : '',
|
|
90
90
|
})
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
fromBind
|
|
93
|
+
fromBind(opts) {
|
|
94
94
|
// test.example.com 3600 IN SRV Priority Weight Port Target
|
|
95
|
-
const [
|
|
95
|
+
const [owner, ttl, c, type, pri, weight, port, target] =
|
|
96
|
+
opts.bindline.split(/\s+/)
|
|
96
97
|
return new SRV({
|
|
97
|
-
owner
|
|
98
|
-
ttl
|
|
99
|
-
class
|
|
100
|
-
type
|
|
101
|
-
priority: parseInt(pri,
|
|
102
|
-
weight
|
|
103
|
-
port
|
|
104
|
-
target
|
|
98
|
+
owner: owner,
|
|
99
|
+
ttl: parseInt(ttl, 10),
|
|
100
|
+
class: c,
|
|
101
|
+
type: type,
|
|
102
|
+
priority: parseInt(pri, 10),
|
|
103
|
+
weight: parseInt(weight, 10),
|
|
104
|
+
port: parseInt(port, 10),
|
|
105
|
+
target: target,
|
|
105
106
|
})
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
/****** EXPORTERS *******/
|
|
109
110
|
|
|
110
|
-
toTinydns
|
|
111
|
-
|
|
111
|
+
toTinydns() {
|
|
112
112
|
let rdata = ''
|
|
113
113
|
|
|
114
|
-
for (const e of [
|
|
114
|
+
for (const e of ['priority', 'weight', 'port']) {
|
|
115
115
|
rdata += TINYDNS.UInt16toOctal(this.get(e))
|
|
116
116
|
}
|
|
117
117
|
|
package/rr/sshfp.js
CHANGED
|
@@ -1,86 +1,85 @@
|
|
|
1
|
-
|
|
2
1
|
import RR from '../rr.js'
|
|
3
2
|
import * as TINYDNS from '../lib/tinydns.js'
|
|
4
3
|
|
|
5
4
|
export default class SSHFP extends RR {
|
|
6
|
-
constructor
|
|
5
|
+
constructor(opts) {
|
|
7
6
|
super(opts)
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
/****** Resource record specific setters *******/
|
|
11
|
-
setAlgorithm
|
|
10
|
+
setAlgorithm(val) {
|
|
12
11
|
// 0: reserved 1: RSA 2: DSA 3: ECDSA 4: Ed25519 6: Ed448
|
|
13
12
|
this.is8bitInt('SSHFP', 'algorithm', val)
|
|
14
13
|
|
|
15
14
|
this.set('algorithm', val)
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
setFptype
|
|
17
|
+
setFptype(val) {
|
|
19
18
|
// 0: reserved, 1: SHA-1, 2: SHA-256
|
|
20
19
|
this.is8bitInt('SSHFP', 'type', val)
|
|
21
20
|
|
|
22
21
|
this.set('fptype', val)
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
setFingerprint
|
|
24
|
+
setFingerprint(val) {
|
|
26
25
|
this.set('fingerprint', val)
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
getDescription
|
|
28
|
+
getDescription() {
|
|
30
29
|
return 'Secure Shell Key Fingerprints'
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
getRdataFields
|
|
34
|
-
return [
|
|
32
|
+
getRdataFields() {
|
|
33
|
+
return ['algorithm', 'fptype', 'fingerprint']
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
getRFCs
|
|
38
|
-
return [
|
|
36
|
+
getRFCs() {
|
|
37
|
+
return [4255, 7479, 8709]
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
getTypeId
|
|
40
|
+
getTypeId() {
|
|
42
41
|
return 44
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
/****** IMPORTERS *******/
|
|
46
|
-
fromTinydns
|
|
45
|
+
fromTinydns(opts) {
|
|
47
46
|
// SSHFP via generic, :fqdn:n:rdata:ttl:timestamp:lo
|
|
48
|
-
const [
|
|
49
|
-
if (n != 44)
|
|
47
|
+
const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
|
|
48
|
+
if (n != 44) this.throwHelp('SSHFP fromTinydns, invalid n')
|
|
50
49
|
|
|
51
50
|
return new SSHFP({
|
|
52
|
-
owner
|
|
53
|
-
ttl
|
|
54
|
-
type
|
|
55
|
-
algorithm
|
|
56
|
-
fptype
|
|
51
|
+
owner: this.fullyQualify(fqdn),
|
|
52
|
+
ttl: parseInt(ttl, 10),
|
|
53
|
+
type: 'SSHFP',
|
|
54
|
+
algorithm: TINYDNS.octalToUInt8(rdata.substring(0, 4)),
|
|
55
|
+
fptype: TINYDNS.octalToUInt8(rdata.substring(4, 8)),
|
|
57
56
|
fingerprint: TINYDNS.octalToHex(rdata.substring(8)),
|
|
58
|
-
timestamp
|
|
59
|
-
location
|
|
57
|
+
timestamp: ts,
|
|
58
|
+
location: loc !== '' && loc !== '\n' ? loc : '',
|
|
60
59
|
})
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
fromBind
|
|
62
|
+
fromBind(opts) {
|
|
64
63
|
// test.example.com 3600 IN SSHFP algo fptype fp
|
|
65
|
-
const [
|
|
64
|
+
const [owner, ttl, c, type, algo, fptype, fp] = opts.bindline.split(/\s+/)
|
|
66
65
|
return new SSHFP({
|
|
67
66
|
owner,
|
|
68
|
-
ttl
|
|
69
|
-
class
|
|
70
|
-
type
|
|
71
|
-
algorithm
|
|
72
|
-
fptype
|
|
67
|
+
ttl: parseInt(ttl, 10),
|
|
68
|
+
class: c,
|
|
69
|
+
type: type,
|
|
70
|
+
algorithm: parseInt(algo, 10),
|
|
71
|
+
fptype: parseInt(fptype, 10),
|
|
73
72
|
fingerprint: fp,
|
|
74
73
|
})
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
/****** EXPORTERS *******/
|
|
78
77
|
|
|
79
|
-
toTinydns
|
|
78
|
+
toTinydns() {
|
|
80
79
|
return this.getTinydnsGeneric(
|
|
81
80
|
TINYDNS.UInt8toOctal(this.get('algorithm')) +
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
TINYDNS.UInt8toOctal(this.get('fptype')) +
|
|
82
|
+
TINYDNS.packHex(this.get('fingerprint')),
|
|
84
83
|
)
|
|
85
84
|
}
|
|
86
85
|
}
|
package/rr/svcb.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import RR from '../rr.js'
|
|
2
|
+
|
|
3
|
+
export default class SVCB extends RR {
|
|
4
|
+
constructor(opts) {
|
|
5
|
+
super(opts)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/****** Resource record specific setters *******/
|
|
9
|
+
setPriority(val) {
|
|
10
|
+
this.is16bitInt('SVCB', 'priority', val)
|
|
11
|
+
|
|
12
|
+
this.set('priority', val)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
setTargetName(val) {
|
|
16
|
+
// this.isFullyQualified('SVCB', 'target name', val)
|
|
17
|
+
// this.isValidHostname('SVCB', 'target name', val)
|
|
18
|
+
|
|
19
|
+
// RFC 4034: letters in the DNS names are lower cased
|
|
20
|
+
this.set('target name', val.toLowerCase())
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
setParams(val) {
|
|
24
|
+
// if (!val) throw new Error(`SVCB: params is required`)
|
|
25
|
+
|
|
26
|
+
this.set('params', val)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getDescription() {
|
|
30
|
+
return 'Service Binding'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getRdataFields(arg) {
|
|
34
|
+
return ['priority', 'target name', 'params']
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
getRFCs() {
|
|
38
|
+
return [9460]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
getTypeId() {
|
|
42
|
+
return 64
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/****** IMPORTERS *******/
|
|
46
|
+
|
|
47
|
+
fromBind(opts) {
|
|
48
|
+
// test.example.com 3600 IN SVCB Priority TargetName Params
|
|
49
|
+
// _8443._foo.api.example.com. 7200 IN SVCB 0 svc4.example.net.
|
|
50
|
+
// svc4.example.net. 7200 IN SVCB 3 svc4.example.net. ( alpn="bar" port="8004" )
|
|
51
|
+
const [owner, ttl, c, type, pri, fqdn] = opts.bindline.split(/\s+/)
|
|
52
|
+
return new SVCB({
|
|
53
|
+
owner,
|
|
54
|
+
ttl: parseInt(ttl, 10),
|
|
55
|
+
class: c,
|
|
56
|
+
type,
|
|
57
|
+
priority: parseInt(pri, 10),
|
|
58
|
+
'target name': fqdn,
|
|
59
|
+
params: opts.bindline.split(/\s+/).slice(6).join(' ').trim(),
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/****** EXPORTERS *******/
|
|
64
|
+
}
|
package/rr/tlsa.js
CHANGED
|
@@ -1,106 +1,111 @@
|
|
|
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 TLSA extends RR {
|
|
7
|
-
constructor
|
|
6
|
+
constructor(opts) {
|
|
8
7
|
super(opts)
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
/****** Resource record specific setters *******/
|
|
12
|
-
setCertificateUsage
|
|
13
|
-
if (![
|
|
14
|
-
|
|
11
|
+
setCertificateUsage(val) {
|
|
12
|
+
if (![0, 1, 2, 3].includes(val))
|
|
13
|
+
this.throwHelp(`TLSA: certificate usage invalid`)
|
|
15
14
|
|
|
16
15
|
this.set('certificate usage', val)
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
setSelector
|
|
20
|
-
if (![
|
|
21
|
-
throw new Error(`TLSA: selector invalid, ${this.citeRFC()}`)
|
|
18
|
+
setSelector(val) {
|
|
19
|
+
if (![0, 1].includes(val)) this.throwHelp(`TLSA: selector invalid`)
|
|
22
20
|
|
|
23
21
|
this.set('selector', val)
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
setMatchingType
|
|
27
|
-
if (![
|
|
28
|
-
throw new Error(`TLSA: matching type, ${this.citeRFC()}`)
|
|
24
|
+
setMatchingType(val) {
|
|
25
|
+
if (![0, 1, 2].includes(val)) this.throwHelp(`TLSA: matching type`)
|
|
29
26
|
|
|
30
27
|
this.set('matching type', val)
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
setCertificateAssociationData
|
|
30
|
+
setCertificateAssociationData(val) {
|
|
34
31
|
this.set('certificate association data', val)
|
|
35
32
|
}
|
|
36
33
|
|
|
37
|
-
getDescription
|
|
34
|
+
getDescription() {
|
|
38
35
|
return 'TLSA certificate association'
|
|
39
36
|
}
|
|
40
37
|
|
|
41
|
-
getRdataFields
|
|
42
|
-
return [
|
|
38
|
+
getRdataFields(arg) {
|
|
39
|
+
return [
|
|
40
|
+
'certificate usage',
|
|
41
|
+
'selector',
|
|
42
|
+
'matching type',
|
|
43
|
+
'certificate association data',
|
|
44
|
+
]
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
getRFCs
|
|
46
|
-
return [
|
|
47
|
+
getRFCs() {
|
|
48
|
+
return [6698]
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
getTypeId
|
|
51
|
+
getTypeId() {
|
|
50
52
|
return 52
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
getQuotedFields
|
|
54
|
-
return [
|
|
55
|
+
getQuotedFields() {
|
|
56
|
+
return []
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
/****** IMPORTERS *******/
|
|
58
60
|
|
|
59
|
-
fromBind
|
|
61
|
+
fromBind(opts) {
|
|
60
62
|
// test.example.com 3600 IN TLSA, usage, selector, match, data
|
|
61
|
-
const match = opts.bindline.split(
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
const match = opts.bindline.split(
|
|
64
|
+
/^([^\s]+)\s+([0-9]+)\s+(\w+)\s+(\w+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+(.*?)\s*$/,
|
|
65
|
+
)
|
|
66
|
+
if (!match) this.throwHelp(`unable to parse TLSA: ${opts.bindline}`)
|
|
67
|
+
const [owner, ttl, c, type, usage, selector, matchtype, cad] =
|
|
68
|
+
match.slice(1)
|
|
64
69
|
return new TLSA({
|
|
65
|
-
owner
|
|
66
|
-
ttl
|
|
67
|
-
class
|
|
70
|
+
owner: this.fullyQualify(owner),
|
|
71
|
+
ttl: parseInt(ttl, 10),
|
|
72
|
+
class: c,
|
|
68
73
|
type,
|
|
69
|
-
'certificate usage'
|
|
70
|
-
selector
|
|
71
|
-
'matching type'
|
|
74
|
+
'certificate usage': parseInt(usage, 10),
|
|
75
|
+
selector: parseInt(selector, 10),
|
|
76
|
+
'matching type': parseInt(matchtype, 10),
|
|
72
77
|
'certificate association data': cad,
|
|
73
78
|
})
|
|
74
79
|
}
|
|
75
80
|
|
|
76
|
-
fromTinydns
|
|
77
|
-
const [
|
|
78
|
-
if (n != 52)
|
|
81
|
+
fromTinydns(opts) {
|
|
82
|
+
const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
|
|
83
|
+
if (n != 52) this.throwHelp('TLSA fromTinydns, invalid n')
|
|
79
84
|
|
|
80
85
|
const bytes = Buffer.from(TINYDNS.octalToChar(rdata), 'binary')
|
|
81
86
|
|
|
82
87
|
return new TLSA({
|
|
83
|
-
owner
|
|
84
|
-
ttl
|
|
85
|
-
type
|
|
86
|
-
'certificate usage'
|
|
87
|
-
selector
|
|
88
|
-
'matching type'
|
|
88
|
+
owner: this.fullyQualify(fqdn),
|
|
89
|
+
ttl: parseInt(ttl, 10),
|
|
90
|
+
type: 'TLSA',
|
|
91
|
+
'certificate usage': bytes.readUInt8(0),
|
|
92
|
+
selector: bytes.readUInt8(1),
|
|
93
|
+
'matching type': bytes.readUInt8(2),
|
|
89
94
|
'certificate association data': bytes.slice(3).toString(),
|
|
90
|
-
timestamp
|
|
91
|
-
location
|
|
95
|
+
timestamp: ts,
|
|
96
|
+
location: loc !== '' && loc !== '\n' ? loc : '',
|
|
92
97
|
})
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
/****** EXPORTERS *******/
|
|
96
|
-
toTinydns
|
|
101
|
+
toTinydns() {
|
|
97
102
|
const dataRe = new RegExp(/[\r\n\t:\\/]/, 'g')
|
|
98
103
|
|
|
99
104
|
return this.getTinydnsGeneric(
|
|
100
105
|
TINYDNS.UInt8toOctal(this.get('certificate usage')) +
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
106
|
+
TINYDNS.UInt8toOctal(this.get('selector')) +
|
|
107
|
+
TINYDNS.UInt8toOctal(this.get('matching type')) +
|
|
108
|
+
TINYDNS.escapeOctal(dataRe, this.get('certificate association data')),
|
|
104
109
|
)
|
|
105
110
|
}
|
|
106
111
|
}
|
package/rr/tsig.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import RR from '../rr.js'
|
|
2
|
+
|
|
3
|
+
export default class TSIG extends RR {
|
|
4
|
+
constructor(opts) {
|
|
5
|
+
super(opts)
|
|
6
|
+
if (opts === null) return
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/****** Resource record specific setters *******/
|
|
10
|
+
|
|
11
|
+
getDescription() {
|
|
12
|
+
return 'Transaction Signature'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getRdataFields(arg) {
|
|
16
|
+
return [
|
|
17
|
+
'algorithm name',
|
|
18
|
+
'time signed',
|
|
19
|
+
'fudge',
|
|
20
|
+
'mac',
|
|
21
|
+
'original id',
|
|
22
|
+
'error',
|
|
23
|
+
'other',
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getRFCs() {
|
|
28
|
+
return [2845]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getTypeId() {
|
|
32
|
+
return 250
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/****** IMPORTERS *******/
|
|
36
|
+
|
|
37
|
+
fromBind(opts) {
|
|
38
|
+
// test.example.com 3600 IN TSIG SAMPLE-ALG.EXAMPLE. 853804800 300 0 0 0
|
|
39
|
+
const [owner, ttl, c, type, algorithm] = opts.bindline.split(/\s+/)
|
|
40
|
+
return new TSIG({
|
|
41
|
+
owner,
|
|
42
|
+
ttl: parseInt(ttl, 10),
|
|
43
|
+
class: c,
|
|
44
|
+
type: type,
|
|
45
|
+
algorithm: algorithm,
|
|
46
|
+
// 'time signed': opts.bindline,
|
|
47
|
+
// fudge
|
|
48
|
+
// mac
|
|
49
|
+
// original id
|
|
50
|
+
// error
|
|
51
|
+
// other
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/****** EXPORTERS *******/
|
|
56
|
+
}
|