@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/nsec.js CHANGED
@@ -1,15 +1,14 @@
1
-
2
1
  import RR from '../rr.js'
3
2
 
4
3
  export default class NSEC extends RR {
5
- constructor (opts) {
4
+ constructor(opts) {
6
5
  super(opts)
7
6
  if (opts === null) return
8
7
  }
9
8
 
10
9
  /****** Resource record specific setters *******/
11
- setNextDomain (val) {
12
- if (!val) throw new Error(`NSEC: 'next domain' is required:, ${this.citeRFC()}`)
10
+ setNextDomain(val) {
11
+ if (!val) this.throwHelp(`NSEC: 'next domain' is required:`)
13
12
 
14
13
  this.isFullyQualified('NSEC', 'next domain', val)
15
14
  this.isValidHostname('NSEC', 'next domain', val)
@@ -18,44 +17,49 @@ export default class NSEC extends RR {
18
17
  this.set('next domain', val.toLowerCase())
19
18
  }
20
19
 
21
- setTypeBitMaps (val) {
22
- if (!val) throw new Error(`NSEC: 'type bit maps' is required, ${this.citeRFC()}`)
20
+ setTypeBitMaps(val) {
21
+ if (!val) this.throwHelp(`NSEC: 'type bit maps' is required`)
23
22
 
24
23
  this.set('type bit maps', val)
25
24
  }
26
25
 
27
- getDescription () {
26
+ getDescription() {
28
27
  return 'Next Secure'
29
28
  }
30
29
 
31
- getRdataFields (arg) {
32
- return [ 'next domain', 'type bit maps' ]
30
+ getRdataFields(arg) {
31
+ return ['next domain', 'type bit maps']
33
32
  }
34
33
 
35
- getRFCs () {
36
- return [ 4034 ]
34
+ getRFCs() {
35
+ return [4034]
37
36
  }
38
37
 
39
- getTypeId () {
38
+ getTypeId() {
40
39
  return 47
41
40
  }
42
41
 
43
42
  /****** IMPORTERS *******/
44
43
 
45
- fromBind (opts) {
44
+ fromBind(opts) {
46
45
  // test.example.com 3600 IN NSEC NextDomain TypeBitMaps
47
- const [ owner, ttl, c, type, next ] = opts.bindline.split(/\s+/)
46
+ const [owner, ttl, c, type, next] = opts.bindline.split(/\s+/)
48
47
  return new NSEC({
49
48
  owner,
50
- ttl : parseInt(ttl, 10),
51
- class : c,
52
- type : type,
53
- 'next domain' : next,
54
- 'type bit maps': opts.bindline.split(/\s+/).slice(5).filter(removeParens).join(' ').trim(),
49
+ ttl: parseInt(ttl, 10),
50
+ class: c,
51
+ type: type,
52
+ 'next domain': next,
53
+ 'type bit maps': opts.bindline
54
+ .split(/\s+/)
55
+ .slice(5)
56
+ .filter(removeParens)
57
+ .join(' ')
58
+ .trim(),
55
59
  })
56
60
  }
57
61
 
58
62
  /****** EXPORTERS *******/
59
63
  }
60
64
 
61
- const removeParens = a => ![ '(',')' ].includes(a)
65
+ const removeParens = (a) => !['(', ')'].includes(a)
package/rr/nsec3.js CHANGED
@@ -1,44 +1,43 @@
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 NSEC3 extends RR {
7
- constructor (opts) {
6
+ constructor(opts) {
8
7
  super(opts)
9
8
  if (opts === null) return
10
9
  }
11
10
 
12
11
  /****** Resource record specific setters *******/
13
- setHashAlgorithm (val) {
12
+ setHashAlgorithm(val) {
14
13
  // Hash Algorithm is a single octet.
15
14
  // The Hash Algorithm field is represented as an unsigned decimal integer.
16
- if (!val) throw new Error(`NSEC3: 'hash algorithm' is required, ${this.citeRFC()}`)
15
+ if (!val) this.throwHelp(`NSEC3: 'hash algorithm' is required`)
17
16
 
18
17
  this.is8bitInt('NSEC3', 'hash algorithm', val)
19
18
 
20
19
  this.set('hash algorithm', val)
21
20
  }
22
21
 
23
- setFlags (val) {
22
+ setFlags(val) {
24
23
  // The Flags field is represented as an unsigned decimal integer.
25
- if (!val) throw new Error(`NSEC3: 'flags' is required, ${this.citeRFC()}`)
24
+ if (!val) this.throwHelp(`NSEC3: 'flags' is required`)
26
25
 
27
26
  this.is8bitInt('NSEC3', 'flags', val)
28
27
 
29
28
  this.set('flags', val)
30
29
  }
31
30
 
32
- setIterations (val) {
31
+ setIterations(val) {
33
32
  // The Iterations field is represented as an unsigned decimal integer. 0-65535
34
- if (!val) throw new Error(`NSEC3: 'iterations' is required, ${this.citeRFC()}`)
33
+ if (!val) this.throwHelp(`NSEC3: 'iterations' is required`)
35
34
 
36
35
  this.is16bitInt('NSEC3', 'flags', val)
37
36
 
38
37
  this.set('iterations', val)
39
38
  }
40
39
 
41
- setSalt (val) {
40
+ setSalt(val) {
42
41
  // The Salt field is represented as a sequence of case-insensitive
43
42
  // hexadecimal digits. Whitespace is not allowed within the
44
43
  // sequence. The Salt field is represented as "-" (without the
@@ -46,95 +45,109 @@ export default class NSEC3 extends RR {
46
45
  this.set('salt', val)
47
46
  }
48
47
 
49
- setNextHashedOwnerName (val) {
48
+ setNextHashedOwnerName(val) {
50
49
  // The Next Hashed Owner Name field is represented as an unpadded
51
50
  // sequence of case-insensitive base32 digits, without whitespace
52
- if (!val) throw new Error(`NSEC3: 'next hashed owner name' is required, ${this.citeRFC()}`)
51
+ if (!val) this.throwHelp(`NSEC3: 'next hashed owner name' is required`)
53
52
 
54
53
  this.set('next hashed owner name', val)
55
54
  }
56
55
 
57
- setTypeBitMaps (val) {
56
+ setTypeBitMaps(val) {
58
57
  // The Type Bit Maps field is represented as a sequence of RR type mnemonics.
59
- if (!val) throw new Error(`NSEC3: 'type bit maps' is required, ${this.citeRFC()}`)
58
+ if (!val) this.throwHelp(`NSEC3: 'type bit maps' is required`)
60
59
 
61
60
  this.set('type bit maps', val)
62
61
  }
63
62
 
64
- getDescription () {
63
+ getDescription() {
65
64
  return 'Next Secure'
66
65
  }
67
66
 
68
- getRdataFields (arg) {
69
- return [ 'hash algorithm', 'flags', 'iterations', 'salt', 'next hashed owner name', 'type bit maps' ]
67
+ getRdataFields(arg) {
68
+ return [
69
+ 'hash algorithm',
70
+ 'flags',
71
+ 'iterations',
72
+ 'salt',
73
+ 'next hashed owner name',
74
+ 'type bit maps',
75
+ ]
70
76
  }
71
77
 
72
- getRFCs () {
73
- return [ 5155, 9077 ]
78
+ getRFCs() {
79
+ return [5155, 9077]
74
80
  }
75
81
 
76
- getTypeId () {
82
+ getTypeId() {
77
83
  return 50
78
84
  }
79
85
 
80
86
  /****** IMPORTERS *******/
81
87
 
82
- fromBind (opts) {
88
+ fromBind(opts) {
83
89
  // test.example.com. 3600 IN NSEC3 1 1 12 aabbccdd (2vptu5timamqttgl4luu9kg21e0aor3s A RRSIG)
84
- const [ owner, ttl, c, type, ha, flags, iterations, salt ] = opts.bindline.split(/\s+/)
90
+ const [owner, ttl, c, type, ha, flags, iterations, salt] =
91
+ opts.bindline.split(/\s+/)
85
92
  const rdata = opts.bindline.split(/\(|\)/)[1]
86
93
 
87
94
  return new NSEC3({
88
95
  owner,
89
- ttl : parseInt(ttl, 10),
90
- class : c,
91
- type : type,
92
- 'hash algorithm' : parseInt(ha, 10),
93
- flags : parseInt(flags, 10),
94
- iterations : parseInt(iterations, 10),
96
+ ttl: parseInt(ttl, 10),
97
+ class: c,
98
+ type: type,
99
+ 'hash algorithm': parseInt(ha, 10),
100
+ flags: parseInt(flags, 10),
101
+ iterations: parseInt(iterations, 10),
95
102
  salt,
96
103
  'next hashed owner name': rdata.split(/\s+/)[0],
97
- 'type bit maps' : rdata.split(/\s+/).slice(1).join('\t'),
104
+ 'type bit maps': rdata.split(/\s+/).slice(1).join('\t'),
98
105
  })
99
106
  }
100
107
 
101
- fromTinydns (opts) {
102
- const [ fqdn, n, rdata, ttl, ts, loc ] = opts.tinyline.substring(1).split(':')
103
- if (n != 50) throw new Error('NSEC3 fromTinydns, invalid n')
108
+ fromTinydns(opts) {
109
+ const [fqdn, n, rdata, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
110
+ if (n != 50) this.throwHelp('NSEC3 fromTinydns, invalid n')
104
111
 
105
112
  const bytes = Buffer.from(TINYDNS.octalToChar(rdata), 'binary')
106
113
 
107
114
  return new NSEC3({
108
- owner : this.fullyQualify(fqdn),
109
- ttl : parseInt(ttl, 10),
110
- type : 'NSEC3',
115
+ owner: this.fullyQualify(fqdn),
116
+ ttl: parseInt(ttl, 10),
117
+ type: 'NSEC3',
111
118
  'hash algorithm': bytes.readUInt8(0),
112
- flags : bytes.readUInt8(1),
113
- iterations : bytes.readUInt16BE(2),
119
+ flags: bytes.readUInt8(1),
120
+ iterations: bytes.readUInt16BE(2),
114
121
  // salt : ,
115
122
  // 'next hashed owner name': ,
116
123
  // 'type bit maps' : ,
117
- timestamp : ts,
118
- location : loc !== '' && loc !== '\n' ? loc : '',
124
+ timestamp: ts,
125
+ location: loc !== '' && loc !== '\n' ? loc : '',
119
126
  })
120
127
  }
121
128
 
122
129
  /****** EXPORTERS *******/
123
130
 
124
- toBind (zone_opts) {
125
- return `${this.getFQDN('owner', zone_opts)}\t${this.get('ttl')}\t${this.get('class')}\tNSEC3${this.getRdataFields().slice(0,4).map(f => '\t' + this.get(f)).join('')}\t(${this.getRdataFields().slice(4).map(f => this.get(f)).join('\t')})\n`
131
+ toBind(zone_opts) {
132
+ return `${this.getFQDN('owner', zone_opts)}\t${this.get('ttl')}\t${this.get('class')}\tNSEC3${this.getRdataFields()
133
+ .slice(0, 4)
134
+ .map((f) => '\t' + this.get(f))
135
+ .join('')}\t(${this.getRdataFields()
136
+ .slice(4)
137
+ .map((f) => this.get(f))
138
+ .join('\t')})\n`
126
139
  }
127
140
 
128
- toTinydns () {
141
+ toTinydns() {
129
142
  const dataRe = new RegExp(/[\r\n\t:\\/]/, 'g')
130
143
 
131
144
  return this.getTinydnsGeneric(
132
145
  TINYDNS.UInt8toOctal(this.get('hash algorithm')) +
133
- TINYDNS.UInt8toOctal(this.get('flags')) +
134
- TINYDNS.UInt16toOctal(this.get('iterations')) +
135
- TINYDNS.escapeOctal(dataRe, this.get('salt')) +
136
- TINYDNS.escapeOctal(dataRe, this.get('next hashed owner name')) +
137
- TINYDNS.escapeOctal(dataRe, this.get('type bit maps'))
146
+ TINYDNS.UInt8toOctal(this.get('flags')) +
147
+ TINYDNS.UInt16toOctal(this.get('iterations')) +
148
+ TINYDNS.escapeOctal(dataRe, this.get('salt')) +
149
+ TINYDNS.escapeOctal(dataRe, this.get('next hashed owner name')) +
150
+ TINYDNS.escapeOctal(dataRe, this.get('type bit maps')),
138
151
  )
139
152
  }
140
153
  }
package/rr/nsec3param.js CHANGED
@@ -1,42 +1,41 @@
1
-
2
1
  import RR from '../rr.js'
3
2
 
4
3
  export default class NSEC3PARAM extends RR {
5
- constructor (opts) {
4
+ constructor(opts) {
6
5
  super(opts)
7
6
  if (opts === null) return
8
7
  }
9
8
 
10
9
  /****** Resource record specific setters *******/
11
- setHashAlgoritm (val) {
10
+ setHashAlgorithm(val) {
12
11
  // Hash Algorithm is a single octet.
13
12
  // The Hash Algorithm field is represented as an unsigned decimal integer.
14
- if (!val) throw new Error(`NSEC3PARAM: 'hash algorithm' is required, ${this.citeRFC()}`)
13
+ if (!val) this.throwHelp(`NSEC3PARAM: 'hash algorithm' is required`)
15
14
 
16
15
  this.is8bitInt('NSEC3PARAM', 'hash algorithm', val)
17
16
 
18
17
  this.set('hash algorithm', val)
19
18
  }
20
19
 
21
- setFlags (val) {
20
+ setFlags(val) {
22
21
  // The Flags field is represented as an unsigned decimal integer.
23
- if (!val) throw new Error(`NSEC3PARAM: 'flags' is required, ${this.citeRFC()}`)
22
+ if (!val) this.throwHelp(`NSEC3PARAM: 'flags' is required`)
24
23
 
25
24
  this.is8bitInt('NSEC3PARAM', 'flags', val)
26
25
 
27
26
  this.set('flags', val)
28
27
  }
29
28
 
30
- setIterations (val) {
29
+ setIterations(val) {
31
30
  // The Iterations field is represented as an unsigned decimal integer. 0-65535
32
- if (!val) throw new Error(`NSEC3PARAM: 'iterations' is required, ${this.citeRFC()}`)
31
+ if (!val) this.throwHelp(`NSEC3PARAM: 'iterations' is required`)
33
32
 
34
33
  this.is16bitInt('NSEC3PARAM', 'iterations', val)
35
34
 
36
35
  this.set('iterations', val)
37
36
  }
38
37
 
39
- setSalt (val) {
38
+ setSalt(val) {
40
39
  // The Salt field is represented as a sequence of case-insensitive
41
40
  // hexadecimal digits. Whitespace is not allowed within the
42
41
  // sequence. The Salt field is represented as "-" (without the
@@ -44,41 +43,40 @@ export default class NSEC3PARAM extends RR {
44
43
  this.set('salt', val)
45
44
  }
46
45
 
47
- getDescription () {
46
+ getDescription() {
48
47
  return 'Next Secure Parameters'
49
48
  }
50
49
 
51
- getRdataFields (arg) {
52
- return [ 'hash algorithm', 'flags', 'iterations', 'salt' ]
50
+ getRdataFields(arg) {
51
+ return ['hash algorithm', 'flags', 'iterations', 'salt']
53
52
  }
54
53
 
55
- getRFCs () {
56
- return [ 5155 ]
54
+ getRFCs() {
55
+ return [5155]
57
56
  }
58
57
 
59
- getTypeId () {
58
+ getTypeId() {
60
59
  return 51
61
60
  }
62
61
 
63
62
  /****** IMPORTERS *******/
64
63
 
65
- fromBind (str) {
64
+ fromBind(str) {
66
65
  // test.example.com 3600 IN NSEC3PARAM
67
- const [ owner, ttl, c, type ] = str.split(/\s+/)
66
+ const [owner, ttl, c, type] = str.split(/\s+/)
68
67
  return new NSEC3PARAM({
69
68
  owner,
70
- ttl : parseInt(ttl, 10),
71
- class : c,
72
- type : type,
73
- 'hash algorithm' : '',
74
- 'flags' : '',
75
- 'iterations' : '',
76
- 'salt' : '',
69
+ ttl: parseInt(ttl, 10),
70
+ class: c,
71
+ type: type,
72
+ 'hash algorithm': '',
73
+ flags: '',
74
+ iterations: '',
75
+ salt: '',
77
76
  'next hashed owner name': '',
78
- 'type bit maps' : '',
77
+ 'type bit maps': '',
79
78
  })
80
79
  }
81
80
 
82
81
  /****** EXPORTERS *******/
83
-
84
82
  }
package/rr/nxt.js ADDED
@@ -0,0 +1,65 @@
1
+ import RR from '../rr.js'
2
+
3
+ export default class NXT extends RR {
4
+ constructor(opts) {
5
+ super(opts)
6
+ if (opts === null) return
7
+ }
8
+
9
+ /****** Resource record specific setters *******/
10
+ setNextDomain(val) {
11
+ if (!val) this.throwHelp(`NXT: 'next domain' is required`)
12
+
13
+ this.isFullyQualified('NXT', 'next domain', val)
14
+ this.isValidHostname('NXT', 'next domain', val)
15
+
16
+ // RFC 4034: letters in the DNS names are lower cased
17
+ this.set('next domain', val.toLowerCase())
18
+ }
19
+
20
+ setTypeBitMap(val) {
21
+ if (!val) this.throwHelp(`NXT: 'type bit map' is required`)
22
+
23
+ this.set('type bit map', val)
24
+ }
25
+
26
+ getDescription() {
27
+ return 'Next Secure'
28
+ }
29
+
30
+ getRdataFields(arg) {
31
+ return ['next domain', 'type bit map']
32
+ }
33
+
34
+ getRFCs() {
35
+ return [2065]
36
+ }
37
+
38
+ getTypeId() {
39
+ return 30
40
+ }
41
+
42
+ /****** IMPORTERS *******/
43
+
44
+ fromBind(opts) {
45
+ // test.example.com 3600 IN NXT NextDomain TypeBitMap
46
+ const [owner, ttl, c, type, next] = opts.bindline.split(/\s+/)
47
+ return new NXT({
48
+ owner,
49
+ ttl: parseInt(ttl, 10),
50
+ class: c,
51
+ type: type,
52
+ 'next domain': next,
53
+ 'type bit map': opts.bindline
54
+ .split(/\s+/)
55
+ .slice(5)
56
+ .filter(removeParens)
57
+ .join(' ')
58
+ .trim(),
59
+ })
60
+ }
61
+
62
+ /****** EXPORTERS *******/
63
+ }
64
+
65
+ const removeParens = (a) => !['(', ')'].includes(a)
package/rr/openpgpkey.js CHANGED
@@ -1,42 +1,45 @@
1
-
2
1
  import RR from '../rr.js'
3
2
 
4
3
  export default class OPENPGPKEY extends RR {
5
- constructor (opts) {
4
+ constructor(opts) {
6
5
  super(opts)
7
6
  }
8
7
 
9
8
  /****** Resource record specific setters *******/
10
- setPublicKey (val) {
9
+ setPublicKey(val) {
11
10
  this.set('public key', val)
12
11
  }
13
12
 
14
- getDescription () {
13
+ getDescription() {
15
14
  return 'OpenPGP Public Key'
16
15
  }
17
16
 
18
- getRdataFields () {
19
- return [ 'public key' ]
17
+ getRdataFields() {
18
+ return ['public key']
20
19
  }
21
20
 
22
- getRFCs () {
23
- return [ 4880, 7929 ]
21
+ getRFCs() {
22
+ return [4880, 7929]
24
23
  }
25
24
 
26
- getTypeId () {
25
+ getTypeId() {
27
26
  return 61
28
27
  }
29
28
 
30
29
  /****** IMPORTERS *******/
31
- fromBind (str) {
30
+ fromBind(obj) {
32
31
  // test.example.com 3600 IN OPENPGPKEY <base64 public key>
33
- const [ owner, ttl, c, type, privatekey ] = str.split(/\s+/)
32
+ // eslint-disable-next-line no-unused-vars
33
+ const [ignore, owner, ttl, c, type, publickey] = obj.bindline.match(
34
+ /^([\S]+)\s+(\d+)\s+(\w+)\s+(\w+)\s+([\W\w]*)$/,
35
+ )
36
+
34
37
  return new OPENPGPKEY({
35
38
  owner,
36
- ttl : parseInt(ttl, 10),
37
- class : c,
38
- type : type,
39
- 'private key': privatekey,
39
+ ttl: parseInt(ttl, 10),
40
+ class: c,
41
+ type: type,
42
+ 'public key': publickey.trim(),
40
43
  })
41
44
  }
42
45
 
package/rr/ptr.js CHANGED
@@ -1,13 +1,12 @@
1
-
2
1
  import RR from '../rr.js'
3
2
 
4
3
  export default class PTR extends RR {
5
- constructor (opts) {
4
+ constructor(opts) {
6
5
  super(opts)
7
6
  }
8
7
 
9
8
  /****** Resource record specific setters *******/
10
- setDname (val) {
9
+ setDname(val) {
11
10
  this.isFullyQualified('PTR', 'dname', val)
12
11
  this.isValidHostname('PTR', 'dname', val)
13
12
 
@@ -15,51 +14,51 @@ export default class PTR extends RR {
15
14
  this.set('dname', val.toLowerCase())
16
15
  }
17
16
 
18
- getDescription () {
17
+ getDescription() {
19
18
  return 'Pointer'
20
19
  }
21
20
 
22
- getRdataFields (arg) {
23
- return [ 'dname' ]
21
+ getRdataFields(arg) {
22
+ return ['dname']
24
23
  }
25
24
 
26
- getRFCs () {
27
- return [ 1035 ]
25
+ getRFCs() {
26
+ return [1035]
28
27
  }
29
28
 
30
- getTypeId () {
29
+ getTypeId() {
31
30
  return 12
32
31
  }
33
32
 
34
33
  /****** IMPORTERS *******/
35
- fromTinydns (opts) {
34
+ fromTinydns(opts) {
36
35
  // ^fqdn:p:ttl:timestamp:lo
37
- const [ fqdn, p, ttl, ts, loc ] = opts.tinyline.substring(1).split(':')
36
+ const [fqdn, p, ttl, ts, loc] = opts.tinyline.substring(1).split(':')
38
37
 
39
38
  return new PTR({
40
- owner : this.fullyQualify(fqdn),
41
- ttl : parseInt(ttl, 10),
42
- type : 'PTR',
43
- dname : this.fullyQualify(p),
39
+ owner: this.fullyQualify(fqdn),
40
+ ttl: parseInt(ttl, 10),
41
+ type: 'PTR',
42
+ dname: this.fullyQualify(p),
44
43
  timestamp: ts,
45
- location : loc !== '' && loc !== '\n' ? loc : '',
44
+ location: loc !== '' && loc !== '\n' ? loc : '',
46
45
  })
47
46
  }
48
47
 
49
- fromBind (opts) {
48
+ fromBind(opts) {
50
49
  // test.example.com 3600 IN PTR dname
51
- const [ owner, ttl, c, type, dname ] = opts.bindline.split(/\s+/)
50
+ const [owner, ttl, c, type, dname] = opts.bindline.split(/\s+/)
52
51
  return new PTR({
53
52
  owner,
54
- ttl : parseInt(ttl, 10),
53
+ ttl: parseInt(ttl, 10),
55
54
  class: c,
56
- type : type,
55
+ type: type,
57
56
  dname: dname,
58
57
  })
59
58
  }
60
59
 
61
60
  /****** EXPORTERS *******/
62
- toTinydns () {
61
+ toTinydns() {
63
62
  return `^${this.getTinyFQDN('owner')}:${this.getTinyFQDN('dname')}:${this.getTinydnsPostamble()}\n`
64
63
  }
65
64
  }