@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/rrsig.js
CHANGED
|
@@ -1,85 +1,91 @@
|
|
|
1
|
-
|
|
2
1
|
import RR from '../rr.js'
|
|
3
2
|
|
|
4
3
|
export default class RRSIG extends RR {
|
|
5
|
-
constructor
|
|
4
|
+
constructor(opts) {
|
|
6
5
|
super(opts)
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
/****** Resource record specific setters *******/
|
|
10
|
-
setTypeCovered
|
|
9
|
+
setTypeCovered(val) {
|
|
11
10
|
// a 2 octet Type Covered field
|
|
12
|
-
if (!val)
|
|
13
|
-
if (val.length > 2)
|
|
11
|
+
if (!val) this.throwHelp(`RRSIG: 'type covered' is required`)
|
|
12
|
+
if (val.length > 2) this.throwHelp(`RRSIG: 'type covered' is too long`)
|
|
14
13
|
|
|
15
14
|
this.set('type covered', val)
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
setAlgorithm
|
|
17
|
+
setAlgorithm(val) {
|
|
19
18
|
// a 1 octet Algorithm field
|
|
20
19
|
// 1=RSA/MD5, 2=DH, 3=RRSIGA/SHA-1, 4=EC, 5=RSA/SHA-1
|
|
21
|
-
if (![
|
|
22
|
-
|
|
20
|
+
if (![1, 2, 3, 4, 5, 253, 254].includes(val))
|
|
21
|
+
this.throwHelp(`RRSIG: algorithm invalid`)
|
|
23
22
|
|
|
24
23
|
this.set('algorithm', val)
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
setLabels
|
|
26
|
+
setLabels(val) {
|
|
28
27
|
// a 1 octet Labels field
|
|
29
28
|
this.is8bitInt('RRSIG', 'labels', val)
|
|
30
29
|
|
|
31
30
|
this.set('labels', val)
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
setOriginalTtl
|
|
33
|
+
setOriginalTtl(val) {
|
|
35
34
|
// a 4 octet Original TTL field
|
|
36
35
|
this.is32bitInt('RRSIG', 'original ttl', val)
|
|
37
36
|
|
|
38
37
|
this.set('original ttl', val)
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
setSignatureExpiration
|
|
40
|
+
setSignatureExpiration(val) {
|
|
42
41
|
// a 4 octet Signature Expiration field
|
|
43
42
|
this.set('signature expiration', val)
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
setSignatureInception
|
|
45
|
+
setSignatureInception(val) {
|
|
47
46
|
// a 4 octet Signature Inception field
|
|
48
47
|
this.set('signature inception', val)
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
setKeyTag
|
|
50
|
+
setKeyTag(val) {
|
|
52
51
|
// a 2 octet Key tag
|
|
53
52
|
this.set('key tag', val)
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
setSignersName
|
|
55
|
+
setSignersName(val) {
|
|
57
56
|
// the Signer's Name field
|
|
58
57
|
this.set('signers name', val)
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
setSignature
|
|
60
|
+
setSignature(val) {
|
|
62
61
|
// the Signature field.
|
|
63
62
|
|
|
64
63
|
this.set('signature', val)
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
getDescription
|
|
66
|
+
getDescription() {
|
|
68
67
|
return 'Resource Record Signature'
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
getRdataFields
|
|
70
|
+
getRdataFields(arg) {
|
|
72
71
|
return [
|
|
73
|
-
'type covered',
|
|
74
|
-
'
|
|
72
|
+
'type covered',
|
|
73
|
+
'algorithm',
|
|
74
|
+
'labels',
|
|
75
|
+
'original ttl',
|
|
76
|
+
'signature expiration',
|
|
77
|
+
'signature inception',
|
|
78
|
+
'key tag',
|
|
79
|
+
'signers name',
|
|
80
|
+
'signature',
|
|
75
81
|
]
|
|
76
82
|
}
|
|
77
83
|
|
|
78
|
-
getRFCs
|
|
79
|
-
return [
|
|
84
|
+
getRFCs() {
|
|
85
|
+
return [4034]
|
|
80
86
|
}
|
|
81
87
|
|
|
82
|
-
getTypeId
|
|
88
|
+
getTypeId() {
|
|
83
89
|
return 46
|
|
84
90
|
}
|
|
85
91
|
|
|
@@ -97,5 +103,4 @@ export default class RRSIG extends RR {
|
|
|
97
103
|
// }
|
|
98
104
|
|
|
99
105
|
/****** EXPORTERS *******/
|
|
100
|
-
|
|
101
106
|
}
|
package/rr/sig.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
|
|
2
1
|
import RR from '../rr.js'
|
|
3
2
|
|
|
4
3
|
export default class SIG extends RR {
|
|
5
|
-
constructor
|
|
4
|
+
constructor(opts) {
|
|
6
5
|
super(opts)
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
/****** Resource record specific setters *******/
|
|
10
|
-
setTypeCovered
|
|
9
|
+
setTypeCovered(val) {
|
|
11
10
|
// a 2 octet Type Covered field
|
|
12
|
-
if (!val)
|
|
11
|
+
if (!val) this.throwHelp(`SIG: 'type covered' is required`)
|
|
13
12
|
|
|
14
13
|
this.set('type covered', val)
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
setAlgorithm
|
|
16
|
+
setAlgorithm(val) {
|
|
18
17
|
// a 1 octet Algorithm field
|
|
19
18
|
|
|
20
19
|
this.is8bitInt('SIG', 'labels', val)
|
|
@@ -22,64 +21,71 @@ export default class SIG extends RR {
|
|
|
22
21
|
this.set('algorithm', val)
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
setLabels
|
|
24
|
+
setLabels(val) {
|
|
26
25
|
// a 1 octet Labels field
|
|
27
26
|
this.is8bitInt('SIG', 'labels', val)
|
|
28
27
|
|
|
29
28
|
this.set('labels', val)
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
setOriginalTtl
|
|
31
|
+
setOriginalTtl(val) {
|
|
33
32
|
// a 4 octet Original TTL field
|
|
34
33
|
this.is32bitInt('SIG', 'original ttl', val)
|
|
35
34
|
|
|
36
35
|
this.set('original ttl', val)
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
setSignatureExpiration
|
|
38
|
+
setSignatureExpiration(val) {
|
|
40
39
|
// a 4 octet Signature Expiration field
|
|
41
40
|
this.set('signature expiration', val)
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
setSignatureInception
|
|
43
|
+
setSignatureInception(val) {
|
|
45
44
|
// a 4 octet Signature Inception field
|
|
46
45
|
this.set('signature inception', val)
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
setKeyTag
|
|
48
|
+
setKeyTag(val) {
|
|
50
49
|
// a 2 octet Key tag
|
|
51
50
|
this.set('key tag', val)
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
setSignersName
|
|
53
|
+
setSignersName(val) {
|
|
55
54
|
// the domain name of the signer generating the SIG RR
|
|
56
55
|
|
|
57
56
|
// RFC 4034: letters in the DNS names are lower cased
|
|
58
57
|
this.set('signers name', val.toLowerCase())
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
setSignature
|
|
60
|
+
setSignature(val) {
|
|
62
61
|
// the Signature field.
|
|
63
62
|
|
|
64
63
|
this.set('signature', val)
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
getDescription
|
|
66
|
+
getDescription() {
|
|
68
67
|
return 'Signature'
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
getRdataFields
|
|
70
|
+
getRdataFields(arg) {
|
|
72
71
|
return [
|
|
73
|
-
'type covered',
|
|
74
|
-
'
|
|
72
|
+
'type covered',
|
|
73
|
+
'algorithm',
|
|
74
|
+
'labels',
|
|
75
|
+
'original ttl',
|
|
76
|
+
'signature expiration',
|
|
77
|
+
'signature inception',
|
|
78
|
+
'key tag',
|
|
79
|
+
'signers name',
|
|
80
|
+
'signature',
|
|
75
81
|
]
|
|
76
82
|
}
|
|
77
83
|
|
|
78
|
-
getRFCs
|
|
79
|
-
return [
|
|
84
|
+
getRFCs() {
|
|
85
|
+
return [2535]
|
|
80
86
|
}
|
|
81
87
|
|
|
82
|
-
getTypeId
|
|
88
|
+
getTypeId() {
|
|
83
89
|
return 24
|
|
84
90
|
}
|
|
85
91
|
|
|
@@ -96,5 +102,4 @@ export default class SIG extends RR {
|
|
|
96
102
|
// }
|
|
97
103
|
|
|
98
104
|
/****** EXPORTERS *******/
|
|
99
|
-
|
|
100
105
|
}
|
package/rr/smimea.js
CHANGED
|
@@ -1,73 +1,78 @@
|
|
|
1
|
-
|
|
2
1
|
import RR from '../rr.js'
|
|
3
2
|
|
|
4
3
|
export default class SMIMEA extends RR {
|
|
5
|
-
constructor
|
|
4
|
+
constructor(opts) {
|
|
6
5
|
super(opts)
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
/****** Resource record specific setters *******/
|
|
10
|
-
setCertificateUsage
|
|
11
|
-
if (![
|
|
12
|
-
|
|
9
|
+
setCertificateUsage(val) {
|
|
10
|
+
if (![0, 1, 2, 3].includes(val))
|
|
11
|
+
this.throwHelp(`SMIMEA: certificate usage invalid`)
|
|
13
12
|
|
|
14
13
|
this.set('certificate usage', val)
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
setSelector
|
|
18
|
-
if (![
|
|
19
|
-
throw new Error(`SMIMEA: selector invalid, ${this.citeRFC()}`)
|
|
16
|
+
setSelector(val) {
|
|
17
|
+
if (![0, 1].includes(val)) this.throwHelp(`SMIMEA: selector invalid`)
|
|
20
18
|
|
|
21
19
|
this.set('selector', val)
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
setMatchingType
|
|
25
|
-
if (![
|
|
26
|
-
throw new Error(`SMIMEA: matching type, ${this.citeRFC()}`)
|
|
22
|
+
setMatchingType(val) {
|
|
23
|
+
if (![0, 1, 2].includes(val)) this.throwHelp(`SMIMEA: matching type`)
|
|
27
24
|
|
|
28
25
|
this.set('matching type', val)
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
setCertificateAssociationData
|
|
28
|
+
setCertificateAssociationData(val) {
|
|
32
29
|
this.set('certificate association data', val)
|
|
33
30
|
}
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
getDescription () {
|
|
32
|
+
getDescription() {
|
|
37
33
|
return 'S/MIME cert association'
|
|
38
34
|
}
|
|
39
35
|
|
|
40
|
-
getRdataFields
|
|
41
|
-
return [
|
|
36
|
+
getRdataFields(arg) {
|
|
37
|
+
return [
|
|
38
|
+
'certificate usage',
|
|
39
|
+
'selector',
|
|
40
|
+
'matching type',
|
|
41
|
+
'certificate association data',
|
|
42
|
+
]
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
getRFCs
|
|
45
|
-
return [
|
|
45
|
+
getRFCs() {
|
|
46
|
+
return [8162]
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
getTypeId
|
|
49
|
+
getTypeId() {
|
|
49
50
|
return 53
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
getQuotedFields
|
|
53
|
-
return [
|
|
53
|
+
getQuotedFields() {
|
|
54
|
+
return []
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
/****** IMPORTERS *******/
|
|
57
58
|
|
|
58
|
-
fromBind
|
|
59
|
+
fromBind(opts) {
|
|
59
60
|
// test.example.com 3600 IN SMIMEA, usage, selector, match, data
|
|
60
|
-
const [
|
|
61
|
+
const [owner, ttl, c, type, usage, selector, match] =
|
|
62
|
+
opts.bindline.split(/\s+/)
|
|
61
63
|
return new SMIMEA({
|
|
62
64
|
owner,
|
|
63
|
-
ttl
|
|
64
|
-
class
|
|
65
|
-
type
|
|
66
|
-
'certificate usage'
|
|
67
|
-
selector
|
|
68
|
-
'matching type'
|
|
69
|
-
'certificate association data': opts.bindline
|
|
65
|
+
ttl: parseInt(ttl, 10),
|
|
66
|
+
class: c,
|
|
67
|
+
type: type,
|
|
68
|
+
'certificate usage': parseInt(usage, 10),
|
|
69
|
+
selector: parseInt(selector, 10),
|
|
70
|
+
'matching type': parseInt(match, 10),
|
|
71
|
+
'certificate association data': opts.bindline
|
|
72
|
+
.split(/\s+/)
|
|
73
|
+
.slice(7)
|
|
74
|
+
.join(' ')
|
|
75
|
+
.trim(),
|
|
70
76
|
})
|
|
71
77
|
}
|
|
72
|
-
|
|
73
78
|
}
|
package/rr/soa.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
1
|
import RR from '../rr.js'
|
|
3
2
|
|
|
4
3
|
export default class SOA extends RR {
|
|
5
|
-
constructor
|
|
4
|
+
constructor(opts) {
|
|
6
5
|
super(opts)
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
/****** Resource record specific setters *******/
|
|
10
|
-
setMinimum
|
|
9
|
+
setMinimum(val) {
|
|
11
10
|
// minimum (used for negative caching, since RFC 2308)
|
|
12
11
|
// RFC 1912 sugggests 1-5 days
|
|
13
12
|
// RIPE recommends 3600 (1 hour)
|
|
@@ -16,7 +15,7 @@ export default class SOA extends RR {
|
|
|
16
15
|
this.set('minimum', val)
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
setMname
|
|
18
|
+
setMname(val) {
|
|
20
19
|
// MNAME (primary NS)
|
|
21
20
|
this.isValidHostname('SOA', 'MNAME', val)
|
|
22
21
|
this.isFullyQualified('SOA', 'MNAME', val)
|
|
@@ -25,23 +24,23 @@ export default class SOA extends RR {
|
|
|
25
24
|
this.set('mname', val.toLowerCase())
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
setRname
|
|
27
|
+
setRname(val) {
|
|
29
28
|
// RNAME (email of admin) (escape . with \)
|
|
30
29
|
this.isValidHostname('SOA', 'RNAME', val)
|
|
31
30
|
this.isFullyQualified('SOA', 'RNAME', val)
|
|
32
|
-
if (/@/.test(val))
|
|
31
|
+
if (/@/.test(val)) this.throwHelp(`SOA rname replaces @ with a . (dot)`)
|
|
33
32
|
|
|
34
33
|
// RFC 4034: letters in the DNS names are lower cased
|
|
35
34
|
this.set('rname', val.toLowerCase())
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
setSerial
|
|
37
|
+
setSerial(val) {
|
|
39
38
|
this.is32bitInt('SOA', 'serial', val)
|
|
40
39
|
|
|
41
40
|
this.set('serial', val)
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
setRefresh
|
|
43
|
+
setRefresh(val) {
|
|
45
44
|
// refresh (seconds after which to check with master for update)
|
|
46
45
|
// RFC 1912 suggests 20 min to 12 hours
|
|
47
46
|
// RIPE recommends 86400 (24 hours)
|
|
@@ -50,7 +49,7 @@ export default class SOA extends RR {
|
|
|
50
49
|
this.set('refresh', val)
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
setRetry
|
|
52
|
+
setRetry(val) {
|
|
54
53
|
// seconds after which to retry serial # update
|
|
55
54
|
// RIPE recommends 7200 seconds (2 hours)
|
|
56
55
|
|
|
@@ -59,7 +58,7 @@ export default class SOA extends RR {
|
|
|
59
58
|
this.set('retry', val)
|
|
60
59
|
}
|
|
61
60
|
|
|
62
|
-
setExpire
|
|
61
|
+
setExpire(val) {
|
|
63
62
|
// seconds after which secondary should drop zone if no master response
|
|
64
63
|
// RFC 1912 suggests 2-4 weeks
|
|
65
64
|
// RIPE suggests 3600000 (1,000 hours, 6 weeks)
|
|
@@ -68,73 +67,88 @@ export default class SOA extends RR {
|
|
|
68
67
|
this.set('expire', val)
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
getDescription
|
|
70
|
+
getDescription() {
|
|
72
71
|
return 'Start Of Authority'
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
getRdataFields
|
|
76
|
-
return [
|
|
74
|
+
getRdataFields(arg) {
|
|
75
|
+
return ['mname', 'rname', 'serial', 'refresh', 'retry', 'expire', 'minimum']
|
|
77
76
|
}
|
|
78
77
|
|
|
79
|
-
getRFCs
|
|
80
|
-
return [
|
|
78
|
+
getRFCs() {
|
|
79
|
+
return [1035, 2308]
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
getTypeId
|
|
82
|
+
getTypeId() {
|
|
84
83
|
return 6
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
/****** IMPORTERS *******/
|
|
88
|
-
fromBind
|
|
87
|
+
fromBind(opts) {
|
|
89
88
|
// example.com TTL IN SOA mname rname serial refresh retry expire minimum
|
|
90
|
-
const [
|
|
89
|
+
const [
|
|
90
|
+
owner,
|
|
91
|
+
ttl,
|
|
92
|
+
c,
|
|
93
|
+
type,
|
|
94
|
+
mname,
|
|
95
|
+
rname,
|
|
96
|
+
serial,
|
|
97
|
+
refresh,
|
|
98
|
+
retry,
|
|
99
|
+
expire,
|
|
100
|
+
minimum,
|
|
101
|
+
] = opts.bindline.split(/[\s+]/)
|
|
91
102
|
|
|
92
103
|
return new SOA({
|
|
93
104
|
owner,
|
|
94
|
-
ttl
|
|
95
|
-
class
|
|
105
|
+
ttl: parseInt(ttl) || parseInt(minimum),
|
|
106
|
+
class: c,
|
|
96
107
|
type,
|
|
97
108
|
mname,
|
|
98
109
|
rname,
|
|
99
|
-
serial
|
|
110
|
+
serial: parseInt(serial, 10),
|
|
100
111
|
refresh: parseInt(refresh, 10),
|
|
101
|
-
retry
|
|
102
|
-
expire
|
|
112
|
+
retry: parseInt(retry, 10),
|
|
113
|
+
expire: parseInt(expire, 10),
|
|
103
114
|
minimum: parseInt(minimum, 10),
|
|
104
115
|
})
|
|
105
116
|
}
|
|
106
117
|
|
|
107
|
-
fromTinydns
|
|
118
|
+
fromTinydns(opts) {
|
|
108
119
|
// Zfqdn:mname:rname:ser:ref:ret:exp:min:ttl:time:lo
|
|
109
|
-
const [
|
|
120
|
+
const [fqdn, mname, rname, ser, ref, ret, exp, min, ttl, ts, loc] =
|
|
121
|
+
opts.tinyline.substring(1).split(':')
|
|
110
122
|
|
|
111
123
|
return new SOA({
|
|
112
|
-
owner
|
|
113
|
-
ttl
|
|
114
|
-
type
|
|
115
|
-
mname
|
|
116
|
-
rname
|
|
117
|
-
serial
|
|
118
|
-
refresh
|
|
119
|
-
retry
|
|
120
|
-
expire
|
|
121
|
-
minimum
|
|
124
|
+
owner: this.fullyQualify(fqdn),
|
|
125
|
+
ttl: parseInt(ttl, 10),
|
|
126
|
+
type: 'SOA',
|
|
127
|
+
mname: this.fullyQualify(mname),
|
|
128
|
+
rname: this.fullyQualify(rname),
|
|
129
|
+
serial: parseInt(ser || opts.default?.serial, 10),
|
|
130
|
+
refresh: parseInt(ref, 10) || 16384,
|
|
131
|
+
retry: parseInt(ret, 10) || 2048,
|
|
132
|
+
expire: parseInt(exp, 10) || 1048576,
|
|
133
|
+
minimum: parseInt(min, 10) || 2560,
|
|
122
134
|
timestamp: parseInt(ts) || '',
|
|
123
|
-
location
|
|
135
|
+
location: loc !== '' && loc !== '\n' ? loc : '',
|
|
124
136
|
})
|
|
125
137
|
}
|
|
126
138
|
|
|
127
139
|
/****** EXPORTERS *******/
|
|
128
|
-
toBind
|
|
129
|
-
const numFields = [
|
|
130
|
-
return `${this.getFQDN('owner', zone_opts)}\t${this.get('ttl')}\t${this.get('class')}\tSOA\t${this.getFQDN('mname', zone_opts)}\t${this.getFQDN('rname', zone_opts)}${numFields.map(f => '\t' + this.get(f)
|
|
140
|
+
toBind(zone_opts) {
|
|
141
|
+
const numFields = ['serial', 'refresh', 'retry', 'expire', 'minimum']
|
|
142
|
+
return `${this.getFQDN('owner', zone_opts)}\t${this.get('ttl')}\t${this.get('class')}\tSOA\t${this.getFQDN('mname', zone_opts)}\t${this.getFQDN('rname', zone_opts)}${numFields.map((f) => '\t' + this.get(f)).join('')}\n`
|
|
131
143
|
}
|
|
132
144
|
|
|
133
|
-
toMaraDNS
|
|
134
|
-
return `${this.get('owner')}\t SOA\t${this.getRdataFields()
|
|
145
|
+
toMaraDNS() {
|
|
146
|
+
return `${this.get('owner')}\t SOA\t${this.getRdataFields()
|
|
147
|
+
.map((f) => this.getQuoted(f))
|
|
148
|
+
.join('\t')} ~\n`
|
|
135
149
|
}
|
|
136
150
|
|
|
137
|
-
toTinydns
|
|
151
|
+
toTinydns() {
|
|
138
152
|
return `Z${this.getTinyFQDN('owner')}:${this.getTinyFQDN('mname')}:${this.getTinyFQDN('rname')}:${this.getEmpty('serial')}:${this.getEmpty('refresh')}:${this.getEmpty('retry')}:${this.getEmpty('expire')}:${this.getEmpty('minimum')}:${this.getTinydnsPostamble()}\n`
|
|
139
153
|
}
|
|
140
154
|
}
|
package/rr/spf.js
CHANGED
|
@@ -5,50 +5,53 @@ import TXT from './txt.js'
|
|
|
5
5
|
import * as TINYDNS from '../lib/tinydns.js'
|
|
6
6
|
|
|
7
7
|
export default class SPF extends TXT {
|
|
8
|
-
constructor
|
|
8
|
+
constructor(opts) {
|
|
9
9
|
super(opts)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/****** Resource record specific setters *******/
|
|
13
|
-
setData
|
|
13
|
+
setData(val) {
|
|
14
14
|
this.set('data', val)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
getDescription
|
|
17
|
+
getDescription() {
|
|
18
18
|
return 'Sender Policy Framework'
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
getRdataFields
|
|
22
|
-
return [
|
|
21
|
+
getRdataFields(arg) {
|
|
22
|
+
return ['data']
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
getRFCs
|
|
26
|
-
return [
|
|
25
|
+
getRFCs() {
|
|
26
|
+
return [4408, 7208]
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
getTypeId
|
|
29
|
+
getTypeId() {
|
|
30
30
|
return 99
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/****** IMPORTERS *******/
|
|
34
|
-
fromTinydns
|
|
34
|
+
fromTinydns(opts) {
|
|
35
35
|
// SPF via generic, :fqdn:n:rdata:ttl:timestamp:lo
|
|
36
|
-
const [
|
|
37
|
-
if (n != 99)
|
|
36
|
+
const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
|
|
37
|
+
if (n != 99) this.throwHelp('SPF fromTinydns, invalid n')
|
|
38
38
|
|
|
39
39
|
return new SPF({
|
|
40
|
-
type
|
|
41
|
-
owner
|
|
42
|
-
data
|
|
43
|
-
ttl
|
|
40
|
+
type: 'SPF',
|
|
41
|
+
owner: this.fullyQualify(fqdn),
|
|
42
|
+
data: TINYDNS.octalToChar(rdata),
|
|
43
|
+
ttl: parseInt(ttl, 10),
|
|
44
44
|
timestamp: ts,
|
|
45
|
-
location
|
|
45
|
+
location: loc !== '' && loc !== '\n' ? loc : '',
|
|
46
46
|
})
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/****** EXPORTERS *******/
|
|
50
|
-
toTinydns
|
|
51
|
-
const rdata = TINYDNS.escapeOctal(
|
|
50
|
+
toTinydns() {
|
|
51
|
+
const rdata = TINYDNS.escapeOctal(
|
|
52
|
+
new RegExp(/[\r\n\t:\\/]/, 'g'),
|
|
53
|
+
this.get('data'),
|
|
54
|
+
)
|
|
52
55
|
return this.getTinydnsGeneric(rdata)
|
|
53
56
|
}
|
|
54
57
|
}
|