@nictool/dns-resource-record 1.1.3
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/.codeclimate.yml +25 -0
- package/CHANGELOG.md +253 -0
- package/DEVELOP.md +23 -0
- package/LICENSE +29 -0
- package/README.md +267 -0
- package/index.js +67 -0
- package/lib/tinydns.js +186 -0
- package/package.json +40 -0
- package/rr/a.js +65 -0
- package/rr/aaaa.js +137 -0
- package/rr/caa.js +129 -0
- package/rr/cert.js +75 -0
- package/rr/cname.js +76 -0
- package/rr/dname.js +74 -0
- package/rr/dnskey.js +117 -0
- package/rr/ds.js +104 -0
- package/rr/hinfo.js +84 -0
- package/rr/ipseckey.js +159 -0
- package/rr/key.js +73 -0
- package/rr/loc.js +216 -0
- package/rr/mx.js +86 -0
- package/rr/naptr.js +146 -0
- package/rr/ns.js +74 -0
- package/rr/nsec.js +61 -0
- package/rr/nsec3.js +99 -0
- package/rr/nsec3param.js +84 -0
- package/rr/openpgpkey.js +44 -0
- package/rr/ptr.js +65 -0
- package/rr/rrsig.js +101 -0
- package/rr/sig.js +100 -0
- package/rr/smimea.js +73 -0
- package/rr/soa.js +140 -0
- package/rr/spf.js +54 -0
- package/rr/srv.js +122 -0
- package/rr/sshfp.js +86 -0
- package/rr/tlsa.js +106 -0
- package/rr/txt.js +122 -0
- package/rr/uri.js +95 -0
- package/rr.js +291 -0
- package/test/a.js +76 -0
- package/test/aaaa.js +79 -0
- package/test/base.js +138 -0
- package/test/caa.js +104 -0
- package/test/cert.js +48 -0
- package/test/cname.js +41 -0
- package/test/dname.js +53 -0
- package/test/dnskey.js +44 -0
- package/test/ds.js +44 -0
- package/test/fake.js +26 -0
- package/test/hinfo.js +75 -0
- package/test/ipseckey.js +115 -0
- package/test/key.js +37 -0
- package/test/loc.js +71 -0
- package/test/mx.js +75 -0
- package/test/naptr.js +40 -0
- package/test/ns.js +53 -0
- package/test/nsec.js +38 -0
- package/test/nsec3.js +26 -0
- package/test/nsec3param.js +26 -0
- package/test/openpgpkey.js +35 -0
- package/test/ptr.js +54 -0
- package/test/rr.js +196 -0
- package/test/smimea.js +45 -0
- package/test/soa.js +77 -0
- package/test/spf.js +48 -0
- package/test/srv.js +81 -0
- package/test/sshfp.js +62 -0
- package/test/tinydns.js +140 -0
- package/test/tlsa.js +54 -0
- package/test/txt.js +70 -0
- package/test/uri.js +61 -0
package/.codeclimate.yml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
checks:
|
|
2
|
+
return-statements:
|
|
3
|
+
enabled: false
|
|
4
|
+
similar-code:
|
|
5
|
+
enabled: false
|
|
6
|
+
file-lines:
|
|
7
|
+
config:
|
|
8
|
+
threshold: 500
|
|
9
|
+
method-lines:
|
|
10
|
+
config:
|
|
11
|
+
threshold: 50
|
|
12
|
+
method-complexity:
|
|
13
|
+
config:
|
|
14
|
+
threshold: 10
|
|
15
|
+
|
|
16
|
+
plugins:
|
|
17
|
+
eslint:
|
|
18
|
+
enabled: true
|
|
19
|
+
channel: "eslint-8"
|
|
20
|
+
config:
|
|
21
|
+
config: ".eslintrc.yaml"
|
|
22
|
+
|
|
23
|
+
ratings:
|
|
24
|
+
paths:
|
|
25
|
+
- "**.js"
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
|
|
2
|
+
#### N.N.N - YYYY-MM-DD
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
#### 1.1.3 - 2022-05-29
|
|
6
|
+
|
|
7
|
+
- chore: publish npm package in @nictool namespace
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
#### 1.1.2 - 2022-05-28
|
|
11
|
+
|
|
12
|
+
- chore(ci): replace .release with submodule
|
|
13
|
+
- chore(ci): use GHA with shared workflows
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
#### 1.1.1 - 2022-04-28
|
|
17
|
+
|
|
18
|
+
- feat(DNSKEY): expanded algo from 1-5 to 1-16 (RFC 8624)
|
|
19
|
+
- warn if outside that range, not error
|
|
20
|
+
- feat(HINFO): added to/from tinydns
|
|
21
|
+
- test(dnskey): update fail test
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
#### 1.1.0 - 2022-04-22
|
|
25
|
+
|
|
26
|
+
- feat(tinydns): add ipv4toOctal, octalToIPv4, base64toOctal, octalToBase64
|
|
27
|
+
- feat(DNSKEY,DS,IPSECKEY,TLSA): added to/fromTinydns support
|
|
28
|
+
- feat(NAPTR): finished fromTinydns
|
|
29
|
+
- feat(bindline & tinyline): pass in opts (was only line), so defaults (serial, ttl, etc) can be passed in.
|
|
30
|
+
- fix(SSHFP): algo & fptype are 1 byte, not 2
|
|
31
|
+
- fix:(cname): fully qualify the target
|
|
32
|
+
- test: add tinydns.unpackDomainName, ipv4toOctal, octalToIPv4
|
|
33
|
+
- test(SRV): add another test case (found a bug in NicTool 2)
|
|
34
|
+
- test(IPSECKEY): expand test coverage
|
|
35
|
+
- tinydns.unpackdomain: return fqdn + length, for RRs where the FQDN is part of the byte stream
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
#### 1.0.1 - 2022-04-19
|
|
39
|
+
|
|
40
|
+
- feat(IPSECKEY): added basic support
|
|
41
|
+
- doc(README): update for ES module usage
|
|
42
|
+
- fix: call is[8|16]BitInt() correctly
|
|
43
|
+
- style: replace this.constructor with class name
|
|
44
|
+
- test: show more results in test output
|
|
45
|
+
- test(CERT): added two test cases
|
|
46
|
+
- test(KEY): added valid test
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
#### 1.0.0 - 2022-04-18
|
|
50
|
+
|
|
51
|
+
- style: move rr/index to ./rr
|
|
52
|
+
- test: add base.getRdataFields
|
|
53
|
+
- style(esm): convert from CJS to ESM (ES6 module)
|
|
54
|
+
- test: add base.getRdataFields
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
#### 0.9.9 - 2022-04-14
|
|
58
|
+
|
|
59
|
+
- feat: parser improvements (DNSKEY, HINFO, NAPTR, SOA, TLSA, TXT)
|
|
60
|
+
- CAA: more robust fromBind parser
|
|
61
|
+
- SOA: leave $TTL and $ORIGIN to dns-zone
|
|
62
|
+
- test/base: improve invalid tests, check error message against expected
|
|
63
|
+
- test/rr: update tests with expected error messages
|
|
64
|
+
- README: move some content to web links
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
#### 0.9.8 - 2022-04-07
|
|
68
|
+
|
|
69
|
+
- url updates
|
|
70
|
+
- fix: txt records
|
|
71
|
+
- feat: add index.citeRFC
|
|
72
|
+
- docs: updates
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
#### 0.9.7 - 2022-03-29
|
|
76
|
+
|
|
77
|
+
- index
|
|
78
|
+
- previousName -> previousOwner
|
|
79
|
+
- export a TYPE_MAP (id => name)
|
|
80
|
+
- isValidHostname: allow \ char
|
|
81
|
+
- add the word 'RFC' in error messages citing RFCs
|
|
82
|
+
- when rejecting hostname, show the rejected character
|
|
83
|
+
- maradns: add export support
|
|
84
|
+
- add index.citeRFC
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
#### 0.9.6 - 2022-03-27
|
|
88
|
+
|
|
89
|
+
- rr\*: rename name -> owner (not overloaded)
|
|
90
|
+
- RFC 4034: letters in DNS names are lower cased
|
|
91
|
+
- README: added definitions
|
|
92
|
+
- repo: move from msimerson -> NicTool org
|
|
93
|
+
- add macos testing
|
|
94
|
+
- add CERT, KEY, NSEC, NSEC3, NSEC3PARAM, OPENPGPKEY, SIG
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
#### 0.9.5 - 2022-03-26
|
|
98
|
+
|
|
99
|
+
- README: add docs for getRFCs()
|
|
100
|
+
- dnskey: fix copy/paste errors
|
|
101
|
+
- HINFO: add fromBind
|
|
102
|
+
- RR.owner: if owner is same as previous, suppress (when sameOwner option is set)
|
|
103
|
+
- master: NODE_ENV=cov when running coverage
|
|
104
|
+
- TXT: pass along zone_opts
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
#### 0.9.4 - 2022-03-24
|
|
108
|
+
|
|
109
|
+
- add: getComment
|
|
110
|
+
- zone_opts, for influencing output of toBind
|
|
111
|
+
- normalize hostnames to lower case
|
|
112
|
+
- add tests: fullyQualify, getFQDN
|
|
113
|
+
- AAAA
|
|
114
|
+
- compress: rewrote per RFC 5952, added tests
|
|
115
|
+
- internally store address in expanded notation
|
|
116
|
+
- fromTinydns: apply correct semantics for 'x' handling
|
|
117
|
+
- fullyQualify
|
|
118
|
+
- special handling for @
|
|
119
|
+
- consider $ORIGIN
|
|
120
|
+
- add uc hex chars to ip6 compress
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
#### 0.9.3 - 2022-03-22
|
|
124
|
+
|
|
125
|
+
- hasValidLabels: remove trailing dot, else split returns empty string
|
|
126
|
+
- rename fullyQualified -> isFullyQualified
|
|
127
|
+
- rename validHostname -> isValidHostname
|
|
128
|
+
- set('type') no longer falls back on constructor.name (didn't reliably inherit)
|
|
129
|
+
- new fns: getTinyFQDN, fullyQualify, getPrefix, getFQDN
|
|
130
|
+
- when loading RR classes, ignore files that don't end with .js
|
|
131
|
+
- rr/txt: support data as array (improves idempotency)
|
|
132
|
+
- fromTinydns: fully qualify hostnames
|
|
133
|
+
- toTinydns: strip trailing . upon export
|
|
134
|
+
- rename getCommonFields -> getPrefixFields
|
|
135
|
+
- TXT: import BIND format w/o mangling WS
|
|
136
|
+
- SPF inherits from TXT
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
#### 0.9.2 - 2022-03-18
|
|
140
|
+
|
|
141
|
+
- mx: weight -> preference
|
|
142
|
+
- ds: keytag -> key tag (consistent naming)
|
|
143
|
+
- mx: add null MX test
|
|
144
|
+
- more use of this.getRFCs in error messages
|
|
145
|
+
- added getTinydnsGeneric
|
|
146
|
+
- on `index.is*` functions which throw, use declaratively
|
|
147
|
+
- class: add NONE and ANY
|
|
148
|
+
- validHostname: allow / char
|
|
149
|
+
- use \_\_dirname to find RR mods
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
#### 0.9.1 - 2022-03-14
|
|
153
|
+
|
|
154
|
+
- TLSA, SMIMEA: add BIND support #13
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
#### 0.9.0 - 2022-03-10
|
|
158
|
+
|
|
159
|
+
- added null object instantiation
|
|
160
|
+
- added `getTypeId`, `getDescription`, `getRdataFields`, `getQuotedFields`
|
|
161
|
+
- tinydns: refactored fromTinydnsGeneric
|
|
162
|
+
- add `RR.toBind()` for most
|
|
163
|
+
- spf: corrected RFC IDs
|
|
164
|
+
- rr/\*: refactor init into RR.constructor
|
|
165
|
+
- ds,dnskey: add to/from BIND support
|
|
166
|
+
- README: significant expansion
|
|
167
|
+
- tests: more signal, less noise
|
|
168
|
+
- tests: import tests from nictool 2
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
#### 0.8.1 - 2022-03-08
|
|
172
|
+
|
|
173
|
+
- use RFC example IPs and zone names
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
#### 0.8.0 - 2022-02-01
|
|
177
|
+
|
|
178
|
+
- fromBind for: A, AAAA, CNAME, TXT, CNAME, TXT, LOC, MX, NS, SOA, PTR, SPF, SSHFP, URI, CAA, DNAME, NAPTR
|
|
179
|
+
- add fromTinydns: LOC
|
|
180
|
+
- rr/\*: add getFields
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
#### 0.7.0 - 2021-10-26
|
|
184
|
+
|
|
185
|
+
- tinydns: added octalToHex, octalToUInt16, unpackDomainName, octalToInt8
|
|
186
|
+
- AAAA: added fromTinydns, compress, expand
|
|
187
|
+
- CAA, CNAME, DNAME, SPF, SSHFP, SRV, URI: added fromTinydns
|
|
188
|
+
- add tests for getRFCs
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
#### 0.6.0 - 2021-10-25
|
|
192
|
+
|
|
193
|
+
- tinydns: added octalToChar
|
|
194
|
+
- A, MX, NS, PTR, SOA, TXT: added fromTinydns
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
#### 0.5.1 - 2021-10-25
|
|
198
|
+
|
|
199
|
+
- LOC: added toTinydns
|
|
200
|
+
- tinydns: add UInt32toOctal
|
|
201
|
+
- SRV: added support
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
#### 0.5.0 - 2021-10-24
|
|
205
|
+
|
|
206
|
+
- NAPTR: add toTinydns
|
|
207
|
+
- tinydns: remove sprintf-js dependency
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
#### 0.4.0 - 2021-10-22
|
|
211
|
+
|
|
212
|
+
- CAA, DNAME, SSHFP, URI: add toTinydns
|
|
213
|
+
- lib/tinydns: added packHex and UInt16AsOctal
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
#### 0.3.1 - 2021-10-21
|
|
217
|
+
|
|
218
|
+
- update index.js to also export RR sub classes
|
|
219
|
+
- update README examples
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
#### 0.3.0 - 2021-10-21
|
|
223
|
+
|
|
224
|
+
- add getRFCs to all RR types
|
|
225
|
+
- populate this.id with IANA type ID
|
|
226
|
+
- toBind: use tabs for exported WS
|
|
227
|
+
- CAA, DNAME, NAPTR, SSHFP, URI: add toBind, tests
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
#### 0.2.3 - 2021-10-21
|
|
231
|
+
|
|
232
|
+
- refactored classes into separate files
|
|
233
|
+
- TXT, SOA, MX, CNAME, PTR, SRV: add toBind and toTinydns
|
|
234
|
+
- SOA: add setMinimum
|
|
235
|
+
- lib/tinydns: added escapeOct & packDomainName
|
|
236
|
+
- PTR, SRV: added tests
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
#### 0.2.2 - 2021-10-20
|
|
240
|
+
|
|
241
|
+
- add tests/*
|
|
242
|
+
- A, AAAA, add toBind and toTinydns()
|
|
243
|
+
- add .release
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
#### 0.2.1 - 2021-10-16
|
|
247
|
+
|
|
248
|
+
- additional RR formats started, weakly validated
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
#### 0.2.0 - 2021-10-16
|
|
252
|
+
|
|
253
|
+
- initial release & name grab
|
package/DEVELOP.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
# Release process
|
|
3
|
+
|
|
4
|
+
In your local repo:
|
|
5
|
+
|
|
6
|
+
- make your changes
|
|
7
|
+
- git add .
|
|
8
|
+
- `.release/do.sh` {major|minor|patch}
|
|
9
|
+
- fill in the blanks in CHANGELOG.md
|
|
10
|
+
- `.release/push.sh`
|
|
11
|
+
|
|
12
|
+
Upon merge to `master`:
|
|
13
|
+
|
|
14
|
+
- the new version will be published to NPM.
|
|
15
|
+
- a GitHub release will be published.
|
|
16
|
+
- a release tag will be committed to the repo.
|
|
17
|
+
|
|
18
|
+
## Clean
|
|
19
|
+
|
|
20
|
+
`.release/cleanup.sh`
|
|
21
|
+
|
|
22
|
+
- will switch to the master branch
|
|
23
|
+
- delete the release branch
|
package/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021, Matt Simerson
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
[](https://github.com/NicTool/dns-resource-record/actions/workflows/ci.yml)
|
|
2
|
+
[](https://coveralls.io/github/NicTool/dns-resource-record?branch=master)
|
|
3
|
+
|
|
4
|
+
# dns-resource-record
|
|
5
|
+
|
|
6
|
+
DNS resource record parser, validator, importer, and exporter.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## SYNOPSIS
|
|
10
|
+
|
|
11
|
+
This module is used to:
|
|
12
|
+
|
|
13
|
+
- validate well formedness and RFC compliance of DNS resource records
|
|
14
|
+
- import RRs from:
|
|
15
|
+
- JS object
|
|
16
|
+
- JSON
|
|
17
|
+
- [BIND](https://www.isc.org/bind/) zone [file format](https://bind9.readthedocs.io/en/latest/reference.html#zone-file)
|
|
18
|
+
- tinydns [data format](https://cr.yp.to/djbdns/tinydns-data.html)
|
|
19
|
+
- export RRs to:
|
|
20
|
+
- BIND zone files
|
|
21
|
+
- tinydns data
|
|
22
|
+
- maradns
|
|
23
|
+
- JS object
|
|
24
|
+
- JSON
|
|
25
|
+
|
|
26
|
+
This package intends to import and export RFC compliant DNS resource records. Please [raise an issue](https://github.com/NicTool/dns-resource-record/issues) if you cannot pass a valid resource record or you can pass an invalid resource record.
|
|
27
|
+
|
|
28
|
+
This package is for working with _individual_ Resource Records. For working with zones of RRs, use [dns-zone](https://github.com/NicTool/dns-zone).
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## USAGE
|
|
32
|
+
|
|
33
|
+
Load the index for access to all RR types:
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
import * as RR from 'dns-resource-record'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### EXAMPLES
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
const exampleRRs = {
|
|
43
|
+
A: {
|
|
44
|
+
owner : 'test.example.com.',
|
|
45
|
+
type : 'A',
|
|
46
|
+
address: '192.0.2.127',
|
|
47
|
+
ttl : 3600,
|
|
48
|
+
},
|
|
49
|
+
AAAA: {
|
|
50
|
+
owner : 'test.example.com.',
|
|
51
|
+
type : 'AAAA',
|
|
52
|
+
address: '2605:7900:20:a::4',
|
|
53
|
+
ttl : 3600,
|
|
54
|
+
},
|
|
55
|
+
SOA: {
|
|
56
|
+
owner : 'example.com.',
|
|
57
|
+
type : 'SOA',
|
|
58
|
+
mname : 'matt.example.com.',
|
|
59
|
+
rname : 'ns1.example.com.',
|
|
60
|
+
serial : 1,
|
|
61
|
+
refresh: 7200,
|
|
62
|
+
retry : 3600,
|
|
63
|
+
expire : 1209600,
|
|
64
|
+
minimum: 3600,
|
|
65
|
+
ttl : 3600,
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
console.log(new RR.SOA(exampleRRs.SOA))
|
|
70
|
+
SOA(11) [Map] {
|
|
71
|
+
'owner' => 'example.com.',
|
|
72
|
+
'ttl' => 3600,
|
|
73
|
+
'class' => 'IN',
|
|
74
|
+
'type' => 'SOA',
|
|
75
|
+
'mname' => 'matt.example.com.',
|
|
76
|
+
'rname' => 'ns1.example.com.',
|
|
77
|
+
'serial' => 1,
|
|
78
|
+
'refresh' => 7200,
|
|
79
|
+
'retry' => 3600,
|
|
80
|
+
'expire' => 1209600,
|
|
81
|
+
'minimum' => 3600
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
console.error(e.message) // invalid RRs throw
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Validate records by passing a properly formatted JS object to the record-specific class. To validate an A record:
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
const validatedA = new RR.A(exampleRRs.A)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Manipulate the validated record using pattern named setters:
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
console.log(validatedA.toBind())
|
|
99
|
+
test.example.com. 3600 IN A 192.0.2.127
|
|
100
|
+
|
|
101
|
+
validatedA.setAddress('192.0.2.128')
|
|
102
|
+
console.log(validatedA.toBind())
|
|
103
|
+
test.example.com. 3600 IN A 192.0.2.128
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The setters are named: `set` + `Field`, where field is the resource record field name to modify. Multi-word names are camel cased, so a field named `Certificate Usage` has a setter named `setCertificateUsage`. The RFCs aren't always consistent regarding RR field names so aliases are permissible for interoperability.
|
|
107
|
+
|
|
108
|
+
## FUNCTIONS
|
|
109
|
+
|
|
110
|
+
Get the field names for each RR type with `getFields()`:
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
> import * as RR from 'dns-resource-record'
|
|
114
|
+
> new RR.A(null).getFields()
|
|
115
|
+
[ 'owner', 'ttl', 'class', 'type', 'address' ]
|
|
116
|
+
|
|
117
|
+
> new RR.PTR(null).getFields()
|
|
118
|
+
[ 'owner', 'ttl', 'class', 'type', 'dname' ]
|
|
119
|
+
|
|
120
|
+
> new RR.SSHFP(null).getFields()
|
|
121
|
+
[ 'owner', 'ttl', 'class', 'type', 'algorithm', 'fptype', 'fingerprint' ]
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Get a list of RFCs for references about each RR type:
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
> new RR.A(null).getRFCs()
|
|
128
|
+
[ 1035 ]
|
|
129
|
+
|
|
130
|
+
> new RR.SRV(null).getRFCs()
|
|
131
|
+
[ 2782 ]
|
|
132
|
+
|
|
133
|
+
> new RR.MX(null).getRFCs()
|
|
134
|
+
[ 1035, 2181, 7505 ]
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### toBind
|
|
138
|
+
|
|
139
|
+
Validate a record and export to BIND format.
|
|
140
|
+
|
|
141
|
+
```js
|
|
142
|
+
console.log(new RR.A(exampleRRs.A).toBind())
|
|
143
|
+
test.example.com 3600 IN A 192.0.2.127
|
|
144
|
+
|
|
145
|
+
console.log(new RR.AAAA(exampleRRs.AAAA).toBind())
|
|
146
|
+
test.example.com 3600 IN AAAA 2605:7900:20:a::4
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### toTinydns
|
|
150
|
+
|
|
151
|
+
Validate a record and export to tinydns format:
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
console.log(new RR.A(exampleRRs.A).toTinydns())
|
|
155
|
+
+test.example.com:192.0.2.127:3600::
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### fromTinydns toBind
|
|
159
|
+
|
|
160
|
+
Convert a tinydns line to BIND:
|
|
161
|
+
|
|
162
|
+
```js
|
|
163
|
+
console.log(new RR.CAA({
|
|
164
|
+
tinyline: ':ns1.example.com:257:\\000\\005issue"http\\072\\057\\057letsencrypt.org":3600::\n'
|
|
165
|
+
}).toBind())
|
|
166
|
+
ns1.example.com 3600 IN CAA 0 issue "http://letsencrypt.org"
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### set
|
|
170
|
+
|
|
171
|
+
The DNS validation checks can be bypassed entirely by using 'set':
|
|
172
|
+
|
|
173
|
+
```js
|
|
174
|
+
> validatedA.set('address', 'oops')
|
|
175
|
+
A(5) [Map] {
|
|
176
|
+
'owner' => 'test.example.com',
|
|
177
|
+
'ttl' => 3600,
|
|
178
|
+
'class' => 'IN',
|
|
179
|
+
'type' => 'A',
|
|
180
|
+
'address' => 'oops'
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Consider this a "running with scissors" mode.
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
## Supported Records
|
|
188
|
+
|
|
189
|
+
This module intends to include support for all current (ie, not officially deprecated) DNS RRs **and** all RRs that are in active use on the internet.
|
|
190
|
+
|
|
191
|
+
PRs are welcome, especially PRs with tests.
|
|
192
|
+
|
|
193
|
+
| **RR** | **toBind** | **toTinydns** | **fromBind** | **fromTinydns** |
|
|
194
|
+
|:---------: |:----------------:|:----------------:|:----------------:|:----------------:|
|
|
195
|
+
| **A** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
196
|
+
| **AAAA** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
197
|
+
| **CAA** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
198
|
+
| **CERT** | | | | |
|
|
199
|
+
| **CNAME** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
200
|
+
| **DNAME** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
201
|
+
| **DNSKEY** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
202
|
+
| **DS** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
203
|
+
| **HINFO** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
204
|
+
|**IPSECKEY**|:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
205
|
+
| **KEY** | | | | |
|
|
206
|
+
| **LOC** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
207
|
+
| **MX** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
208
|
+
| **NAPTR** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
209
|
+
| **NS** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
210
|
+
| **NSEC** | | | | |
|
|
211
|
+
| **NSEC3** | | | | |
|
|
212
|
+
| **NSEC3PARAM**| | | | |
|
|
213
|
+
| **OPENPGPKEY**| | | | |
|
|
214
|
+
| **PTR** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
215
|
+
| **RRSIG** | | | | |
|
|
216
|
+
| **SIG** | | | | |
|
|
217
|
+
| **SMIMEA** |:white_check_mark:| |:white_check_mark:| |
|
|
218
|
+
| **SOA** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
219
|
+
| **SPF** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
220
|
+
| **SRV** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
221
|
+
| **SSHFP** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
222
|
+
| **TLSA** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
223
|
+
| **TXT** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
224
|
+
| **URI** |:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:|
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
## TIPS
|
|
228
|
+
|
|
229
|
+
- Domain owner names are:
|
|
230
|
+
- stored fully qualified, aka absolute.
|
|
231
|
+
- normalized to lower case, because:
|
|
232
|
+
- DNS is case insensitive (see RFCs 4343, 1035, 1034)
|
|
233
|
+
- this library enforces duplicate suppression
|
|
234
|
+
- DNSSEC canonicalization (see RFC 4034)
|
|
235
|
+
- wire format for most RRs require it
|
|
236
|
+
- Master Zone File expansions exist in [dns-zone](https://github.com/NicTool/dns-zone)
|
|
237
|
+
- to{Bind|MaraDNS} output can be influenced (suppress TTL, class, relative domain names) with an options object. See it in `bin/dns-zone` in the [dns-zone](https://github.com/NicTool/dns-zone) package.
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
## SEE ALSO
|
|
241
|
+
|
|
242
|
+
- [Dictionary of DNS terms](https://nictool.github.io/web/Dictionary)
|
|
243
|
+
- [Wikipedia, List of DNS Record Types](https://en.wikipedia.org/wiki/List_of_DNS_record_types)
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
## TODO
|
|
247
|
+
|
|
248
|
+
- [x] Change all IPs to use [RFC example/doc](https://en.wikipedia.org/wiki/Reserved_IP_addresses) address space
|
|
249
|
+
- [x] change all domains to use reserved doc names
|
|
250
|
+
- [x] import tests from nictool/server/t/12_records.t
|
|
251
|
+
- [x] add defaults for empty values like TTL
|
|
252
|
+
- [x] DNSSEC RRs: DS, NSEC, NSEC3, NSEC3PARAM, RRSIG
|
|
253
|
+
- [x] CERT RRs: CERT, KEY, SIG, OPENPGPKEY
|
|
254
|
+
- [x] RFC 4034: if the type of RR is NS, MD, MF, CNAME, SOA, MB,
|
|
255
|
+
MG, MR, PTR, HINFO, MINFO, MX, RP, AFSDB, RT, SIG, PX, NXT,
|
|
256
|
+
NAPTR, KX, SRV, DNAME, A6, RRSIG, or NSEC, all uppercase
|
|
257
|
+
letters in the DNS names contained within the RDATA are replaced by the lowercase letters;
|
|
258
|
+
- [x] LOC record ingest/out isn't consistent with API
|
|
259
|
+
- [ ] export a web page for each RR type
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
## DEVELOP
|
|
263
|
+
|
|
264
|
+
- this package has no dependencies. That's no accident.
|
|
265
|
+
- this will be used by a node.js app & a browser based app, so ES modules
|
|
266
|
+
- platform independence is a goal
|
|
267
|
+
- [x] CI tests are on linux, windows, and macos
|
package/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
|
|
2
|
+
import RR from './rr.js'
|
|
3
|
+
import A from './rr/a.js'
|
|
4
|
+
import AAAA from './rr/aaaa.js'
|
|
5
|
+
import CAA from './rr/caa.js'
|
|
6
|
+
import CERT from './rr/cert.js'
|
|
7
|
+
import CNAME from './rr/cname.js'
|
|
8
|
+
import DNAME from './rr/dname.js'
|
|
9
|
+
import DNSKEY from './rr/dnskey.js'
|
|
10
|
+
import DS from './rr/ds.js'
|
|
11
|
+
import HINFO from './rr/hinfo.js'
|
|
12
|
+
import IPSECKEY from './rr/ipseckey.js'
|
|
13
|
+
import KEY from './rr/key.js'
|
|
14
|
+
import LOC from './rr/loc.js'
|
|
15
|
+
import MX from './rr/mx.js'
|
|
16
|
+
import NAPTR from './rr/naptr.js'
|
|
17
|
+
import NS from './rr/ns.js'
|
|
18
|
+
import NSEC from './rr/nsec.js'
|
|
19
|
+
import NSEC3 from './rr/nsec3.js'
|
|
20
|
+
import NSEC3PARAM from './rr/nsec3param.js'
|
|
21
|
+
import OPENPGPKEY from './rr/openpgpkey.js'
|
|
22
|
+
import PTR from './rr/ptr.js'
|
|
23
|
+
import RRSIG from './rr/rrsig.js'
|
|
24
|
+
import SIG from './rr/sig.js'
|
|
25
|
+
import SMIMEA from './rr/smimea.js'
|
|
26
|
+
import SOA from './rr/soa.js'
|
|
27
|
+
import SPF from './rr/spf.js'
|
|
28
|
+
import SRV from './rr/srv.js'
|
|
29
|
+
import SSHFP from './rr/sshfp.js'
|
|
30
|
+
import TLSA from './rr/tlsa.js'
|
|
31
|
+
import TXT from './rr/txt.js'
|
|
32
|
+
import URI from './rr/uri.js'
|
|
33
|
+
|
|
34
|
+
export default RR
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
A,
|
|
38
|
+
AAAA,
|
|
39
|
+
CAA,
|
|
40
|
+
CERT,
|
|
41
|
+
CNAME,
|
|
42
|
+
DNAME,
|
|
43
|
+
DNSKEY,
|
|
44
|
+
DS,
|
|
45
|
+
HINFO,
|
|
46
|
+
IPSECKEY,
|
|
47
|
+
KEY,
|
|
48
|
+
LOC,
|
|
49
|
+
MX,
|
|
50
|
+
NAPTR,
|
|
51
|
+
NS,
|
|
52
|
+
NSEC,
|
|
53
|
+
NSEC3,
|
|
54
|
+
NSEC3PARAM,
|
|
55
|
+
OPENPGPKEY,
|
|
56
|
+
PTR,
|
|
57
|
+
RRSIG,
|
|
58
|
+
SIG,
|
|
59
|
+
SMIMEA,
|
|
60
|
+
SSHFP,
|
|
61
|
+
SOA,
|
|
62
|
+
SPF,
|
|
63
|
+
SRV,
|
|
64
|
+
TLSA,
|
|
65
|
+
TXT,
|
|
66
|
+
URI
|
|
67
|
+
}
|