@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.
Files changed (75) hide show
  1. package/CHANGELOG.md +26 -43
  2. package/README.md +48 -48
  3. package/index.js +83 -29
  4. package/lib/tinydns.js +68 -61
  5. package/package.json +1 -2
  6. package/rr/a.js +32 -23
  7. package/rr/aaaa.js +49 -35
  8. package/rr/caa.js +56 -44
  9. package/rr/cert.js +21 -19
  10. package/rr/cname.js +22 -23
  11. package/rr/dname.js +23 -23
  12. package/rr/dnskey.js +45 -43
  13. package/rr/ds.js +40 -40
  14. package/rr/hinfo.js +29 -28
  15. package/rr/https.js +62 -0
  16. package/rr/ipseckey.js +69 -50
  17. package/rr/key.js +23 -23
  18. package/rr/loc.js +71 -58
  19. package/rr/mx.js +41 -27
  20. package/rr/naptr.js +52 -53
  21. package/rr/ns.js +26 -23
  22. package/rr/nsec.js +24 -20
  23. package/rr/nsec3.js +59 -46
  24. package/rr/nsec3param.js +24 -26
  25. package/rr/nxt.js +65 -0
  26. package/rr/openpgpkey.js +18 -15
  27. package/rr/ptr.js +20 -21
  28. package/rr/rrsig.js +28 -23
  29. package/rr/sig.js +25 -20
  30. package/rr/smimea.js +36 -31
  31. package/rr/soa.js +56 -42
  32. package/rr/spf.js +21 -18
  33. package/rr/srv.js +45 -45
  34. package/rr/sshfp.js +30 -31
  35. package/rr/svcb.js +64 -0
  36. package/rr/tlsa.js +50 -45
  37. package/rr/tsig.js +56 -0
  38. package/rr/txt.js +42 -35
  39. package/rr/uri.js +33 -33
  40. package/rr/wks.js +45 -0
  41. package/rr.js +133 -87
  42. package/.codeclimate.yml +0 -25
  43. package/DEVELOP.md +0 -23
  44. package/test/a.js +0 -76
  45. package/test/aaaa.js +0 -79
  46. package/test/base.js +0 -138
  47. package/test/caa.js +0 -104
  48. package/test/cert.js +0 -48
  49. package/test/cname.js +0 -41
  50. package/test/dname.js +0 -53
  51. package/test/dnskey.js +0 -44
  52. package/test/ds.js +0 -44
  53. package/test/fake.js +0 -26
  54. package/test/hinfo.js +0 -75
  55. package/test/ipseckey.js +0 -115
  56. package/test/key.js +0 -37
  57. package/test/loc.js +0 -71
  58. package/test/mx.js +0 -75
  59. package/test/naptr.js +0 -40
  60. package/test/ns.js +0 -53
  61. package/test/nsec.js +0 -38
  62. package/test/nsec3.js +0 -40
  63. package/test/nsec3param.js +0 -26
  64. package/test/openpgpkey.js +0 -35
  65. package/test/ptr.js +0 -54
  66. package/test/rr.js +0 -196
  67. package/test/smimea.js +0 -45
  68. package/test/soa.js +0 -77
  69. package/test/spf.js +0 -48
  70. package/test/srv.js +0 -81
  71. package/test/sshfp.js +0 -62
  72. package/test/tinydns.js +0 -140
  73. package/test/tlsa.js +0 -54
  74. package/test/txt.js +0 -70
  75. package/test/uri.js +0 -61
