@nictool/dns-resource-record 1.1.6 → 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 +56 -62
- package/index.js +77 -29
- package/lib/tinydns.js +68 -61
- package/package.json +10 -6
- 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 +90 -30
- 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 +116 -79
- 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 -26
- 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/tlsa.js
CHANGED
|
@@ -1,106 +1,113 @@
|
|
|
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 (![
|
|
11
|
+
setCertificateUsage(val) {
|
|
12
|
+
if (![0, 1, 2, 3].includes(val))
|
|
14
13
|
throw new Error(`TLSA: certificate usage invalid, ${this.citeRFC()}`)
|
|
15
14
|
|
|
16
15
|
this.set('certificate usage', val)
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
setSelector
|
|
20
|
-
if (![
|
|
18
|
+
setSelector(val) {
|
|
19
|
+
if (![0, 1].includes(val))
|
|
21
20
|
throw new Error(`TLSA: selector invalid, ${this.citeRFC()}`)
|
|
22
21
|
|
|
23
22
|
this.set('selector', val)
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
setMatchingType
|
|
27
|
-
if (![
|
|
25
|
+
setMatchingType(val) {
|
|
26
|
+
if (![0, 1, 2].includes(val))
|
|
28
27
|
throw new Error(`TLSA: matching type, ${this.citeRFC()}`)
|
|
29
28
|
|
|
30
29
|
this.set('matching type', val)
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
setCertificateAssociationData
|
|
32
|
+
setCertificateAssociationData(val) {
|
|
34
33
|
this.set('certificate association data', val)
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
getDescription
|
|
36
|
+
getDescription() {
|
|
38
37
|
return 'TLSA certificate association'
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
getRdataFields
|
|
42
|
-
return [
|
|
40
|
+
getRdataFields(arg) {
|
|
41
|
+
return [
|
|
42
|
+
'certificate usage',
|
|
43
|
+
'selector',
|
|
44
|
+
'matching type',
|
|
45
|
+
'certificate association data',
|
|
46
|
+
]
|
|
43
47
|
}
|
|
44
48
|
|
|
45
|
-
getRFCs
|
|
46
|
-
return [
|
|
49
|
+
getRFCs() {
|
|
50
|
+
return [6698]
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
getTypeId
|
|
53
|
+
getTypeId() {
|
|
50
54
|
return 52
|
|
51
55
|
}
|
|
52
56
|
|
|
53
|
-
getQuotedFields
|
|
54
|
-
return [
|
|
57
|
+
getQuotedFields() {
|
|
58
|
+
return []
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
/****** IMPORTERS *******/
|
|
58
62
|
|
|
59
|
-
fromBind
|
|
63
|
+
fromBind(opts) {
|
|
60
64
|
// test.example.com 3600 IN TLSA, usage, selector, match, data
|
|
61
|
-
const match = opts.bindline.split(
|
|
65
|
+
const match = opts.bindline.split(
|
|
66
|
+
/^([^\s]+)\s+([0-9]+)\s+(\w+)\s+(\w+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+(.*?)\s*$/,
|
|
67
|
+
)
|
|
62
68
|
if (!match) throw new Error(`unable to parse TLSA: ${opts.bindline}`)
|
|
63
|
-
const [
|
|
69
|
+
const [owner, ttl, c, type, usage, selector, matchtype, cad] =
|
|
70
|
+
match.slice(1)
|
|
64
71
|
return new TLSA({
|
|
65
|
-
owner
|
|
66
|
-
ttl
|
|
67
|
-
class
|
|
72
|
+
owner: this.fullyQualify(owner),
|
|
73
|
+
ttl: parseInt(ttl, 10),
|
|
74
|
+
class: c,
|
|
68
75
|
type,
|
|
69
|
-
'certificate usage'
|
|
70
|
-
selector
|
|
71
|
-
'matching type'
|
|
76
|
+
'certificate usage': parseInt(usage, 10),
|
|
77
|
+
selector: parseInt(selector, 10),
|
|
78
|
+
'matching type': parseInt(matchtype, 10),
|
|
72
79
|
'certificate association data': cad,
|
|
73
80
|
})
|
|
74
81
|
}
|
|
75
82
|
|
|
76
|
-
fromTinydns
|
|
77
|
-
const [
|
|
83
|
+
fromTinydns(opts) {
|
|
84
|
+
const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
|
|
78
85
|
if (n != 52) throw new Error('TLSA fromTinydns, invalid n')
|
|
79
86
|
|
|
80
87
|
const bytes = Buffer.from(TINYDNS.octalToChar(rdata), 'binary')
|
|
81
88
|
|
|
82
89
|
return new TLSA({
|
|
83
|
-
owner
|
|
84
|
-
ttl
|
|
85
|
-
type
|
|
86
|
-
'certificate usage'
|
|
87
|
-
selector
|
|
88
|
-
'matching type'
|
|
90
|
+
owner: this.fullyQualify(fqdn),
|
|
91
|
+
ttl: parseInt(ttl, 10),
|
|
92
|
+
type: 'TLSA',
|
|
93
|
+
'certificate usage': bytes.readUInt8(0),
|
|
94
|
+
selector: bytes.readUInt8(1),
|
|
95
|
+
'matching type': bytes.readUInt8(2),
|
|
89
96
|
'certificate association data': bytes.slice(3).toString(),
|
|
90
|
-
timestamp
|
|
91
|
-
location
|
|
97
|
+
timestamp: ts,
|
|
98
|
+
location: loc !== '' && loc !== '\n' ? loc : '',
|
|
92
99
|
})
|
|
93
100
|
}
|
|
94
101
|
|
|
95
102
|
/****** EXPORTERS *******/
|
|
96
|
-
toTinydns
|
|
103
|
+
toTinydns() {
|
|
97
104
|
const dataRe = new RegExp(/[\r\n\t:\\/]/, 'g')
|
|
98
105
|
|
|
99
106
|
return this.getTinydnsGeneric(
|
|
100
107
|
TINYDNS.UInt8toOctal(this.get('certificate usage')) +
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
108
|
+
TINYDNS.UInt8toOctal(this.get('selector')) +
|
|
109
|
+
TINYDNS.UInt8toOctal(this.get('matching type')) +
|
|
110
|
+
TINYDNS.escapeOctal(dataRe, this.get('certificate association data')),
|
|
104
111
|
)
|
|
105
112
|
}
|
|
106
113
|
}
|
package/rr/tsig.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
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 ['algorithm name', 'time signed', 'fudge', 'mac', 'original id', 'error', 'other']
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getRFCs() {
|
|
20
|
+
return [2845]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getTypeId() {
|
|
24
|
+
return 250
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/****** IMPORTERS *******/
|
|
28
|
+
|
|
29
|
+
fromBind(opts) {
|
|
30
|
+
// test.example.com 3600 IN TSIG SAMPLE-ALG.EXAMPLE. 853804800 300 0 0 0
|
|
31
|
+
const [owner, ttl, c, type, algorithm] = opts.bindline.split(/\s+/)
|
|
32
|
+
return new TSIG({
|
|
33
|
+
owner,
|
|
34
|
+
ttl: parseInt(ttl, 10),
|
|
35
|
+
class: c,
|
|
36
|
+
type: type,
|
|
37
|
+
'algorithm': algorithm,
|
|
38
|
+
// 'time signed': opts.bindline,
|
|
39
|
+
// fudge
|
|
40
|
+
// mac
|
|
41
|
+
// original id
|
|
42
|
+
// error
|
|
43
|
+
// other
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/****** EXPORTERS *******/
|
|
48
|
+
}
|
package/rr/txt.js
CHANGED
|
@@ -1,61 +1,59 @@
|
|
|
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 TXT extends RR {
|
|
7
|
-
constructor
|
|
6
|
+
constructor(opts) {
|
|
8
7
|
super(opts)
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
/****** Resource record specific setters *******/
|
|
12
|
-
setData
|
|
11
|
+
setData(val) {
|
|
13
12
|
this.set('data', val)
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
getDescription
|
|
15
|
+
getDescription() {
|
|
17
16
|
return 'Text'
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
getRdataFields
|
|
21
|
-
return [
|
|
19
|
+
getRdataFields(arg) {
|
|
20
|
+
return ['data']
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
getRFCs
|
|
25
|
-
return [
|
|
23
|
+
getRFCs() {
|
|
24
|
+
return [1035]
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
getTypeId
|
|
27
|
+
getTypeId() {
|
|
29
28
|
return 16
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
/****** IMPORTERS *******/
|
|
33
|
-
fromTinydns
|
|
32
|
+
fromTinydns(opts) {
|
|
34
33
|
const str = opts.tinyline
|
|
35
34
|
let fqdn, rdata, s, ttl, ts, loc
|
|
36
35
|
// 'fqdn:s:ttl:timestamp:lo
|
|
37
36
|
if (str[0] === "'") {
|
|
38
|
-
[
|
|
37
|
+
;[fqdn, s, ttl, ts, loc] = str.substring(1).split(':')
|
|
39
38
|
rdata = TINYDNS.octalToChar(s)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
[ fqdn, rdata, ttl, ts, loc ] = this.fromTinydnsGeneric(str)
|
|
39
|
+
} else {
|
|
40
|
+
;[fqdn, rdata, ttl, ts, loc] = this.fromTinydnsGeneric(str)
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
return new this.constructor({
|
|
46
|
-
owner
|
|
47
|
-
ttl
|
|
48
|
-
type
|
|
49
|
-
data
|
|
44
|
+
owner: this.fullyQualify(fqdn),
|
|
45
|
+
ttl: parseInt(ttl, 10),
|
|
46
|
+
type: 'TXT',
|
|
47
|
+
data: rdata,
|
|
50
48
|
timestamp: ts,
|
|
51
|
-
location
|
|
49
|
+
location: loc !== '' && loc !== '\n' ? loc : '',
|
|
52
50
|
})
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
fromTinydnsGeneric
|
|
53
|
+
fromTinydnsGeneric(str) {
|
|
56
54
|
// generic: :fqdn:n:rdata:ttl:timestamp:location
|
|
57
55
|
// eslint-disable-next-line prefer-const
|
|
58
|
-
let [
|
|
56
|
+
let [fqdn, n, rdata, ttl, ts, loc] = str.substring(1).split(':')
|
|
59
57
|
if (n != 16) throw new Error('TXT fromTinydns, invalid n')
|
|
60
58
|
|
|
61
59
|
rdata = TINYDNS.octalToChar(rdata)
|
|
@@ -67,35 +65,40 @@ export default class TXT extends RR {
|
|
|
67
65
|
pos = len + pos
|
|
68
66
|
len = rdata.charCodeAt(pos + 1)
|
|
69
67
|
}
|
|
70
|
-
return [
|
|
68
|
+
return [fqdn, s, ttl, ts, loc]
|
|
71
69
|
}
|
|
72
70
|
|
|
73
|
-
fromBind
|
|
71
|
+
fromBind(opts) {
|
|
74
72
|
// test.example.com 3600 IN TXT "..."
|
|
75
|
-
const match = opts.bindline.split(
|
|
73
|
+
const match = opts.bindline.split(
|
|
74
|
+
/^([^\s]+)\s+([0-9]+)\s+(\w+)\s+(\w+)\s+?\s*(.*?)\s*$/,
|
|
75
|
+
)
|
|
76
76
|
if (!match) throw new Error(`unable to parse TXT: ${opts.bindline}`)
|
|
77
|
-
const [
|
|
77
|
+
const [owner, ttl, c, type, rdata] = match.slice(1)
|
|
78
78
|
|
|
79
79
|
return new this.constructor({
|
|
80
80
|
owner,
|
|
81
|
-
ttl
|
|
81
|
+
ttl: parseInt(ttl, 10),
|
|
82
82
|
class: c,
|
|
83
83
|
type,
|
|
84
|
-
data
|
|
84
|
+
data: rdata
|
|
85
|
+
.match(/"([^"]+?)"/g)
|
|
86
|
+
.map((s) => s.replace(/^"|"$/g, ''))
|
|
87
|
+
.join(''),
|
|
85
88
|
})
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
/****** EXPORTERS *******/
|
|
89
|
-
toBind
|
|
92
|
+
toBind(zone_opts) {
|
|
90
93
|
return `${this.getPrefix(zone_opts)}\t"${asQuotedStrings(this.get('data'))}"\n`
|
|
91
94
|
}
|
|
92
95
|
|
|
93
|
-
toMaraDNS
|
|
96
|
+
toMaraDNS() {
|
|
94
97
|
const data = asQuotedStrings(this.get('data')).replace(/"/g, "'")
|
|
95
98
|
return `${this.get('owner')}\t+${this.get('ttl')}\t${this.get('type')}\t'${data}' ~\n`
|
|
96
99
|
}
|
|
97
100
|
|
|
98
|
-
toTinydns
|
|
101
|
+
toTinydns() {
|
|
99
102
|
let data = this.get('data')
|
|
100
103
|
if (Array.isArray(data)) data = data.join('')
|
|
101
104
|
const rdata = TINYDNS.escapeOctal(new RegExp(/[\r\n\t:\\/]/, 'g'), data)
|
|
@@ -103,15 +106,19 @@ export default class TXT extends RR {
|
|
|
103
106
|
}
|
|
104
107
|
}
|
|
105
108
|
|
|
106
|
-
function asQuotedStrings
|
|
107
|
-
|
|
109
|
+
function asQuotedStrings(data) {
|
|
108
110
|
// BIND croaks when any string in the TXT RR data is longer than 255
|
|
109
111
|
if (Array.isArray(data)) {
|
|
110
112
|
let hasTooLong = false
|
|
111
113
|
for (const str of data) {
|
|
112
114
|
if (str.length > 255) hasTooLong = true
|
|
113
115
|
}
|
|
114
|
-
return hasTooLong
|
|
116
|
+
return hasTooLong
|
|
117
|
+
? data
|
|
118
|
+
.join('')
|
|
119
|
+
.match(/(.{1,255})/g)
|
|
120
|
+
.join('" "')
|
|
121
|
+
: data.join('" "')
|
|
115
122
|
}
|
|
116
123
|
|
|
117
124
|
if (data.length > 255) {
|
package/rr/uri.js
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
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 URI extends RR {
|
|
7
|
-
constructor
|
|
6
|
+
constructor(opts) {
|
|
8
7
|
super(opts)
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
/****** Resource record specific setters *******/
|
|
12
|
-
setPriority
|
|
11
|
+
setPriority(val) {
|
|
13
12
|
this.is16bitInt('URI', 'priority', val)
|
|
14
13
|
|
|
15
14
|
this.set('priority', val)
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
setWeight
|
|
17
|
+
setWeight(val) {
|
|
19
18
|
this.is16bitInt('URI', 'weight', val)
|
|
20
19
|
|
|
21
20
|
this.set('weight', val)
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
setTarget
|
|
23
|
+
setTarget(val) {
|
|
25
24
|
if (!val) throw new Error(`URI: target is required, ${this.citeRFC()}`)
|
|
26
25
|
|
|
27
26
|
this.set('target', val)
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
/****** IMPORTERS *******/
|
|
31
|
-
fromTinydns
|
|
30
|
+
fromTinydns(opts) {
|
|
32
31
|
// URI via generic, :fqdn:n:rdata:ttl:timestamp:lo
|
|
33
|
-
const [
|
|
32
|
+
const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
|
|
34
33
|
if (n != 256) throw new Error('URI fromTinydns, invalid n')
|
|
35
34
|
|
|
36
35
|
return new URI({
|
|
37
|
-
type
|
|
38
|
-
owner
|
|
39
|
-
priority
|
|
40
|
-
weight
|
|
41
|
-
target
|
|
42
|
-
ttl
|
|
36
|
+
type: 'URI',
|
|
37
|
+
owner: this.fullyQualify(fqdn),
|
|
38
|
+
priority: TINYDNS.octalToUInt16(rdata.substring(0, 8)),
|
|
39
|
+
weight: TINYDNS.octalToUInt16(rdata.substring(8, 16)),
|
|
40
|
+
target: TINYDNS.octalToChar(rdata.substring(16)),
|
|
41
|
+
ttl: parseInt(ttl, 10),
|
|
43
42
|
timestamp: ts,
|
|
44
|
-
location
|
|
43
|
+
location: loc !== '' && loc !== '\n' ? loc : '',
|
|
45
44
|
})
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
fromBind
|
|
47
|
+
fromBind(opts) {
|
|
49
48
|
// test.example.com 3600 IN URI priority, weight, target
|
|
50
|
-
const [
|
|
49
|
+
const [owner, ttl, c, type, priority, weight, target] =
|
|
50
|
+
opts.bindline.split(/\s+/)
|
|
51
51
|
return new URI({
|
|
52
|
-
class
|
|
53
|
-
type
|
|
52
|
+
class: c,
|
|
53
|
+
type: type,
|
|
54
54
|
owner,
|
|
55
55
|
priority: parseInt(priority, 10),
|
|
56
|
-
weight
|
|
57
|
-
target
|
|
58
|
-
ttl
|
|
56
|
+
weight: parseInt(weight, 10),
|
|
57
|
+
target: target.replace(/^"|"$/g, ''),
|
|
58
|
+
ttl: parseInt(ttl, 10),
|
|
59
59
|
})
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/****** MISC *******/
|
|
63
|
-
getDescription
|
|
63
|
+
getDescription() {
|
|
64
64
|
return 'URI'
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
getRdataFields
|
|
68
|
-
return [
|
|
67
|
+
getRdataFields(arg) {
|
|
68
|
+
return ['priority', 'weight', 'target']
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
getRFCs
|
|
72
|
-
return [
|
|
71
|
+
getRFCs() {
|
|
72
|
+
return [7553]
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
getTypeId
|
|
75
|
+
getTypeId() {
|
|
76
76
|
return 256
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
getQuotedFields
|
|
80
|
-
return [
|
|
79
|
+
getQuotedFields() {
|
|
80
|
+
return ['target']
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/****** EXPORTERS *******/
|
|
84
|
-
toTinydns
|
|
84
|
+
toTinydns() {
|
|
85
85
|
const dataRe = new RegExp(/[\r\n\t:\\/]/, 'g')
|
|
86
86
|
let rdata = ''
|
|
87
87
|
|
|
88
|
-
for (const e of [
|
|
88
|
+
for (const e of ['priority', 'weight']) {
|
|
89
89
|
rdata += TINYDNS.UInt16toOctal(this.get(e))
|
|
90
90
|
}
|
|
91
91
|
|
package/rr/wks.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import RR from '../rr.js'
|
|
2
|
+
|
|
3
|
+
export default class WKS 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 'Well Known Service'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getRdataFields(arg) {
|
|
16
|
+
return ['bit map']
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getRFCs() {
|
|
20
|
+
return [883, 1035]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getTypeId() {
|
|
24
|
+
return 11
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/****** IMPORTERS *******/
|
|
28
|
+
|
|
29
|
+
fromBind(opts) {
|
|
30
|
+
// test.example.com 3600 IN WKS 192.168.1.1 TCP 25
|
|
31
|
+
const [owner, ttl, c, type, address, protocol, bitmap] = opts.bindline.split(/\s+/)
|
|
32
|
+
return new WKS({
|
|
33
|
+
owner,
|
|
34
|
+
ttl: parseInt(ttl, 10),
|
|
35
|
+
class: c,
|
|
36
|
+
type,
|
|
37
|
+
address, // 32-bit int
|
|
38
|
+
protocol, // 8-bit int, 6=TCP, 17=UDP
|
|
39
|
+
bitmap, // var len bit map, must be multiple of 8
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/****** EXPORTERS *******/
|
|
44
|
+
}
|