@nictool/dns-resource-record 1.5.0 → 1.6.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/rr/nsec.js CHANGED
@@ -29,6 +29,10 @@ export default class NSEC extends RR {
29
29
  return 'Next Secure'
30
30
  }
31
31
 
32
+ getTags() {
33
+ return ['dnssec']
34
+ }
35
+
32
36
  getRdataFields(arg) {
33
37
  return ['next domain', 'type bit maps']
34
38
  }
@@ -41,6 +45,17 @@ export default class NSEC extends RR {
41
45
  return 47
42
46
  }
43
47
 
48
+ getCanonical() {
49
+ return {
50
+ owner: 'alfa.example.com.',
51
+ ttl: 3600,
52
+ class: 'IN',
53
+ type: 'NSEC',
54
+ 'next domain': 'host.example.com.',
55
+ 'type bit maps': 'A MX RRSIG NSEC TYPE1234',
56
+ }
57
+ }
58
+
44
59
  /****** IMPORTERS *******/
45
60
 
46
61
  fromTinydns({ tinyline }) {
package/rr/nsec3.js CHANGED
@@ -64,6 +64,10 @@ export default class NSEC3 extends RR {
64
64
  return 'Next Secure'
65
65
  }
66
66
 
67
+ getTags() {
68
+ return ['dnssec']
69
+ }
70
+
67
71
  getRdataFields(arg) {
68
72
  return ['hash algorithm', 'flags', 'iterations', 'salt', 'next hashed owner name', 'type bit maps']
69
73
  }
@@ -76,6 +80,21 @@ export default class NSEC3 extends RR {
76
80
  return 50
77
81
  }
78
82
 
83
+ getCanonical() {
84
+ return {
85
+ owner: 'test.example.com.',
86
+ ttl: 3600,
87
+ class: 'IN',
88
+ type: 'NSEC3',
89
+ 'hash algorithm': 1,
90
+ flags: 1,
91
+ iterations: 12,
92
+ salt: 'aabbccdd',
93
+ 'next hashed owner name': '2vptu5timamqttgl4luu9kg21e0aor3s',
94
+ 'type bit maps': 'A RRSIG',
95
+ }
96
+ }
97
+
79
98
  /****** IMPORTERS *******/
80
99
 
81
100
  fromBind({ bindline }) {
package/rr/nsec3param.js CHANGED
@@ -57,6 +57,10 @@ export default class NSEC3PARAM extends RR {
57
57
  return 'Next Secure Parameters'
58
58
  }
59
59
 
60
+ getTags() {
61
+ return ['dnssec']
62
+ }
63
+
60
64
  getRdataFields(arg) {
61
65
  return ['hash algorithm', 'flags', 'iterations', 'salt']
62
66
  }
@@ -69,6 +73,19 @@ export default class NSEC3PARAM extends RR {
69
73
  return 51
70
74
  }
71
75
 
76
+ getCanonical() {
77
+ return {
78
+ owner: 'example.com.',
79
+ ttl: 3600,
80
+ class: 'IN',
81
+ type: 'NSEC3PARAM',
82
+ 'hash algorithm': 1,
83
+ flags: 1,
84
+ iterations: 12,
85
+ salt: 'aabbccdd',
86
+ }
87
+ }
88
+
72
89
  /****** IMPORTERS *******/
73
90
 
74
91
  fromBind({ bindline }) {
package/rr/nxt.js CHANGED
@@ -29,6 +29,10 @@ export default class NXT extends RR {
29
29
  return 'Next Secure'
30
30
  }
31
31
 
32
+ getTags() {
33
+ return ['deprecated']
34
+ }
35
+
32
36
  getRdataFields(arg) {
33
37
  return ['next domain', 'type bit map']
34
38
  }
@@ -41,6 +45,17 @@ export default class NXT extends RR {
41
45
  return 30
42
46
  }
43
47
 
48
+ getCanonical() {
49
+ return {
50
+ owner: 'big.example.com.',
51
+ ttl: 3600,
52
+ class: 'IN',
53
+ type: 'NXT',
54
+ 'next domain': 'host.example.com.',
55
+ 'type bit map': 'A MX NXT',
56
+ }
57
+ }
58
+
44
59
  /****** IMPORTERS *******/
45
60
 
46
61
  fromTinydns({ tinyline }) {
package/rr/openpgpkey.js CHANGED
@@ -15,6 +15,10 @@ export default class OPENPGPKEY extends RR {
15
15
  return 'OpenPGP Public Key'
16
16
  }
17
17
 
18
+ getTags() {
19
+ return ['security']
20
+ }
21
+
18
22
  getRdataFields() {
19
23
  return ['public key']
20
24
  }
@@ -27,6 +31,16 @@ export default class OPENPGPKEY extends RR {
27
31
  return 61
28
32
  }
29
33
 
34
+ getCanonical() {
35
+ return {
36
+ owner: 'matt.example.com.',
37
+ ttl: 3600,
38
+ class: 'IN',
39
+ type: 'OPENPGPKEY',
40
+ 'public key': 'mQINBFY...',
41
+ }
42
+ }
43
+
30
44
  /****** IMPORTERS *******/
31
45
  fromBind({ bindline: bindline }) {
32
46
  // test.example.com 3600 IN OPENPGPKEY <base64 public key>
package/rr/ptr.js CHANGED
@@ -18,6 +18,10 @@ export default class PTR extends RR {
18
18
  return 'Pointer'
19
19
  }
20
20
 
21
+ getTags() {
22
+ return ['common']
23
+ }
24
+
21
25
  getRdataFields(arg) {
22
26
  return ['dname']
23
27
  }
@@ -30,6 +34,16 @@ export default class PTR extends RR {
30
34
  return 12
31
35
  }
32
36
 
37
+ getCanonical() {
38
+ return {
39
+ owner: '2.2.0.192.in-addr.arpa.',
40
+ ttl: 3600,
41
+ class: 'IN',
42
+ type: 'PTR',
43
+ dname: 'host.example.com.',
44
+ }
45
+ }
46
+
33
47
  /****** IMPORTERS *******/
34
48
  fromTinydns({ tinyline }) {
35
49
  // ^fqdn:p:ttl:timestamp:lo
@@ -58,6 +72,10 @@ export default class PTR extends RR {
58
72
  }
59
73
 
60
74
  /****** EXPORTERS *******/
75
+ getWireRdata() {
76
+ return this.wirePackDomain(this.get('dname'))
77
+ }
78
+
61
79
  toTinydns() {
62
80
  return `^${this.getTinyFQDN('owner')}:${this.getTinyFQDN('dname')}:${this.getTinydnsPostamble()}\n`
63
81
  }
package/rr/rp.js CHANGED
@@ -28,6 +28,10 @@ export default class RP extends RR {
28
28
  return 'Responsible Person'
29
29
  }
30
30
 
31
+ getTags() {
32
+ return ['obsolete']
33
+ }
34
+
31
35
  getRdataFields(arg) {
32
36
  return ['mbox', 'txt']
33
37
  }
package/rr/rrsig.js CHANGED
@@ -78,6 +78,10 @@ export default class RRSIG extends RR {
78
78
  return 'Resource Record Signature'
79
79
  }
80
80
 
81
+ getTags() {
82
+ return ['dnssec']
83
+ }
84
+
81
85
  getRdataFields(arg) {
82
86
  return [
83
87
  'type covered',
@@ -100,6 +104,24 @@ export default class RRSIG extends RR {
100
104
  return 46
101
105
  }
102
106
 
107
+ getCanonical() {
108
+ return {
109
+ owner: 'example.com.',
110
+ ttl: 3600,
111
+ class: 'IN',
112
+ type: 'RRSIG',
113
+ 'type covered': 1,
114
+ algorithm: 5,
115
+ labels: 3,
116
+ 'original ttl': 3600,
117
+ 'signature expiration': 1045053120,
118
+ 'signature inception': 1042461120,
119
+ 'key tag': 12345,
120
+ 'signers name': 'example.com.',
121
+ signature: 'ABCDEF...',
122
+ }
123
+ }
124
+
103
125
  /****** IMPORTERS *******/
104
126
 
105
127
  fromBind({ bindline }) {
package/rr/sig.js CHANGED
@@ -68,6 +68,10 @@ export default class SIG extends RR {
68
68
  return 'Signature'
69
69
  }
70
70
 
71
+ getTags() {
72
+ return ['obsolete']
73
+ }
74
+
71
75
  getRdataFields(arg) {
72
76
  return [
73
77
  'type covered',
@@ -83,13 +87,31 @@ export default class SIG extends RR {
83
87
  }
84
88
 
85
89
  getRFCs() {
86
- return [2535]
90
+ return [2535, 3755]
87
91
  }
88
92
 
89
93
  getTypeId() {
90
94
  return 24
91
95
  }
92
96
 
97
+ getCanonical() {
98
+ return {
99
+ owner: 'example.com.',
100
+ ttl: 3600,
101
+ class: 'IN',
102
+ type: 'SIG',
103
+ 'type covered': 1,
104
+ algorithm: 5,
105
+ labels: 3,
106
+ 'original ttl': 3600,
107
+ 'signature expiration': 1045053120,
108
+ 'signature inception': 1042461120,
109
+ 'key tag': 12345,
110
+ 'signers name': 'example.com.',
111
+ signature: 'ABCDEF...',
112
+ }
113
+ }
114
+
93
115
  /****** IMPORTERS *******/
94
116
 
95
117
  fromBind({ bindline }) {
package/rr/smimea.js CHANGED
@@ -58,6 +58,10 @@ export default class SMIMEA extends RR {
58
58
  return 'S/MIME cert association'
59
59
  }
60
60
 
61
+ getTags() {
62
+ return ['security']
63
+ }
64
+
61
65
  getRdataFields(arg) {
62
66
  return ['certificate usage', 'selector', 'matching type', 'certificate association data']
63
67
  }
@@ -70,6 +74,19 @@ export default class SMIMEA extends RR {
70
74
  return 53
71
75
  }
72
76
 
77
+ getCanonical() {
78
+ return {
79
+ owner: '_443._tcp.www.example.com.',
80
+ ttl: 3600,
81
+ class: 'IN',
82
+ type: 'SMIMEA',
83
+ 'certificate usage': 0,
84
+ selector: 0,
85
+ 'matching type': 1,
86
+ 'certificate association data': 'ABCDEF...',
87
+ }
88
+ }
89
+
73
90
  getQuotedFields() {
74
91
  return []
75
92
  }
package/rr/soa.js CHANGED
@@ -83,6 +83,22 @@ export default class SOA extends RR {
83
83
  return 6
84
84
  }
85
85
 
86
+ getCanonical() {
87
+ return {
88
+ owner: 'example.com.',
89
+ ttl: 3600,
90
+ class: 'IN',
91
+ type: 'SOA',
92
+ mname: 'ns1.example.com.',
93
+ rname: 'admin.example.com.',
94
+ serial: 2023051001,
95
+ refresh: 7200,
96
+ retry: 3600,
97
+ expire: 1209600,
98
+ minimum: 3600,
99
+ }
100
+ }
101
+
86
102
  /****** IMPORTERS *******/
87
103
  fromBind({ bindline }) {
88
104
  // example.com TTL IN SOA mname rname serial refresh retry expire minimum
@@ -136,6 +152,20 @@ export default class SOA extends RR {
136
152
  .join('\t')} ~\n`
137
153
  }
138
154
 
155
+ getWireRdata() {
156
+ const nums = Buffer.alloc(20)
157
+ nums.writeUInt32BE(this.get('serial'), 0)
158
+ nums.writeUInt32BE(this.get('refresh'), 4)
159
+ nums.writeUInt32BE(this.get('retry'), 8)
160
+ nums.writeUInt32BE(this.get('expire'), 12)
161
+ nums.writeUInt32BE(this.get('minimum'), 16)
162
+ return Buffer.concat([
163
+ this.wirePackDomain(this.get('mname')),
164
+ this.wirePackDomain(this.get('rname')),
165
+ nums,
166
+ ])
167
+ }
168
+
139
169
  toTinydns() {
140
170
  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`
141
171
  }
package/rr/spf.js CHANGED
@@ -18,6 +18,10 @@ export default class SPF extends TXT {
18
18
  return 'Sender Policy Framework'
19
19
  }
20
20
 
21
+ getTags() {
22
+ return ['deprecated']
23
+ }
24
+
21
25
  getRdataFields(arg) {
22
26
  return ['data']
23
27
  }
@@ -30,6 +34,16 @@ export default class SPF extends TXT {
30
34
  return 99
31
35
  }
32
36
 
37
+ getCanonical() {
38
+ return {
39
+ owner: 'example.com.',
40
+ ttl: 3600,
41
+ class: 'IN',
42
+ type: 'SPF',
43
+ data: 'v=spf1 mx -all',
44
+ }
45
+ }
46
+
33
47
  /****** IMPORTERS *******/
34
48
  fromTinydns({ tinyline }) {
35
49
  // SPF via generic, :fqdn:n:rdata:ttl:timestamp:lo
package/rr/srv.js CHANGED
@@ -41,6 +41,10 @@ export default class SRV extends RR {
41
41
  return 'Service'
42
42
  }
43
43
 
44
+ getTags() {
45
+ return ['common']
46
+ }
47
+
44
48
  getRdataFields(arg) {
45
49
  return ['priority', 'weight', 'port', 'target']
46
50
  }
@@ -53,6 +57,19 @@ export default class SRV extends RR {
53
57
  return 33
54
58
  }
55
59
 
60
+ getCanonical() {
61
+ return {
62
+ owner: '_imaps._tcp.example.com.',
63
+ ttl: 3600,
64
+ class: 'IN',
65
+ type: 'SRV',
66
+ priority: 10,
67
+ weight: 10,
68
+ port: 993,
69
+ target: 'mail.example.com.',
70
+ }
71
+ }
72
+
56
73
  /****** IMPORTERS *******/
57
74
  fromTinydns({ tinyline }) {
58
75
  const str = tinyline
package/rr/sshfp.js CHANGED
@@ -46,6 +46,10 @@ export default class SSHFP extends RR {
46
46
  return 'Secure Shell Key Fingerprints'
47
47
  }
48
48
 
49
+ getTags() {
50
+ return ['security']
51
+ }
52
+
49
53
  getRdataFields() {
50
54
  return ['algorithm', 'fptype', 'fingerprint']
51
55
  }
@@ -58,6 +62,18 @@ export default class SSHFP extends RR {
58
62
  return 44
59
63
  }
60
64
 
65
+ getCanonical() {
66
+ return {
67
+ owner: 'mail.example.com.',
68
+ ttl: 3600,
69
+ class: 'IN',
70
+ type: 'SSHFP',
71
+ algorithm: 2,
72
+ fptype: 1,
73
+ fingerprint: '123456789abcdef6789abcdf6789abdf6789abcd',
74
+ }
75
+ }
76
+
61
77
  /****** IMPORTERS *******/
62
78
  fromTinydns({ tinyline }) {
63
79
  // SSHFP via generic, :fqdn:n:rdata:ttl:timestamp:lo
package/rr/svcb.js CHANGED
@@ -44,6 +44,18 @@ export default class SVCB extends RR {
44
44
  return 64
45
45
  }
46
46
 
47
+ getCanonical() {
48
+ return {
49
+ owner: '_8443._foo.api.example.com.',
50
+ ttl: 3600,
51
+ class: 'IN',
52
+ type: 'SVCB',
53
+ priority: 1,
54
+ 'target name': 'svc4.example.net.',
55
+ params: 'alpn="h2,h3"',
56
+ }
57
+ }
58
+
47
59
  /****** IMPORTERS *******/
48
60
 
49
61
  fromBind({ bindline }) {
package/rr/tlsa.js CHANGED
@@ -58,18 +58,35 @@ export default class TLSA extends RR {
58
58
  return 'TLSA certificate association'
59
59
  }
60
60
 
61
+ getTags() {
62
+ return ['security']
63
+ }
64
+
61
65
  getRdataFields(arg) {
62
66
  return ['certificate usage', 'selector', 'matching type', 'certificate association data']
63
67
  }
64
68
 
65
69
  getRFCs() {
66
- return [6698]
70
+ return [6698, 7671]
67
71
  }
68
72
 
69
73
  getTypeId() {
70
74
  return 52
71
75
  }
72
76
 
77
+ getCanonical() {
78
+ return {
79
+ owner: '_443._tcp.www.example.com.',
80
+ ttl: 3600,
81
+ class: 'IN',
82
+ type: 'TLSA',
83
+ 'certificate usage': 3,
84
+ selector: 1,
85
+ 'matching type': 1,
86
+ 'certificate association data': 'ABCDEF...',
87
+ }
88
+ }
89
+
73
90
  getQuotedFields() {
74
91
  return []
75
92
  }
package/rr/tsig.js CHANGED
@@ -25,6 +25,22 @@ export default class TSIG extends RR {
25
25
  return 250
26
26
  }
27
27
 
28
+ getCanonical() {
29
+ return {
30
+ owner: 'test.example.',
31
+ ttl: 0,
32
+ class: 'ANY',
33
+ type: 'TSIG',
34
+ 'algorithm name': 'hmac-sha256.',
35
+ 'time signed': 1620650000,
36
+ fudge: 300,
37
+ mac: 'ABCDEF...',
38
+ 'original id': 12345,
39
+ error: 0,
40
+ other: '',
41
+ }
42
+ }
43
+
28
44
  setClass(t) {
29
45
  if (t !== 'ANY') this.throwHelp('TSIG: Class is required to be ANY')
30
46
  this.set('class', t)
package/rr/txt.js CHANGED
@@ -16,18 +16,32 @@ export default class TXT extends RR {
16
16
  return 'Text'
17
17
  }
18
18
 
19
+ getTags() {
20
+ return ['common']
21
+ }
22
+
19
23
  getRdataFields(arg) {
20
24
  return ['data']
21
25
  }
22
26
 
23
27
  getRFCs() {
24
- return [1035]
28
+ return [1035, 4408, 7208, 6376]
25
29
  }
26
30
 
27
31
  getTypeId() {
28
32
  return 16
29
33
  }
30
34
 
35
+ getCanonical() {
36
+ return {
37
+ owner: 'example.com.',
38
+ ttl: 3600,
39
+ class: 'IN',
40
+ type: 'TXT',
41
+ data: 'v=spf1 mx -all',
42
+ }
43
+ }
44
+
31
45
  /****** IMPORTERS *******/
32
46
  fromTinydns({ tinyline }) {
33
47
  const str = tinyline
@@ -98,6 +112,12 @@ export default class TXT extends RR {
98
112
  return `${this.get('owner')}\t+${this.get('ttl')}\t${this.get('type')}\t'${data}' ~\n`
99
113
  }
100
114
 
115
+ getWireRdata() {
116
+ let data = this.get('data')
117
+ if (Array.isArray(data)) data = data.join('')
118
+ return packStringWire(data)
119
+ }
120
+
101
121
  toTinydns() {
102
122
  let data = this.get('data')
103
123
  if (Array.isArray(data)) data = data.join('')
@@ -127,3 +147,18 @@ function asQuotedStrings(data) {
127
147
 
128
148
  return data
129
149
  }
150
+
151
+ function packStringWire(str) {
152
+ const parts = str.match(/(.{1,255})/g)
153
+ let len = 0
154
+ for (const part of parts) len += part.length + 1
155
+
156
+ const buf = Buffer.allocUnsafe(len)
157
+ let offset = 0
158
+ for (const part of parts) {
159
+ buf.writeUInt8(part.length, offset++)
160
+ buf.write(part, offset, 'ascii')
161
+ offset += part.length
162
+ }
163
+ return buf
164
+ }
package/rr/uri.js CHANGED
@@ -75,6 +75,18 @@ export default class URI extends RR {
75
75
  return 256
76
76
  }
77
77
 
78
+ getCanonical() {
79
+ return {
80
+ owner: 'www.example.com.',
81
+ ttl: 3600,
82
+ class: 'IN',
83
+ type: 'URI',
84
+ priority: 10,
85
+ weight: 10,
86
+ target: 'http://www.example.com/',
87
+ }
88
+ }
89
+
78
90
  getQuotedFields() {
79
91
  return ['target']
80
92
  }
package/rr/wks.js CHANGED
@@ -29,6 +29,10 @@ export default class WKS extends RR {
29
29
  return 'Well Known Service'
30
30
  }
31
31
 
32
+ getTags() {
33
+ return ['obsolete']
34
+ }
35
+
32
36
  getRdataFields(arg) {
33
37
  return ['address', 'protocol', 'bit map']
34
38
  }
@@ -41,6 +45,18 @@ export default class WKS extends RR {
41
45
  return 11
42
46
  }
43
47
 
48
+ getCanonical() {
49
+ return {
50
+ owner: 'host.example.com.',
51
+ ttl: 3600,
52
+ class: 'IN',
53
+ type: 'WKS',
54
+ address: '192.0.2.1',
55
+ protocol: 'TCP',
56
+ 'bit map': 'ftp smtp',
57
+ }
58
+ }
59
+
44
60
  /****** IMPORTERS *******/
45
61
 
46
62
  fromBind({ bindline }) {