@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/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,24 @@ 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))
|
|
32
|
+
throw new Error(`SOA rname replaces @ with a . (dot), ${this.citeRFC()}`)
|
|
33
33
|
|
|
34
34
|
// RFC 4034: letters in the DNS names are lower cased
|
|
35
35
|
this.set('rname', val.toLowerCase())
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
setSerial
|
|
38
|
+
setSerial(val) {
|
|
39
39
|
this.is32bitInt('SOA', 'serial', val)
|
|
40
40
|
|
|
41
41
|
this.set('serial', val)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
setRefresh
|
|
44
|
+
setRefresh(val) {
|
|
45
45
|
// refresh (seconds after which to check with master for update)
|
|
46
46
|
// RFC 1912 suggests 20 min to 12 hours
|
|
47
47
|
// RIPE recommends 86400 (24 hours)
|
|
@@ -50,7 +50,7 @@ export default class SOA extends RR {
|
|
|
50
50
|
this.set('refresh', val)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
setRetry
|
|
53
|
+
setRetry(val) {
|
|
54
54
|
// seconds after which to retry serial # update
|
|
55
55
|
// RIPE recommends 7200 seconds (2 hours)
|
|
56
56
|
|
|
@@ -59,7 +59,7 @@ export default class SOA extends RR {
|
|
|
59
59
|
this.set('retry', val)
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
setExpire
|
|
62
|
+
setExpire(val) {
|
|
63
63
|
// seconds after which secondary should drop zone if no master response
|
|
64
64
|
// RFC 1912 suggests 2-4 weeks
|
|
65
65
|
// RIPE suggests 3600000 (1,000 hours, 6 weeks)
|
|
@@ -68,73 +68,88 @@ export default class SOA extends RR {
|
|
|
68
68
|
this.set('expire', val)
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
getDescription
|
|
71
|
+
getDescription() {
|
|
72
72
|
return 'Start Of Authority'
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
getRdataFields
|
|
76
|
-
return [
|
|
75
|
+
getRdataFields(arg) {
|
|
76
|
+
return ['mname', 'rname', 'serial', 'refresh', 'retry', 'expire', 'minimum']
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
getRFCs
|
|
80
|
-
return [
|
|
79
|
+
getRFCs() {
|
|
80
|
+
return [1035, 2308]
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
getTypeId
|
|
83
|
+
getTypeId() {
|
|
84
84
|
return 6
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/****** IMPORTERS *******/
|
|
88
|
-
fromBind
|
|
88
|
+
fromBind(opts) {
|
|
89
89
|
// example.com TTL IN SOA mname rname serial refresh retry expire minimum
|
|
90
|
-
const [
|
|
90
|
+
const [
|
|
91
|
+
owner,
|
|
92
|
+
ttl,
|
|
93
|
+
c,
|
|
94
|
+
type,
|
|
95
|
+
mname,
|
|
96
|
+
rname,
|
|
97
|
+
serial,
|
|
98
|
+
refresh,
|
|
99
|
+
retry,
|
|
100
|
+
expire,
|
|
101
|
+
minimum,
|
|
102
|
+
] = opts.bindline.split(/[\s+]/)
|
|
91
103
|
|
|
92
104
|
return new SOA({
|
|
93
105
|
owner,
|
|
94
|
-
ttl
|
|
95
|
-
class
|
|
106
|
+
ttl: parseInt(ttl) || parseInt(minimum),
|
|
107
|
+
class: c,
|
|
96
108
|
type,
|
|
97
109
|
mname,
|
|
98
110
|
rname,
|
|
99
|
-
serial
|
|
111
|
+
serial: parseInt(serial, 10),
|
|
100
112
|
refresh: parseInt(refresh, 10),
|
|
101
|
-
retry
|
|
102
|
-
expire
|
|
113
|
+
retry: parseInt(retry, 10),
|
|
114
|
+
expire: parseInt(expire, 10),
|
|
103
115
|
minimum: parseInt(minimum, 10),
|
|
104
116
|
})
|
|
105
117
|
}
|
|
106
118
|
|
|
107
|
-
fromTinydns
|
|
119
|
+
fromTinydns(opts) {
|
|
108
120
|
// Zfqdn:mname:rname:ser:ref:ret:exp:min:ttl:time:lo
|
|
109
|
-
const [
|
|
121
|
+
const [fqdn, mname, rname, ser, ref, ret, exp, min, ttl, ts, loc] =
|
|
122
|
+
opts.tinyline.substring(1).split(':')
|
|
110
123
|
|
|
111
124
|
return new SOA({
|
|
112
|
-
owner
|
|
113
|
-
ttl
|
|
114
|
-
type
|
|
115
|
-
mname
|
|
116
|
-
rname
|
|
117
|
-
serial
|
|
118
|
-
refresh
|
|
119
|
-
retry
|
|
120
|
-
expire
|
|
121
|
-
minimum
|
|
125
|
+
owner: this.fullyQualify(fqdn),
|
|
126
|
+
ttl: parseInt(ttl, 10),
|
|
127
|
+
type: 'SOA',
|
|
128
|
+
mname: this.fullyQualify(mname),
|
|
129
|
+
rname: this.fullyQualify(rname),
|
|
130
|
+
serial: parseInt(ser || opts.default?.serial, 10),
|
|
131
|
+
refresh: parseInt(ref, 10) || 16384,
|
|
132
|
+
retry: parseInt(ret, 10) || 2048,
|
|
133
|
+
expire: parseInt(exp, 10) || 1048576,
|
|
134
|
+
minimum: parseInt(min, 10) || 2560,
|
|
122
135
|
timestamp: parseInt(ts) || '',
|
|
123
|
-
location
|
|
136
|
+
location: loc !== '' && loc !== '\n' ? loc : '',
|
|
124
137
|
})
|
|
125
138
|
}
|
|
126
139
|
|
|
127
140
|
/****** 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)
|
|
141
|
+
toBind(zone_opts) {
|
|
142
|
+
const numFields = ['serial', 'refresh', 'retry', 'expire', 'minimum']
|
|
143
|
+
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
144
|
}
|
|
132
145
|
|
|
133
|
-
toMaraDNS
|
|
134
|
-
return `${this.get('owner')}\t SOA\t${this.getRdataFields()
|
|
146
|
+
toMaraDNS() {
|
|
147
|
+
return `${this.get('owner')}\t SOA\t${this.getRdataFields()
|
|
148
|
+
.map((f) => this.getQuoted(f))
|
|
149
|
+
.join('\t')} ~\n`
|
|
135
150
|
}
|
|
136
151
|
|
|
137
|
-
toTinydns
|
|
152
|
+
toTinydns() {
|
|
138
153
|
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
154
|
}
|
|
140
155
|
}
|
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 [
|
|
36
|
+
const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
|
|
37
37
|
if (n != 99) throw new Error('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
|
}
|
package/rr/srv.js
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
|
|
2
1
|
import net from '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
|
|
30
|
+
setTarget(val) {
|
|
32
31
|
if (!val) throw new Error(`SRV: target is required, ${this.citeRFC()}`)
|
|
33
32
|
|
|
34
33
|
if (net.isIPv4(val) || net.isIPv6(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
|
-
[
|
|
71
|
+
;[fqdn, n, rdata, ttl, ts, loc] = str.substring(1).split(':')
|
|
72
72
|
if (n != 33) throw new Error('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 [
|
|
47
|
+
const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
|
|
49
48
|
if (n != 44) throw new Error('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
|
}
|