@nictool/dns-resource-record 1.2.4 → 1.3.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/rr/hip.js ADDED
@@ -0,0 +1,102 @@
1
+ import RR from '../rr.js'
2
+
3
+ import * as TINYDNS from '../lib/tinydns.js'
4
+
5
+ export default class HIP extends RR {
6
+ constructor(opts) {
7
+ super(opts)
8
+ }
9
+
10
+ /****** Resource record specific setters *******/
11
+ setPkAlgorithm(val) {
12
+ if (val === undefined) this.throwHelp('HIP: pk algorithm is required')
13
+ this.is8bitInt('HIP', 'pk algorithm', val)
14
+ this.set('pk algorithm', val)
15
+ }
16
+
17
+ setHit(val) {
18
+ if (!val) this.throwHelp('HIP: hit is required')
19
+ this.set('hit', val)
20
+ }
21
+
22
+ setPublicKey(val) {
23
+ if (!val) this.throwHelp('HIP: public key is required')
24
+ this.set('public key', val)
25
+ }
26
+
27
+ setRendezvousServers(val) {
28
+ this.set('rendezvous servers', val ?? '')
29
+ }
30
+
31
+ getDescription() {
32
+ return 'Host Identity Protocol'
33
+ }
34
+
35
+ getRdataFields(arg) {
36
+ return ['pk algorithm', 'hit', 'public key', 'rendezvous servers']
37
+ }
38
+
39
+ getRFCs() {
40
+ return [8005]
41
+ }
42
+
43
+ getTypeId() {
44
+ return 55
45
+ }
46
+
47
+ getCanonical() {
48
+ return {
49
+ owner: 'example.com.',
50
+ ttl: 3600,
51
+ class: 'IN',
52
+ type: 'HIP',
53
+ 'pk algorithm': 2,
54
+ hit: '200100107B1A74DF365639CC39F1D578',
55
+ 'public key':
56
+ 'AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwIXAqcOTiW7iHnQt5hwVAAAAA==',
57
+ 'rendezvous servers': '',
58
+ }
59
+ }
60
+
61
+ /****** IMPORTERS *******/
62
+ fromBind(opts) {
63
+ // owner ttl IN HIP pk-algorithm HIT public-key [rendezvous-server...]
64
+ const parts = opts.bindline.split(/\s+/)
65
+ const [owner, ttl, c, type, pkAlgorithm, hit, publicKey] = parts
66
+ return new HIP({
67
+ owner,
68
+ ttl: parseInt(ttl, 10),
69
+ class: c,
70
+ type,
71
+ 'pk algorithm': parseInt(pkAlgorithm, 10),
72
+ hit,
73
+ 'public key': publicKey,
74
+ 'rendezvous servers': parts.slice(7).join(' ').trim(),
75
+ })
76
+ }
77
+
78
+ /****** EXPORTERS *******/
79
+ toBind(zone_opts) {
80
+ const rs = this.get('rendezvous servers')
81
+ const rsPart = rs ? `\t${rs}` : ''
82
+ return `${this.getPrefix(zone_opts)}\t${this.get('pk algorithm')}\t${this.get('hit')}\t${this.get('public key')}${rsPart}\n`
83
+ }
84
+
85
+ toTinydns() {
86
+ const hitBytes = Buffer.from(this.get('hit'), 'hex')
87
+ const pkBytes = Buffer.from(this.get('public key'), 'base64')
88
+ const rs = this.get('rendezvous servers')
89
+
90
+ let rdata = ''
91
+ rdata += TINYDNS.UInt8toOctal(hitBytes.length)
92
+ rdata += TINYDNS.UInt8toOctal(this.get('pk algorithm'))
93
+ rdata += TINYDNS.UInt16toOctal(pkBytes.length)
94
+ for (const b of hitBytes) rdata += TINYDNS.UInt8toOctal(b)
95
+ for (const b of pkBytes) rdata += TINYDNS.UInt8toOctal(b)
96
+ if (rs) {
97
+ for (const name of rs.split(/\s+/)) rdata += TINYDNS.packDomainName(name)
98
+ }
99
+
100
+ return this.getTinydnsGeneric(rdata)
101
+ }
102
+ }
package/rr/https.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import RR from '../rr.js'
2
2
 