package/rr/ds.js CHANGED
@@ -1,104 +1,104 @@
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 DS extends RR {
7
- constructor (opts) {
6
+ constructor(opts) {
8
7
  super(opts)
9
8
  }
10
9
 
11
10
  /****** Resource record specific setters *******/
12
- setKeyTag (val) {
11
+ setKeyTag(val) {
13
12
  // a 2 octet Key Tag field...in network byte order
14
- if (!val) throw new Error(`DS: key tag is required`)
15
- if (val.length > 2) throw new Error(`DS: key tag is too long, ${this.citeRFC()}`)
13
+ if (!val) this.throwHelp(`DS: key tag is required`)
14
+ if (val.length > 2) this.throwHelp(`DS: key tag is too long`)
16
15
 
17
16
  this.set('key tag', val)
18
17
  }
19
18
 
20
- setAlgorithm (val) {
19
+ setAlgorithm(val) {
21
20
  // 1=RSA/MD5, 2=DH, 3=DSA/SHA-1, 4=EC, 5=RSA/SHA-1
22
- if (![ 1,2,3,4,5,253,254 ].includes(val))
23
- throw new Error(`DS: algorithm invalid, ${this.citeRFC()}`)
21
+ if (![1, 2, 3, 4, 5, 253, 254].includes(val))
22
+ this.throwHelp(`DS: algorithm invalid`)
24
23
 
25
24
  this.set('algorithm', val)
26
25
  }
27
26
 
28
- setDigestType (val) {
29
- if (![ 1,2 ].includes(val)) throw new Error(`DS: digest type invalid, ${this.citeRFC()}`)
27
+ setDigestType(val) {
28
+ if (![1, 2].includes(val)) this.throwHelp(`DS: digest type invalid`)
30
29
 
31
30
  this.set('digest type', val)
32
31
  }
33
32
 
34
- setDigest (val) {
35
- if (!val) throw new Error(`DS: digest is required, ${this.citeRFC()}`)
33
+ setDigest(val) {
34
+ if (!val) this.throwHelp(`DS: digest is required`)
36
35
 
37
36
  this.set('digest', val)
38
37
  }
39
38
 
40
- getDescription () {
39
+ getDescription() {
41
40
  return 'Delegation Signer'
42
41
  }
43
42
 
44
- getRdataFields (arg) {
45
- return [ 'key tag', 'algorithm', 'digest type', 'digest' ]
43
+ getRdataFields(arg) {
44
+ return ['key tag', 'algorithm', 'digest type', 'digest']
46
45
  }
47
46
 
48
- getRFCs () {
49
- return [ 4034, 4509 ]
47
+ getRFCs() {
48
+ return [4034, 4509]
50
49
  }
51
50
 
52
- getTypeId () {
51
+ getTypeId() {
53
52
  return 43
54
53
  }
55
54
 
56
55
  /****** IMPORTERS *******/
57
56
 
58
- fromBind (opts) {
57
+ fromBind(opts) {
59
58
  // test.example.com 3600 IN DS Key Tag Algorithm, Digest Type, Digest
60
- const [ owner, ttl, c, type, keytag, algorithm, digesttype ] = opts.bindline.split(/\s+/)
59
+ const [owner, ttl, c, type, keytag, algorithm, digesttype] =
60
+ opts.bindline.split(/\s+/)
61
61
  return new DS({
62
62
  owner,
63
- ttl : parseInt(ttl, 10),
64
- class : c,
63
+ ttl: parseInt(ttl, 10),
64
+ class: c,
65
65
  type,
66
- 'key tag' : parseInt(keytag, 10),
67
- algorithm : parseInt(algorithm, 10),
66
+ 'key tag': parseInt(keytag, 10),
67
+ algorithm: parseInt(algorithm, 10),
68
68
  'digest type': parseInt(digesttype, 10),
69
- digest : opts.bindline.split(/\s+/).slice(7).join(' ').trim(),
69
+ digest: opts.bindline.split(/\s+/).slice(7).join(' ').trim(),
70
70
  })
71
71
  }
72
72
 
73
- fromTinydns (opts) {
74
- const [ fqdn, n, rdata, ttl, ts, loc ] = opts.tinyline.substring(1).split(':')
75
- if (n != 43) throw new Error('DS fromTinydns, invalid n')
73
+ fromTinydns(opts) {
74
+ const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
75
+ if (n != 43) this.throwHelp('DS fromTinydns, invalid n')
76
76
 
77
77
  const binRdata = Buffer.from(TINYDNS.octalToChar(rdata), 'binary')
78
78
 
79
79
  return new DS({
80
- owner : this.fullyQualify(fqdn),
81
- ttl : parseInt(ttl, 10),
82
- type : 'DS',
83
- 'key tag' : binRdata.readUInt16BE(0),
84
- algorithm : binRdata.readUInt8(2),
80
+ owner: this.fullyQualify(fqdn),
81
+ ttl: parseInt(ttl, 10),
82
+ type: 'DS',
83
+ 'key tag': binRdata.readUInt16BE(0),
84
+ algorithm: binRdata.readUInt8(2),
85
85
  'digest type': binRdata.readUInt8(3),
86
- digest : binRdata.slice(4).toString(),
87
- timestamp : ts,
88
- location : loc !== '' && loc !== '\n' ? loc : '',
86
+ digest: binRdata.slice(4).toString(),
87
+ timestamp: ts,
88
+ location: loc !== '' && loc !== '\n' ? loc : '',
89
89
  })
90
90
  }
91
91
 
92
92
  /****** EXPORTERS *******/
93
93
 
94
- toTinydns () {
94
+ toTinydns() {
95
95
  const rdataRe = new RegExp(/[\r\n\t:\\/]/, 'g')
96
96
 
97
97
  return this.getTinydnsGeneric(
98
98
  TINYDNS.UInt16toOctal(this.get('key tag')) +
99
- TINYDNS.UInt8toOctal(this.get('algorithm')) +
100
- TINYDNS.UInt8toOctal(this.get('digest type')) +
101
- TINYDNS.escapeOctal(rdataRe, this.get('digest'))
99
+ TINYDNS.UInt8toOctal(this.get('algorithm')) +
100
+ TINYDNS.UInt8toOctal(this.get('digest type')) +
101
+ TINYDNS.escapeOctal(rdataRe, this.get('digest')),
102
102
  )
103
103
  }
104
104
  }
package/rr/hinfo.js CHANGED
@@ -1,54 +1,55 @@
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 HINFO extends RR {
7
- constructor (opts) {
6
+ constructor(opts) {
8
7
  super(opts)
9
8
  }
10
9
 
11
10
  /****** Resource record specific setters *******/
12
- setCpu (val) {
13
- if (val.length > 255) throw new Error('HINFO cpu cannot exceed 255 chars')
11
+ setCpu(val) {
12
+ if (val.length > 255) this.throwHelp('HINFO cpu cannot exceed 255 chars')
14
13
  this.set('cpu', val.replace(/^["']|["']$/g, ''))
15
14
  }
16
15
 
17
- setOs (val) {
18
- if (val.length > 255) throw new Error('HINFO os cannot exceed 255 chars')
16
+ setOs(val) {
17
+ if (val.length > 255) this.throwHelp('HINFO os cannot exceed 255 chars')
19
18
  this.set('os', val.replace(/^["']|["']$/g, ''))
20
19
  }
21
20
 
22
- getDescription () {
21
+ getDescription() {
23
22
  return 'Host Info'
24
23
  }
25
24
 
26
- getRdataFields (arg) {
27
- return [ 'cpu', 'os' ]
25
+ getRdataFields(arg) {
26
+ return ['cpu', 'os']
28
27
  }
29
28
 
30
- getRFCs () {
31
- return [ 1034, 1035, 8482 ]
29
+ getRFCs() {
30
+ return [1034, 1035, 8482]
32
31
  }
33
32
 
34
- getTypeId () {
33
+ getTypeId() {
35
34
  return 13
36
35
  }
37
36
 
38
- getQuotedFields () {
39
- return [ 'cpu', 'os' ]
37
+ getQuotedFields() {
38
+ return ['cpu', 'os']
40
39
  }
41
40
 
42
41
  /****** IMPORTERS *******/
43
- fromBind (opts) {
42
+ fromBind(opts) {
44
43
  // test.example.com 3600 IN HINFO DEC-2060 TOPS20
45
- const match = opts.bindline.match(/([^\s]+)\s+([0-9]+)\s+(IN)\s+(HINFO)\s+("[^"]+"|[^\s]+)\s+("[^"]+"|[^\s]+)/i)
46
- if (!match) throw new Error(`unable to parse HINFO: ${opts.bindline}`)
47
- const [ owner, ttl, c, type, cpu, os ] = match.slice(1)
44
+ const match = opts.bindline.match(
45
+ /([^\s]+)\s+([0-9]+)\s+(IN)\s+(HINFO)\s+("[^"]+"|[^\s]+)\s+("[^"]+"|[^\s]+)/i,
46
+ )
47
+ if (!match) this.throwHelp(`unable to parse HINFO: ${opts.bindline}`)
48
+ const [owner, ttl, c, type, cpu, os] = match.slice(1)
48
49
 
49
50
  return new HINFO({
50
51
  owner,
51
- ttl : parseInt(ttl, 10),
52
+ ttl: parseInt(ttl, 10),
52
53
  class: c,
53
54
  type,
54
55
  cpu,
@@ -56,29 +57,29 @@ export default class HINFO extends RR {
56
57
  })
57
58
  }
58
59
 
59
- fromTinydns (opts) {
60
+ fromTinydns(opts) {
60
61
  // HINFO via generic, :fqdn:n:rdata:ttl:timestamp:lo
61
- const [ fqdn, , rdata, ttl, ts, loc ] = opts.tinyline.substring(1).split(':')
62
- const [ cpu, os ] = [ ...TINYDNS.unpackString(rdata) ]
62
+ const [fqdn, , rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
63
+ const [cpu, os] = [...TINYDNS.unpackString(rdata)]
63
64
 
64
65
  return new this.constructor({
65
- owner : this.fullyQualify(fqdn),
66
- ttl : parseInt(ttl, 10),
67
- type : 'HINFO',
66
+ owner: this.fullyQualify(fqdn),
67
+ ttl: parseInt(ttl, 10),
68
+ type: 'HINFO',
68
69
  cpu,
69
70
  os,
70
71
  timestamp: ts,
71
- location : loc !== '' && loc !== '\n' ? loc : '',
72
+ location: loc !== '' && loc !== '\n' ? loc : '',
72
73
  })
73
74
  }
74
75
 
75
76
  /****** EXPORTERS *******/
76
- toTinydns () {
77
+ toTinydns() {
77
78
  return this.getTinydnsGeneric(
78
79
  [
79
80
  TINYDNS.packString(this.get('cpu')),
80
81
  TINYDNS.packString(this.get('os')),
81
- ].join('')
82
+ ].join(''),
82
83
  )
83
84
  }
84
85
  }
package/rr/https.js ADDED
@@ -0,0 +1,62 @@
1
+ import RR from '../rr.js'
2
+
3
+ export default class HTTPS extends RR {
4
+ constructor(opts) {
5
+ super(opts)
6
+ }
7
+
8
+ /****** Resource record specific setters *******/
9
+ setPriority(val) {
10
+ this.is16bitInt('HTTPS', 'priority', val)
11
+
12
+ this.set('priority', val)
13
+ }
14
+
15
+ setTargetName(val) {
16
+ // this.isFullyQualified('HTTPS', 'target name', val)
17
+ // this.isValidHostname('HTTPS', '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) this.throwHelp(`HTTPS: params is required`)
25
+
26
+ this.set('params', val)
27
+ }
28
+
29
+ getDescription() {
30
+ return 'HTTP Semantics'
31
+ }
32
+
33
+ getRdataFields(arg) {
34
+ return ['priority', 'target name', 'params']
35
+ }
36
+
37
+ getRFCs() {
38
+ return [9460]
39
+ }
40
+
41
+ getTypeId() {
42
+ return 65
43
+ }
44
+
45
+ /****** IMPORTERS *******/
46
+
47
+ fromBind(opts) {
48
+ // test.example.com 3600 IN HTTPS Priority TargetName Params
49
+ const [owner, ttl, c, type, pri, fqdn] = opts.bindline.split(/\s+/)
50
+ return new HTTPS({
51
+ owner,
52
+ ttl: parseInt(ttl, 10),
53
+ class: c,
54
+ type,
55
+ priority: parseInt(pri, 10),
56
+ 'target name': fqdn,
57
+ params: opts.bindline.split(/\s+/).slice(6).join(' ').trim(),
58
+ })
59
+ }
60
+
61
+ /****** EXPORTERS *******/
62
+ }
package/rr/ipseckey.js CHANGED
@@ -1,135 +1,154 @@
1
-
2
- import net from 'net'
1
+ import net from 'node:net'
3
2
 
4
3
  import RR from '../rr.js'
5
4
 
6
5
  import * as TINYDNS from '../lib/tinydns.js'
7
6
 
8
7
  export default class IPSECKEY extends RR {
9
- constructor (opts) {
8
+ constructor(opts) {
10
9
  super(opts)
11
10
  }
12
11
 
13
12
  /****** Resource record specific setters *******/
14
- setPrecedence (val) {
13
+ setPrecedence(val) {
15
14
  // an 8-bit precedence for this record.
16
15
  this.is8bitInt('IPSECKEY', 'precedence', val)
17
16
 
18
17
  this.set('precedence', val)
19
18
  }
20
19
 
21
- setGatewayType (val) {
20
+ setGatewayType(val) {
22
21
  // 0 (none), 1 (4-byte IPv4), 2 (16-byte IPv6), 3 (wire encoded domain name)
23
- if (![ 0,1,2,3 ].includes(val))
24
- throw new Error(`IPSECKEY: Gateway Type is invalid, ${this.citeRFC()}`)
22
+ if (![0, 1, 2, 3].includes(val))
23
+ this.throwHelp(`IPSECKEY: Gateway Type is invalid`)
25
24
 
26
25
  this.set('gateway type', val)
27
26
  }
28
27
 
29
- setAlgorithm (val) {
28
+ setAlgorithm(val) {
30
29
  // unsigned int, 1 octet, values: 1=DSA, 2=RSA
31
- if (![ 1,2 ].includes(val))
32
- throw new Error(`IPSECKEY: Algorithm invalid, ${this.citeRFC()}`)
30
+ if (![1, 2].includes(val)) this.throwHelp(`IPSECKEY: Algorithm invalid`)
33
31
 
34
32
  this.set('algorithm', val)
35
33
  }
36
34
 
37
- setGateway (val) {
38
- const gwErr = new Error(`IPSECKEY: gateway invalid (${val}), ${this.citeRFC()}`)
35
+ setGateway(val) {
36
+ const gwErr = new Error(`IPSECKEY: gateway invalid (${val})`)
39
37
  switch (this.get('gateway type')) {
40
- case 0: if (val !== '.') throw gwErr; break
41
- case 1: if (!net.isIPv4(val)) throw gwErr; break
42
- case 2: if (!net.isIPv6(val)) throw gwErr; break
38
+ case 0:
39
+ if (val !== '.') throw gwErr
40
+ break
41
+ case 1:
42
+ if (!net.isIPv4(val)) throw gwErr
43
+ break
44
+ case 2:
45
+ if (!net.isIPv6(val)) throw gwErr
46
+ break
43
47
  }
44
48
 
45
49
  this.set('gateway', val)
46
50
  }
47
51
 
48
- setPublickey (val) {
49
- // if (val) throw new Error(`IPSECKEY: publickey is optional, ${this.citeRFC()}`)
52
+ setPublickey(val) {
53
+ // if (val) this.throwHelp(`IPSECKEY: publickey is optional`)
50
54
 
51
55
  this.set('publickey', val)
52
56
  }
53
57
 
54
- getDescription () {
58
+ getDescription() {
55
59
  return 'IPsec Keying'
56
60
  }
57
61
 
58
- getRdataFields (arg) {
59
- return [ 'precedence', 'gateway type', 'algorithm', 'gateway', 'publickey' ]
62
+ getRdataFields(arg) {
63
+ return ['precedence', 'gateway type', 'algorithm', 'gateway', 'publickey']
60
64
  }
61
65
 
62
- getRFCs () {
63
- return [ 4025 ]
66
+ getRFCs() {
67
+ return [4025]
64
68
  }
65
69
 
66
- getTypeId () {
70
+ getTypeId() {
67
71
  return 45
68
72
  }
69
73
 
74
+ getCanonical() {
75
+ return {
76
+ owner: '38.2.0.192.in-addr.arpa.',
77
+ ttl: 7200,
78
+ class: 'IN',
79
+ type: 'IPSECKEY',
80
+ precedence: 10,
81
+ 'gateway type': 1,
82
+ algorithm: 2,
83
+ gateway: '192.0.2.38',
84
+ publickey: 'AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ==',
85
+ }
86
+ }
87
+
70
88
  /****** IMPORTERS *******/
71
- fromBind (opts) {
89
+ fromBind(opts) {
72
90
  // FQDN TTL CLASS IPSECKEY Precedence GatewayType Algorithm Gateway PublicKey
73
- const [ owner, ttl, c, type, prec, gwt, algo, gateway, publickey ] = opts.bindline.split(/\s+/)
91
+ const [owner, ttl, c, type, prec, gwt, algo, gateway, publickey] =
92
+ opts.bindline.split(/\s+/)
74
93
  return new IPSECKEY({
75
94
  owner,
76
- ttl : parseInt(ttl, 10),
77
- class : c,
95
+ ttl: parseInt(ttl, 10),
96
+ class: c,
78
97
  type,
79
- precedence : parseInt(prec, 10),
80
- 'gateway type': parseInt(gwt, 10),
81
- algorithm : parseInt(algo, 10),
98
+ precedence: parseInt(prec, 10),
99
+ 'gateway type': parseInt(gwt, 10),
100
+ algorithm: parseInt(algo, 10),
82
101
  gateway,
83
102
  publickey,
84
103
  })
85
104
  }
86
105
 
87
- fromTinydns (opts) {
88
- const [ fqdn, n, rdata, ttl, ts, loc ] = opts.tinyline.substring(1).split(':')
89
- if (n != 45) throw new Error('IPSECKEY fromTinydns, invalid n')
106
+ fromTinydns(opts) {
107
+ const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
108
+ if (n != 45) this.throwHelp('IPSECKEY fromTinydns, invalid n')
90
109
 
91
110
  const precedence = TINYDNS.octalToUInt8(rdata.substring(0, 4))
92
- const gwType = TINYDNS.octalToUInt8(rdata.substring(4, 8))
93
- const algorithm = TINYDNS.octalToUInt8(rdata.substring(8, 12))
111
+ const gwType = TINYDNS.octalToUInt8(rdata.substring(4, 8))
112
+ const algorithm = TINYDNS.octalToUInt8(rdata.substring(8, 12))
94
113
 
95
114
  let len, gateway, octalKey
96
115
 
97
116
  switch (gwType) {
98
- case 0: // no gateway
99
- gateway = rdata.substring(12, 13) // should always be: '.'
117
+ case 0: // no gateway
118
+ gateway = rdata.substring(12, 13) // should always be: '.'
100
119
  octalKey = rdata.substring(13)
101
120
  break
102
- case 1: // 4-byte IPv4 address
103
- gateway = TINYDNS.octalToIPv4(rdata.substring(12, 28))
121
+ case 1: // 4-byte IPv4 address
122
+ gateway = TINYDNS.octalToIPv4(rdata.substring(12, 28))
104
123
  octalKey = rdata.substring(28)
105
124
  break
106
- case 2: // 16-byte IPv6
107
- gateway = TINYDNS.octalToHex(rdata.substring(12, 76))
125
+ case 2: // 16-byte IPv6
126
+ gateway = TINYDNS.octalToHex(rdata.substring(12, 76))
108
127
  octalKey = rdata.substring(76)
109
128
  break
110
- case 3: // wire encoded domain name
111
- [ gateway, len ] = TINYDNS.unpackDomainName(rdata.substring(12))
129
+ case 3: // wire encoded domain name
130
+ ;[gateway, len] = TINYDNS.unpackDomainName(rdata.substring(12))
112
131
  octalKey = rdata.substring(12 + len)
113
132
  break
114
133
  }
115
134
 
116
135
  return new IPSECKEY({
117
- owner : this.fullyQualify(fqdn),
118
- ttl : parseInt(ttl, 10),
119
- type : 'IPSECKEY',
136
+ owner: this.fullyQualify(fqdn),
137
+ ttl: parseInt(ttl, 10),
138
+ type: 'IPSECKEY',
120
139
  precedence,
121
140
  'gateway type': gwType,
122
141
  algorithm,
123
142
  gateway,
124
- publickey : TINYDNS.octalToBase64(octalKey),
125
- timestamp : ts,
126
- location : loc !== '' && loc !== '\n' ? loc : '',
143
+ publickey: TINYDNS.octalToBase64(octalKey),
144
+ timestamp: ts,
145
+ location: loc !== '' && loc !== '\n' ? loc : '',
127
146
  })
128
147
  }
129
148
 
130
149
  /****** EXPORTERS *******/
131
150
 
132
- toTinydns () {
151
+ toTinydns() {
133
152
  const rdataRe = new RegExp(/[\r\n\t:\\/]/, 'g')
134
153
 
135
154
  let rdata = ''
package/rr/key.js CHANGED
@@ -1,70 +1,70 @@
1
-
2
1
  import RR from '../rr.js'
3
2
 
4
3
  export default class KEY extends RR {
5
- constructor (opts) {
4
+ constructor(opts) {
6
5
  super(opts)
7
6
  }
8
7
 
9
8
  /****** Resource record specific setters *******/
10
- setFlags (val) {
9
+ setFlags(val) {
11
10
  // a 2 octet Flags Field
12
11
  this.is16bitInt('KEY', 'flags', val)
13
12
 
14
13
  this.set('flags', val)
15
14
  }
16
15
 
17
- setProtocol (val) {
16
+ setProtocol(val) {
18
17
  // 1 octet
19
18
  this.is8bitInt('KEY', 'protocol', val)
20
19
 
21
20
  this.set('protocol', val)
22
21
  }
23
22
 
24
- setAlgorithm (val) {
23
+ setAlgorithm(val) {
25
24
  // 1 octet
26
25
  // 1=RSA/MD5, 2=DH, 3=DSA/SHA-1, 4=EC, 5=RSA/SHA-1
27
- if (![ 1,2,3,4,5,253,254 ].includes(val))
28
- throw new Error(`KEY: algorithm invalid, ${this.citeRFC()}`)
26
+ if (![1, 2, 3, 4, 5, 253, 254].includes(val))
27
+ this.throwHelp(`KEY: algorithm invalid`)
29
28
 
30
29
  this.set('algorithm', val)
31
30
  }
32
31
 
33
- setPublickey (val) {
34
- if (!val) throw new Error(`KEY: publickey is required, ${this.citeRFC()}`)
32
+ setPublickey(val) {
33
+ if (!val) this.throwHelp(`KEY: publickey is required`)
35
34
 
36
35
  this.set('publickey', val)
37
36
  }
38
37
 
39
- getDescription () {
38
+ getDescription() {
40
39
  return 'DNS Public Key'
41
40
  }
42
41
 
43
- getRdataFields (arg) {
44
- return [ 'flags', 'protocol', 'algorithm', 'publickey' ]
42
+ getRdataFields(arg) {
43
+ return ['flags', 'protocol', 'algorithm', 'publickey']
45
44
  }
46
45
 
47
- getRFCs () {
48
- return [ 2535, 3445 ]
46
+ getRFCs() {
47
+ return [2535, 3445]
49
48
  }
50
49
 
51
- getTypeId () {
50
+ getTypeId() {
52
51
  return 25
53
52
  }
54
53
 
55
54
  /****** IMPORTERS *******/
56
55
 
57
- fromBind (opts) {
56
+ fromBind(opts) {
58
57
  // test.example.com 3600 IN KEY Flags Protocol Algorithm PublicKey
59
- const [ owner, ttl, c, type, flags, protocol, algorithm ] = opts.bindline.split(/\s+/)
58
+ const [owner, ttl, c, type, flags, protocol, algorithm] =
59
+ opts.bindline.split(/\s+/)
60
60
  return new KEY({
61
61
  owner,
62
- ttl : parseInt(ttl, 10),
63
- class : c,
64
- type : type,
65
- flags : parseInt(flags, 10),
66
- protocol : parseInt(protocol, 10),
67
- algorithm: parseInt(algorithm, 10),
62
+ ttl: parseInt(ttl, 10),
63
+ class: c,
64
+ type: type,
65
+ flags: parseInt(flags, 10),
66
+ protocol: parseInt(protocol, 10),
67
+ algorithm: parseInt(algorithm, 10),
68
68
  publickey: opts.bindline.split(/\s+/).slice(7).join(' ').trim(),
69
69
  })
70
70
  }