3
+ import * as TINYDNS from '../lib/tinydns.js'
4
+
3
5
  export default class HTTPS extends RR {
4
6
  constructor(opts) {
5
7
  super(opts)
@@ -59,4 +61,14 @@ export default class HTTPS extends RR {
59
61
  }
60
62
 
61
63
  /****** EXPORTERS *******/
64
+
65
+ toTinydns() {
66
+ const dataRe = new RegExp(/[\r\n\t:\\/]/, 'g')
67
+
68
+ return this.getTinydnsGeneric(
69
+ TINYDNS.UInt16toOctal(this.get('priority')) +
70
+ TINYDNS.packDomainName(this.get('target name')) +
71
+ TINYDNS.escapeOctal(dataRe, this.get('params')),
72
+ )
73
+ }
62
74
  }
package/rr/ipseckey.js CHANGED
@@ -16,8 +16,7 @@ export default class IPSECKEY extends RR {
16
16
  }
17
17
 
18
18
  setGatewayType(val) {
19
- if (!this.getGatewayTypeOptions().has(val))
20
- this.throwHelp(`IPSECKEY: Gateway Type is invalid`)
19
+ if (!this.getGatewayTypeOptions().has(val)) this.throwHelp(`IPSECKEY: Gateway Type is invalid`)
21
20
 
22
21
  this.set('gateway type', val)
23
22
  }
@@ -32,8 +31,7 @@ export default class IPSECKEY extends RR {
32
31
  }
33
32
 
34
33
  setAlgorithm(val) {
35
- if (!this.getAlgorithmOptions().has(val))
36
- this.throwHelp(`IPSECKEY: Algorithm invalid`)
34
+ if (!this.getAlgorithmOptions().has(val)) this.throwHelp(`IPSECKEY: Algorithm invalid`)
37
35
 
38
36
  this.set('algorithm', val)
39
37
  }
@@ -47,9 +45,7 @@ export default class IPSECKEY extends RR {
47
45
 
48
46
  setGateway(val) {
49
47
  const type = this.get('gateway type')
50
- const gwErr = new Error(
51
- `IPSECKEY: gateway invalid (${val}) for type ${type}`,
52
- )
48
+ const gwErr = new Error(`IPSECKEY: gateway invalid (${val}) for type ${type}`)
53
49
  switch (type) {
54
50
  case 0:
55
51
  if (val !== '.') throw gwErr
@@ -104,8 +100,7 @@ export default class IPSECKEY extends RR {
104
100
  /****** IMPORTERS *******/
105
101
  fromBind(opts) {
106
102
  // FQDN TTL CLASS IPSECKEY Precedence GatewayType Algorithm Gateway PublicKey
107
- const [owner, ttl, c, type, prec, gwt, algo, gateway, publickey] =
108
- opts.bindline.split(/\s+/)
103
+ const [owner, ttl, c, type, prec, gwt, algo, gateway, publickey] = opts.bindline.split(/\s+/)
109
104
  return new IPSECKEY({
110
105
  owner,
111
106
  ttl: parseInt(ttl, 10),
package/rr/key.js CHANGED
@@ -23,8 +23,7 @@ export default class KEY extends RR {
23
23
  setAlgorithm(val) {
24
24
  // 1 octet
25
25
 
26
- if (!this.getAlgorithmOptions().has(val))
27
- this.throwHelp(`KEY: algorithm invalid`)
26
+ if (!this.getAlgorithmOptions().has(val)) this.throwHelp(`KEY: algorithm invalid`)
28
27
 
29
28
  this.set('algorithm', val)
30
29
  }
@@ -67,8 +66,7 @@ export default class KEY extends RR {
67
66
 
68
67
  fromBind(opts) {
69
68
  // test.example.com 3600 IN KEY Flags Protocol Algorithm PublicKey
70
- const [owner, ttl, c, type, flags, protocol, algorithm] =
71
- opts.bindline.split(/\s+/)
69
+ const [owner, ttl, c, type, flags, protocol, algorithm] = opts.bindline.split(/\s+/)
72
70
  return new KEY({
73
71
  owner,
74
72
  ttl: parseInt(ttl, 10),
package/rr/kx.js ADDED
@@ -0,0 +1,77 @@
1
+ import RR from '../rr.js'
2
+
3
+ import * as TINYDNS from '../lib/tinydns.js'
4
+
5
+ export default class KX extends RR {
6
+ constructor(opts) {
7
+ super(opts)
8
+ }
9
+
10
+ /****** Resource record specific setters *******/
11
+ setPreference(val) {
12
+ if (val === undefined) this.throwHelp('KX: preference is required')
13
+ this.is16bitInt('KX', 'preference', val)
14
+ this.set('preference', val)
15
+ }
16
+
17
+ setExchanger(val) {
18
+ if (!val) this.throwHelp('KX: exchanger is required')
19
+
20
+ this.isFullyQualified('KX', 'exchanger', val)
21
+ this.isValidHostname('KX', 'exchanger', val)
22
+
23
+ this.set('exchanger', val.toLowerCase())
24
+ }
25
+
26
+ getDescription() {
27
+ return 'Key Exchanger'
28
+ }
29
+
30
+ getRdataFields(arg) {
31
+ return ['preference', 'exchanger']
32
+ }
33
+
34
+ getRFCs() {
35
+ return [2230]
36
+ }
37
+
38
+ getTypeId() {
39
+ return 36
40
+ }
41
+
42
+ getCanonical() {
43
+ return {
44
+ owner: 'example.com.',
45
+ ttl: 3600,
46
+ class: 'IN',
47
+ type: 'KX',
48
+ preference: 10,
49
+ exchanger: 'kx.example.com.',
50
+ }
51
+ }
52
+
53
+ /****** IMPORTERS *******/
54
+ fromBind(opts) {
55
+ // test.example.com 3600 IN KX preference exchanger
56
+ const [owner, ttl, c, type, preference, exchanger] = opts.bindline.split(/\s+/)
57
+ return new KX({
58
+ owner,
59
+ ttl: parseInt(ttl, 10),
60
+ class: c,
61
+ type,
62
+ preference: parseInt(preference, 10),
63
+ exchanger,
64
+ })
65
+ }
66
+
67
+ /****** EXPORTERS *******/
68
+ toBind(zone_opts) {
69
+ return `${this.getPrefix(zone_opts)}\t${this.get('preference')}\t${this.getFQDN('exchanger', zone_opts)}\n`
70
+ }
71
+
72
+ toTinydns() {
73
+ return this.getTinydnsGeneric(
74
+ TINYDNS.UInt16toOctal(this.get('preference')) + TINYDNS.packDomainName(this.get('exchanger')),
75
+ )
76
+ }
77
+ }
package/rr/loc.js CHANGED
@@ -53,8 +53,7 @@ export default class LOC extends RR {
53
53
  const dms = '(\\d+)\\s+(?:(\\d+)\\s+)?(?:([\\d.]+)\\s+)?'
54
54
 
55
55
  // alt["m"] [siz["m"] [hp["m"] [vp["m"]]]]
56
- const alt =
57
- '(-?[\\d.]+)m?(?:\\s+([\\d.]+)m?)?(?:\\s+([\\d.]+)m?)?(?:\\s+([\\d.]+)m?)?'
56
+ const alt = '(-?[\\d.]+)m?(?:\\s+([\\d.]+)m?)?(?:\\s+([\\d.]+)m?)?(?:\\s+([\\d.]+)m?)?'
58
57
 
59
58
  // put them all together
60
59
  const locRe = new RegExp(`^${dms}(N|S)\\s+${dms}(E|W)\\s+${alt}`, 'i')
@@ -96,21 +95,11 @@ export default class LOC extends RR {
96
95
  version: TINYDNS.octalToUInt8(rdata.substring(0, 4)),
97
96
  size: this.fromExponent(TINYDNS.octalToUInt8(rdata.substring(4, 8))),
98
97
  precision: {
99
- horizontal: this.fromExponent(
100
- TINYDNS.octalToUInt8(rdata.substring(8, 12)),
101
- ),
102
- vertical: this.fromExponent(
103
- TINYDNS.octalToUInt8(rdata.substring(12, 16)),
104
- ),
98
+ horizontal: this.fromExponent(TINYDNS.octalToUInt8(rdata.substring(8, 12))),
99
+ vertical: this.fromExponent(TINYDNS.octalToUInt8(rdata.substring(12, 16))),
105
100
  },
106
- latitude: this.arcSecToDMS(
107
- TINYDNS.octalToUInt32(rdata.substring(16, 32)),
108
- 'lat',
109
- ),
110
- longitude: this.arcSecToDMS(
111
- TINYDNS.octalToUInt32(rdata.substring(32, 48)),
112
- 'lon',
113
- ),
101
+ latitude: this.arcSecToDMS(TINYDNS.octalToUInt32(rdata.substring(16, 32)), 'lat'),
102
+ longitude: this.arcSecToDMS(TINYDNS.octalToUInt32(rdata.substring(32, 48)), 'lon'),
114
103
  altitude: TINYDNS.octalToUInt32(rdata.substring(48, 64)) - REF.ALTITUDE,
115
104
  }
116
105
 
@@ -137,10 +126,7 @@ export default class LOC extends RR {
137
126
  }
138
127
 
139
128
  dmsToArcSec(obj) {
140
- let retval =
141
- obj.degrees * CONV.deg +
142
- (obj.minutes || 0) * CONV.min +
143
- (obj.seconds || 0) * CONV.sec
129
+ let retval = obj.degrees * CONV.deg + (obj.minutes || 0) * CONV.min + (obj.seconds || 0) * CONV.sec
144
130
  switch (obj.hemisphere.toUpperCase()) {
145
131
  case 'W':
146
132
  case 'S':
package/rr/mx.js CHANGED
@@ -16,8 +16,7 @@ export default class MX extends RR {
16
16
  setExchange(val) {
17
17
  if (!val) this.throwHelp('MX: exchange is required')
18
18
 
19
- if (this.isIPv4(val) || this.isIPv6(val))
20
- this.throwHelp(`MX: exchange must be a FQDN`)
19
+ if (this.isIPv4(val) || this.isIPv6(val)) this.throwHelp(`MX: exchange must be a FQDN`)
21
20
 
22
21
  this.isFullyQualified('MX', 'exchange', val)
23
22
  this.isValidHostname('MX', 'exchange', val)
@@ -57,9 +56,7 @@ export default class MX extends RR {
57
56
  fromTinydns(opts) {
58
57
  // @fqdn:ip:x:dist:ttl:timestamp:lo
59
58
  // eslint-disable-next-line no-unused-vars
60
- const [owner, ip, x, preference, ttl, ts, loc] = opts.tinyline
61
- .substring(1)
62
- .split(':')
59
+ const [owner, ip, x, preference, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
63
60
 
64
61
  return new MX({
65
62
  type: 'MX',
@@ -74,8 +71,7 @@ export default class MX extends RR {
74
71
 
75
72
  fromBind(opts) {
76
73
  // test.example.com 3600 IN MX preference exchange
77
- const [owner, ttl, c, type, preference, exchange] =
78
- opts.bindline.split(/\s+/)
74
+ const [owner, ttl, c, type, preference, exchange] = opts.bindline.split(/\s+/)
79
75
 
80
76
  return new MX({
81
77
  owner,
package/rr/naptr.js CHANGED
@@ -40,8 +40,7 @@ export default class NAPTR extends RR {
40
40
  }
41
41
 
42
42
  setFlags(val) {
43
- if (!this.getFlagsOptions().has(val.toUpperCase()))
44
- this.throwHelp(`NAPTR flags are invalid`)
43
+ if (!this.getFlagsOptions().has(val.toUpperCase())) this.throwHelp(`NAPTR flags are invalid`)
45
44
 
46
45
  this.set('flags', val.toUpperCase())
47
46
  }
package/rr/ns.js CHANGED
@@ -37,16 +37,12 @@ export default class NS extends RR {
37
37
  fromTinydns(opts) {
38
38
  // &fqdn:ip:x:ttl:timestamp:lo
39
39
  // eslint-disable-next-line no-unused-vars
40
- const [fqdn, ip, dname, ttl, ts, loc] = opts.tinyline
41
- .substring(1)
42
- .split(':')
40
+ const [fqdn, ip, dname, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
43
41
 
44
42
  return new NS({
45
43
  type: 'NS',
46
44
  owner: this.fullyQualify(fqdn),
47
- dname: this.fullyQualify(
48
- /\./.test(dname) ? dname : `${dname}.ns.${fqdn}`,
49
- ),
45
+ dname: this.fullyQualify(/\./.test(dname) ? dname : `${dname}.ns.${fqdn}`),
50
46
  ttl: parseInt(ttl, 10),
51
47
  timestamp: ts,
52
48
  location: loc !== '' && loc !== '\n' ? loc : '',
package/rr/nsec.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import RR from '../rr.js'
2
2
 
3
+ import * as TINYDNS from '../lib/tinydns.js'
4
+
3
5
  export default class NSEC extends RR {
4
6
  constructor(opts) {
5
7
  super(opts)
@@ -50,16 +52,20 @@ export default class NSEC extends RR {
50
52
  class: c,
51
53
  type: type,
52
54
  'next domain': next,
53
- 'type bit maps': opts.bindline
54
- .split(/\s+/)
55
- .slice(5)
56
- .filter(removeParens)
57
- .join(' ')
58
- .trim(),
55
+ 'type bit maps': opts.bindline.split(/\s+/).slice(5).filter(removeParens).join(' ').trim(),
59
56
  })
60
57
  }
61
58
 
62
59
  /****** EXPORTERS *******/
60
+
61
+ toTinydns() {
62
+ const dataRe = new RegExp(/[\r\n\t:\\/]/, 'g')
63
+
64
+ return this.getTinydnsGeneric(
65
+ TINYDNS.packDomainName(this.get('next domain')) +
66
+ TINYDNS.escapeOctal(dataRe, this.get('type bit maps')),
67
+ )
68
+ }
63
69
  }
64
70
 
65
71
  const removeParens = (a) => !['(', ')'].includes(a)
package/rr/nsec3.js CHANGED
@@ -65,14 +65,7 @@ export default class NSEC3 extends RR {
65
65
  }
66
66
 
67
67
  getRdataFields(arg) {
68
- return [
69
- 'hash algorithm',
70
- 'flags',
71
- 'iterations',
72
- 'salt',
73
- 'next hashed owner name',
74
- 'type bit maps',
75
- ]
68
+ return ['hash algorithm', 'flags', 'iterations', 'salt', 'next hashed owner name', 'type bit maps']
76
69
  }
77
70
 
78
71
  getRFCs() {
@@ -87,8 +80,7 @@ export default class NSEC3 extends RR {
87
80
 
88
81
  fromBind(opts) {
89
82
  // test.example.com. 3600 IN NSEC3 1 1 12 aabbccdd (2vptu5timamqttgl4luu9kg21e0aor3s A RRSIG)
90
- const [owner, ttl, c, type, ha, flags, iterations, salt] =
91
- opts.bindline.split(/\s+/)
83
+ const [owner, ttl, c, type, ha, flags, iterations, salt] = opts.bindline.split(/\s+/)
92
84
  const rdata = opts.bindline.split(/\(|\)/)[1]
93
85
 
94
86
  return new NSEC3({
package/rr/nxt.js CHANGED
@@ -50,12 +50,7 @@ export default class NXT extends RR {
50
50
  class: c,
51
51
  type: type,
52
52
  'next domain': next,
53
- 'type bit map': opts.bindline
54
- .split(/\s+/)
55
- .slice(5)
56
- .filter(removeParens)
57
- .join(' ')
58
- .trim(),
53
+ 'type bit map': opts.bindline.split(/\s+/).slice(5).filter(removeParens).join(' ').trim(),
59
54
  })
60
55
  }
61
56
 
package/rr/openpgpkey.js CHANGED
@@ -29,10 +29,9 @@ export default class OPENPGPKEY extends RR {
29
29
  /****** IMPORTERS *******/
30
30
  fromBind(obj) {
31
31
  // test.example.com 3600 IN OPENPGPKEY <base64 public key>
32
+ const regex = /^([\S]+)\s+(\d{1,10})\s+(IN)\s+(OPENPGPKEY)\s+([\W\w]*)$/
32
33
  // eslint-disable-next-line no-unused-vars
33
- const [ignore, owner, ttl, c, type, publickey] = obj.bindline
34
- .trim()
35
- .match(/^([\S]+)\s+(\d{1,10})\s+(IN)\s+(OPENPGPKEY)\s+([\W\w]*)$/)
34
+ const [ignore, owner, ttl, c, type, publickey] = obj.bindline.trim().match(regex)
36
35
 
37
36
  return new OPENPGPKEY({
38
37
  owner,
package/rr/rp.js ADDED
@@ -0,0 +1,78 @@
1
+ import RR from '../rr.js'
2
+
3
+ import * as TINYDNS from '../lib/tinydns.js'
4
+
5
+ export default class RP extends RR {
6
+ constructor(opts) {
7
+ super(opts)
8
+ }
9
+
10
+ /****** Resource record specific setters *******/
11
+ setMbox(val) {
12
+ if (!val) this.throwHelp('RP: mbox is required')
13
+
14
+ this.isFullyQualified('RP', 'mbox', val)
15
+
16
+ this.set('mbox', val.toLowerCase())
17
+ }
18
+
19
+ setTxt(val) {
20
+ if (!val) this.throwHelp('RP: txt is required')
21
+
22
+ this.isFullyQualified('RP', 'txt', val)
23
+
24
+ this.set('txt', val.toLowerCase())
25
+ }
26
+
27
+ getDescription() {
28
+ return 'Responsible Person'
29
+ }
30
+
31
+ getRdataFields(arg) {
32
+ return ['mbox', 'txt']
33
+ }
34
+
35
+ getRFCs() {
36
+ return [1183]
37
+ }
38
+
39
+ getTypeId() {
40
+ return 17
41
+ }
42
+
43
+ getCanonical() {
44
+ return {
45
+ owner: 'example.com.',
46
+ ttl: 3600,
47
+ class: 'IN',
48
+ type: 'RP',
49
+ mbox: 'admin.example.com.',
50
+ txt: 'info.example.com.',
51
+ }
52
+ }
53
+
54
+ /****** IMPORTERS *******/
55
+ fromBind(opts) {
56
+ // test.example.com 3600 IN RP mbox txt
57
+ const [owner, ttl, c, type, mbox, txt] = opts.bindline.split(/\s+/)
58
+ return new RP({
59
+ owner,
60
+ ttl: parseInt(ttl, 10),
61
+ class: c,
62
+ type,
63
+ mbox,
64
+ txt,
65
+ })
66
+ }
67
+
68
+ /****** EXPORTERS *******/
69
+ toBind(zone_opts) {
70
+ return `${this.getPrefix(zone_opts)}\t${this.getFQDN('mbox', zone_opts)}\t${this.getFQDN('txt', zone_opts)}\n`
71
+ }
72
+
73
+ toTinydns() {
74
+ return this.getTinydnsGeneric(
75
+ TINYDNS.packDomainName(this.get('mbox')) + TINYDNS.packDomainName(this.get('txt')),
76
+ )
77
+ }
78
+ }
package/rr/rrsig.js CHANGED
@@ -16,8 +16,7 @@ export default class RRSIG extends RR {
16
16
 
17
17
  setAlgorithm(val) {
18
18
  // a 1 octet Algorithm field
19
- if (!this.getAlgorithmOptions().has(val))
20
- this.throwHelp(`RRSIG: algorithm invalid`)
19
+ if (!this.getAlgorithmOptions().has(val)) this.throwHelp(`RRSIG: algorithm invalid`)
21
20
 
22
21
  this.set('algorithm', val)
23
22
  }
package/rr/smimea.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import RR from '../rr.js'
2
2
 
3
+ import * as TINYDNS from '../lib/tinydns.js'
4
+
3
5
  export default class SMIMEA extends RR {
4
6
  constructor(opts) {
5
7
  super(opts)
@@ -7,8 +9,7 @@ export default class SMIMEA extends RR {
7
9
 
8
10
  /****** Resource record specific setters *******/
9
11
  setCertificateUsage(val) {
10
- if (!this.getCertificateUsageOptions().has(val))
11
- this.throwHelp(`SMIMEA: certificate usage invalid`)
12
+ if (!this.getCertificateUsageOptions().has(val)) this.throwHelp(`SMIMEA: certificate usage invalid`)
12
13
 
13
14
  this.set('certificate usage', val)
14
15
  }
@@ -23,8 +24,7 @@ export default class SMIMEA extends RR {
23
24
  }
24
25
 
25
26
  setSelector(val) {
26
- if (!this.getSelectorOptions().has(val))
27
- this.throwHelp(`SMIMEA: selector invalid`)
27
+ if (!this.getSelectorOptions().has(val)) this.throwHelp(`SMIMEA: selector invalid`)
28
28
 
29
29
  this.set('selector', val)
30
30
  }
@@ -37,8 +37,7 @@ export default class SMIMEA extends RR {
37
37
  }
38
38
 
39
39
  setMatchingType(val) {
40
- if (!this.getMatchingTypeOptions().has(val))
41
- this.throwHelp(`SMIMEA: matching type`)
40
+ if (!this.getMatchingTypeOptions().has(val)) this.throwHelp(`SMIMEA: matching type`)
42
41
 
43
42
  this.set('matching type', val)
44
43
  }
@@ -60,12 +59,7 @@ export default class SMIMEA extends RR {
60
59
  }
61
60
 
62
61
  getRdataFields(arg) {
63
- return [
64
- 'certificate usage',
65
- 'selector',
66
- 'matching type',
67
- 'certificate association data',
68
- ]
62
+ return ['certificate usage', 'selector', 'matching type', 'certificate association data']
69
63
  }
70
64
 
71
65
  getRFCs() {
@@ -84,8 +78,7 @@ export default class SMIMEA extends RR {
84
78
 
85
79
  fromBind(opts) {
86
80
  // test.example.com 3600 IN SMIMEA, usage, selector, match, data
87
- const [owner, ttl, c, type, usage, selector, match] =
88
- opts.bindline.split(/\s+/)
81
+ const [owner, ttl, c, type, usage, selector, match] = opts.bindline.split(/\s+/)
89
82
  return new SMIMEA({
90
83
  owner,
91
84
  ttl: parseInt(ttl, 10),
@@ -94,11 +87,19 @@ export default class SMIMEA extends RR {
94
87
  'certificate usage': parseInt(usage, 10),
95
88
  selector: parseInt(selector, 10),
96
89
  'matching type': parseInt(match, 10),
97
- 'certificate association data': opts.bindline
98
- .split(/\s+/)
99
- .slice(7)
100
- .join(' ')
101
- .trim(),
90
+ 'certificate association data': opts.bindline.split(/\s+/).slice(7).join(' ').trim(),
102
91
  })
103
92
  }
93
+
94
+ /****** EXPORTERS *******/
95
+ toTinydns() {
96
+ const dataRe = new RegExp(/[\r\n\t:\\/]/, 'g')
97
+
98
+ return this.getTinydnsGeneric(
99
+ TINYDNS.UInt8toOctal(this.get('certificate usage')) +
100
+ TINYDNS.UInt8toOctal(this.get('selector')) +
101
+ TINYDNS.UInt8toOctal(this.get('matching type')) +
102
+ TINYDNS.escapeOctal(dataRe, this.get('certificate association data')),
103
+ )
104
+ }
104
105
  }
package/rr/soa.js CHANGED
@@ -86,19 +86,8 @@ export default class SOA extends RR {
86
86
  /****** IMPORTERS *******/
87
87
  fromBind(opts) {
88
88
  // example.com TTL IN SOA mname rname serial refresh retry expire minimum
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+]/)
89
+ const [owner, ttl, c, type, mname, rname, serial, refresh, retry, expire, minimum] =
90
+ opts.bindline.split(/[\s+]/)
102
91
 
103
92
  return new SOA({
104
93
  owner,
@@ -117,8 +106,7 @@ export default class SOA extends RR {
117
106
 
118
107
  fromTinydns(opts) {
119
108
  // Zfqdn:mname:rname:ser:ref:ret:exp:min:ttl:time:lo
120
- const [fqdn, mname, rname, ser, ref, ret, exp, min, ttl, ts, loc] =
121
- opts.tinyline.substring(1).split(':')
109
+ const [fqdn, mname, rname, ser, ref, ret, exp, min, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
122
110
 
123
111
  return new SOA({
124
112
  owner: this.fullyQualify(fqdn),
package/rr/spf.js CHANGED
@@ -48,10 +48,7 @@ export default class SPF extends TXT {
48
48
 
49
49
  /****** EXPORTERS *******/
50
50
  toTinydns() {
51
- const rdata = TINYDNS.escapeOctal(
52
- new RegExp(/[\r\n\t:\\/]/, 'g'),
53
- this.get('data'),
54
- )
51
+ const rdata = TINYDNS.escapeOctal(new RegExp(/[\r\n\t:\\/]/, 'g'), this.get('data'))
55
52
  return this.getTinydnsGeneric(rdata)
56
53
  }
57
54
  }