@nictool/dns-resource-record 1.2.2 → 1.2.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/package.json +11 -6
  3. package/rr/a.js +1 -3
  4. package/rr/aaaa.js +1 -3
  5. package/rr/cname.js +1 -3
  6. package/rr/dname.js +1 -3
  7. package/rr/ipseckey.js +2 -4
  8. package/rr/mx.js +1 -3
  9. package/rr/srv.js +1 -3
  10. package/rr.js +12 -3
  11. package/.codeclimate.yml +0 -25
  12. package/.github/FUNDING.yml +0 -3
  13. package/.github/workflows/ci.yml +0 -43
  14. package/.github/workflows/codeql.yml +0 -14
  15. package/.github/workflows/publish.yml +0 -16
  16. package/.gitmodules +0 -3
  17. package/.prettierrc.yml +0 -3
  18. package/DEVELOP.md +0 -9
  19. package/eslint.config.mjs +0 -41
  20. package/test/a.js +0 -75
  21. package/test/aaaa.js +0 -86
  22. package/test/base.js +0 -148
  23. package/test/caa.js +0 -111
  24. package/test/cert.js +0 -48
  25. package/test/cname.js +0 -40
  26. package/test/dname.js +0 -57
  27. package/test/dnskey.js +0 -45
  28. package/test/ds.js +0 -45
  29. package/test/fake.js +0 -34
  30. package/test/hinfo.js +0 -80
  31. package/test/https.js +0 -56
  32. package/test/ipseckey.js +0 -141
  33. package/test/key.js +0 -36
  34. package/test/loc.js +0 -75
  35. package/test/mx.js +0 -78
  36. package/test/naptr.js +0 -47
  37. package/test/ns.js +0 -56
  38. package/test/nsec.js +0 -37
  39. package/test/nsec3.js +0 -47
  40. package/test/nsec3param.js +0 -23
  41. package/test/nxt.js +0 -37
  42. package/test/openpgpkey.js +0 -85
  43. package/test/ptr.js +0 -56
  44. package/test/rr.js +0 -212
  45. package/test/smimea.js +0 -51
  46. package/test/soa.js +0 -99
  47. package/test/spf.js +0 -51
  48. package/test/srv.js +0 -101
  49. package/test/sshfp.js +0 -69
  50. package/test/svcb.js +0 -56
  51. package/test/tinydns.js +0 -163
  52. package/test/tlsa.js +0 -63
  53. package/test/txt.js +0 -82
  54. package/test/uri.js +0 -65
package/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ Notable changes to this project are documented in this file.
4
4
 
5
5
  #### Unreleased
6
6
 
7
+ ### [1.2.3] - 2025-04-14
8
+
9
+ - test(\*): fully qualify node modules
10
+ - feat(rr.isIPv?): added regexes to validate format
11
+ - dep(node:{net|util): remove, for browser compatiblity
12
+ - doc(CONTRIBUTORS.md): added
13
+ - ci: disable codeql schedule (#45)
14
+
7
15
  ### [1.2.2] - 2024-11-17
8
16
 
9
17
  - dep(eslint): update to v9 & config
@@ -300,7 +308,8 @@ Notable changes to this project are documented in this file.
300
308
  [1.1.5]: https://github.com/NicTool/dns-resource-record/releases/tag/1.1.5
301
309
  [1.1.6]: https://github.com/NicTool/dns-resource-record/releases/tag/1.1.6
302
310
  [1.1.8]: https://github.com/NicTool/dns-resource-record/releases/tag/1.1.8
303
- [1.2.1]: https://github.com/NicTool/dns-resource-record/releases/tag/1.2.1
304
- [1.2.2]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.2.2
305
311
  [1.1.7]: https://github.com/NicTool/dns-resource-record/releases/tag/1.1.7
306
312
  [1.2.0]: https://github.com/NicTool/dns-resource-record/releases/tag/1.2.0
313
+ [1.2.1]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.2.1
314
+ [1.2.2]: https://github.com/NicTool/dns-resource-record/releases/tag/1.2.2
315
+ [1.2.3]: https://github.com/NicTool/dns-resource-record/releases/tag/v1.2.3
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@nictool/dns-resource-record",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "DNS Resource Records",
5
5
  "main": "index.js",
6
- "file": [
6
+ "files": [
7
7
  "lib",
8
8
  "rr",
9
9
  "CHANGELOG.md",
@@ -13,7 +13,7 @@
13
13
  "scripts": {
14
14
  "format:check": "npm run prettier; npm run lint",
15
15
  "format": "npm run prettier -- --write && npm run lint --fix",
16
- "lint": "npx eslint@9 **/*.js",
16
+ "lint": "npx eslint **/*.js",
17
17
  "lint:fix": "npm run lint -- --fix",
18
18
  "prettier": "npx prettier --ignore-path .gitignore --check .",
19
19
  "prettier:fix": "npx prettier --ignore-path .gitignore --write .",
@@ -45,9 +45,14 @@
45
45
  },
46
46
  "homepage": "https://github.com/NicTool/dns-resource-record#readme",
47
47
  "devDependencies": {
48
- "@eslint/js": "^9.15.0",
48
+ "@eslint/js": "^10.0.0",
49
49
  "eslint": "^9.15.0",
50
- "globals": "^15.12.0",
51
- "mocha": "^10.8.2"
50
+ "globals": "^16.0.0",
51
+ "mocha": "^11.2.2"
52
+ },
53
+ "prettier": {
54
+ "semi": false,
55
+ "singleQuote": true,
56
+ "trailingComma": "all"
52
57
  }
53
58
  }
package/rr/a.js CHANGED
@@ -1,5 +1,3 @@
1
- import net from 'node:net'
2
-
3
1
  import RR from '../rr.js'
4
2
 
5
3
  export default class A extends RR {
@@ -10,7 +8,7 @@ export default class A extends RR {
10
8
  /****** Resource record specific setters *******/
11
9
  setAddress(val) {
12
10
  if (!val) this.throwHelp('A: address is required')
13
- if (!net.isIPv4(val)) this.throwHelp('A address must be IPv4')
11
+ if (!this.isIPv4(val)) this.throwHelp('A address must be IPv4')
14
12
  this.set('address', val)
15
13
  }
16
14
 
package/rr/aaaa.js CHANGED
@@ -1,5 +1,3 @@
1
- import net from 'node:net'
2
-
3
1
  import RR from '../rr.js'
4
2
  import * as TINYDNS from '../lib/tinydns.js'
5
3
 
@@ -11,7 +9,7 @@ export default class AAAA extends RR {
11
9
  /****** Resource record specific setters *******/
12
10
  setAddress(val) {
13
11
  if (!val) this.throwHelp('AAAA: address is required')
14
- if (!net.isIPv6(val)) this.throwHelp(`AAAA: address must be IPv6 (${val})`)
12
+ if (!this.isIPv6(val)) this.throwHelp(`AAAA: address must be IPv6 (${val})`)
15
13
 
16
14
  this.set('address', this.expand(val.toLowerCase())) // lower case: RFC 5952
17
15
  }
package/rr/cname.js CHANGED
@@ -1,5 +1,3 @@
1
- import net from 'node:net'
2
-
3
1
  import RR from '../rr.js'
4
2
 
5
3
  export default class CNAME extends RR {
@@ -14,7 +12,7 @@ export default class CNAME extends RR {
14
12
 
15
13
  if (!val) this.throwHelp('CNAME: cname is required')
16
14
 
17
- if (net.isIPv4(val) || net.isIPv6(val))
15
+ if (this.isIPv4(val) || this.isIPv6(val))
18
16
  this.throwHelp(`CNAME: cname must be a FQDN: RFC 2181`)
19
17
 
20
18
  if (!this.isFullyQualified('CNAME', 'cname', val)) return
package/rr/dname.js CHANGED
@@ -1,5 +1,3 @@
1
- import net from 'node:net'
2
-
3
1
  import RR from '../rr.js'
4
2
  import * as TINYDNS from '../lib/tinydns.js'
5
3
 
@@ -12,7 +10,7 @@ export default class DNAME extends RR {
12
10
  setTarget(val) {
13
11
  if (!val) this.throwHelp('DNAME: target is required')
14
12
 
15
- if (net.isIPv4(val) || net.isIPv6(val))
13
+ if (this.isIPv4(val) || this.isIPv6(val))
16
14
  this.throwHelp(`DNAME: target must be a domain name`)
17
15
 
18
16
  this.isFullyQualified('DNAME', 'target', val)
package/rr/ipseckey.js CHANGED
@@ -1,5 +1,3 @@
1
- import net from 'node:net'
2
-
3
1
  import RR from '../rr.js'
4
2
 
5
3
  import * as TINYDNS from '../lib/tinydns.js'
@@ -39,10 +37,10 @@ export default class IPSECKEY extends RR {
39
37
  if (val !== '.') throw gwErr
40
38
  break
41
39
  case 1:
42
- if (!net.isIPv4(val)) throw gwErr
40
+ if (!this.isIPv4(val)) throw gwErr
43
41
  break
44
42
  case 2:
45
- if (!net.isIPv6(val)) throw gwErr
43
+ if (!this.isIPv6(val)) throw gwErr
46
44
  break
47
45
  }
48
46
 
package/rr/mx.js CHANGED
@@ -1,5 +1,3 @@
1
- import net from 'node:net'
2
-
3
1
  import RR from '../rr.js'
4
2
 
5
3
  export default class MX extends RR {
@@ -18,7 +16,7 @@ export default class MX extends RR {
18
16
  setExchange(val) {
19
17
  if (!val) this.throwHelp('MX: exchange is required')
20
18
 
21
- if (net.isIPv4(val) || net.isIPv6(val))
19
+ if (this.isIPv4(val) || this.isIPv6(val))
22
20
  this.throwHelp(`MX: exchange must be a FQDN`)
23
21
 
24
22
  this.isFullyQualified('MX', 'exchange', val)
package/rr/srv.js CHANGED
@@ -1,5 +1,3 @@
1
- import net from 'node:net'
2
-
3
1
  import RR from '../rr.js'
4
2
  import * as TINYDNS from '../lib/tinydns.js'
5
3
 
@@ -30,7 +28,7 @@ export default class SRV extends RR {
30
28
  setTarget(val) {
31
29
  if (!val) this.throwHelp(`SRV: target is required`)
32
30
 
33
- if (net.isIPv4(val) || net.isIPv6(val))
31
+ if (this.isIPv4(val) || this.isIPv6(val))
34
32
  this.throwHelp(`SRV: target must be a FQDN`)
35
33
 
36
34
  this.isFullyQualified('SRV', 'target', val)
package/rr.js CHANGED
@@ -1,5 +1,3 @@
1
- import util from 'node:util'
2
-
3
1
  export default class RR extends Map {
4
2
  constructor(opts) {
5
3
  super()
@@ -128,7 +126,7 @@ export default class RR extends Map {
128
126
  if (this.constructor.name === 'RR') throw new Error(e)
129
127
 
130
128
  const example = this.getCanonical
131
- ? `Example ${this.constructor.name}:\n${util.inspect(this.getCanonical(), { depth: null })}\n\n`
129
+ ? `Example ${this.constructor.name}:\n${this.getCanonical()}\n\n`
132
130
  : `${this.constructor.name} records have the fields: ${this.getFields().join(', ')}\n\n`
133
131
 
134
132
  throw new Error(`${e}\n\n${example}${this.citeRFC()}\n`)
@@ -313,6 +311,17 @@ export default class RR extends Map {
313
311
  )
314
312
  }
315
313
 
314
+ isIPv4(string) {
315
+ // https://stackoverflow.com/questions/5284147/validating-ipv4-addresses-with-regexp
316
+ return /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/.test(string)
317
+ }
318
+
319
+ isIPv6(string) {
320
+ return /^(?:(?:[a-fA-F\d]{1,4}:){7}(?:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,2}|:)|(?:[a-fA-F\d]{1,4}:){4}(?:(?::[a-fA-F\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,3}|:)|(?:[a-fA-F\d]{1,4}:){3}(?:(?::[a-fA-F\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,4}|:)|(?:[a-fA-F\d]{1,4}:){2}(?:(?::[a-fA-F\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,5}|:)|(?:[a-fA-F\d]{1,4}:){1}(?:(?::[a-fA-F\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,6}|:)|(?::(?:(?::[a-fA-F\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,7}|:)))(?:%[0-9a-zA-Z]{1,})?$/gm.test(
321
+ string,
322
+ )
323
+ }
324
+
316
325
  toBind(zone_opts) {
317
326
  return `${this.getPrefix(zone_opts)}\t${this.getRdataFields()
318
327
  .map((f) => this.getQuoted(f))
package/.codeclimate.yml DELETED
@@ -1,25 +0,0 @@
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'
@@ -1,3 +0,0 @@
1
- # These are supported funding model platforms
2
-
3
- github: msimerson
@@ -1,43 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- pull_request:
6
-
7
- env:
8
- CI: true
9
-
10
- jobs:
11
- lint:
12
- uses: NicTool/.github/.github/workflows/lint.yml@main
13
-
14
- coverage:
15
- uses: NicTool/.github/.github/workflows/coverage.yml@main
16
- secrets: inherit
17
-
18
- test:
19
- needs: get-lts
20
- runs-on: ${{ matrix.os }}
21
- strategy:
22
- matrix:
23
- os: [ubuntu-latest, windows-latest, macos-latest]
24
- node-version: ${{ fromJson(needs.get-lts.outputs.active) }}
25
- fail-fast: false
26
- steps:
27
- - uses: actions/checkout@v4
28
- - uses: actions/setup-node@v4
29
- name: Node ${{ matrix.node-version }} on ${{ matrix.os }}
30
- with:
31
- node-version: ${{ matrix.node-version }}
32
- - run: npm install
33
- - run: npm test
34
-
35
- get-lts:
36
- needs: lint
37
- runs-on: ubuntu-latest
38
- steps:
39
- - id: get
40
- uses: msimerson/node-lts-versions@v1
41
- outputs:
42
- lts: ${{ steps.get.outputs.lts }}
43
- active: ${{ steps.get.outputs.active }}
@@ -1,14 +0,0 @@
1
- name: CodeQL
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- pull_request:
7
- # The branches below must be a subset of the branches above
8
- branches: [main]
9
- schedule:
10
- - cron: '18 7 * * 4'
11
-
12
- jobs:
13
- codeql:
14
- uses: NicTool/.github/.github/workflows/codeql.yml@main
@@ -1,16 +0,0 @@
1
- name: publish
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- paths:
8
- - package.json
9
-
10
- env:
11
- CI: true
12
-
13
- jobs:
14
- publish:
15
- uses: NicTool/.github/.github/workflows/publish.yml@main
16
- secrets: inherit
package/.gitmodules DELETED
@@ -1,3 +0,0 @@
1
- [submodule ".release"]
2
- path = .release
3
- url = https://github.com/msimerson/.release
package/.prettierrc.yml DELETED
@@ -1,3 +0,0 @@
1
- trailingComma: 'all'
2
- semi: false
3
- singleQuote: true
package/DEVELOP.md DELETED
@@ -1,9 +0,0 @@
1
- # Release process
2
-
3
- In your local repo:
4
-
5
- ```sh
6
- git submodule update --init --recursive
7
- ```
8
-
9
- Read and follow the instructions in .release/README.md
package/eslint.config.mjs DELETED
@@ -1,41 +0,0 @@
1
- import globals from 'globals'
2
- import path from 'node:path'
3
- import { fileURLToPath } from 'node:url'
4
- import js from '@eslint/js'
5
- import { FlatCompat } from '@eslint/eslintrc'
6
-
7
- const __filename = fileURLToPath(import.meta.url)
8
- const __dirname = path.dirname(__filename)
9
- const compat = new FlatCompat({
10
- baseDirectory: __dirname,
11
- recommendedConfig: js.configs.recommended,
12
- allConfig: js.configs.all,
13
- })
14
-
15
- export default [
16
- {
17
- languageOptions: {
18
- ecmaVersion: 'latest',
19
- globals: {
20
- ...globals.node,
21
- ...globals.browser,
22
- ...globals.mocha,
23
- },
24
- sourceType: 'module',
25
- },
26
-
27
- rules: {
28
- // 'no-undef': [ 'warn' ],
29
- 'no-unused-vars': [
30
- 'error',
31
- {
32
- args: 'none',
33
- },
34
- ],
35
-
36
- 'dot-notation': 'error',
37
- 'prefer-const': 'warn',
38
- },
39
- },
40
- js.configs.recommended,
41
- ]
package/test/a.js DELETED
@@ -1,75 +0,0 @@
1
- import A from '../rr/a.js'
2
- import * as base from './base.js'
3
-
4
- const defaults = { class: 'IN', ttl: 3600, type: 'A', address: '192.0.2.127' }
5
-
6
- const validRecords = [
7
- {
8
- ...defaults,
9
- owner: 'test.example.com.',
10
- testB: 'test.example.com.\t3600\tIN\tA\t192.0.2.127\n',
11
- testT: '+test.example.com:192.0.2.127:3600::\n',
12
- },
13
- {
14
- ...defaults,
15
- owner: 'test.example.com.',
16
- ttl: 2147483647,
17
- testB: 'test.example.com.\t2147483647\tIN\tA\t192.0.2.127\n',
18
- testT: '+test.example.com:192.0.2.127:2147483647::\n',
19
- },
20
- {
21
- ...defaults,
22
- owner: 'a.',
23
- ttl: 86400,
24
- testB: 'a.\t86400\tIN\tA\t192.0.2.127\n',
25
- testT: '+a:192.0.2.127:86400::\n',
26
- },
27
- {
28
- ...defaults,
29
- owner: '*.example.com.',
30
- testB: '*.example.com.\t3600\tIN\tA\t192.0.2.127\n',
31
- testT: '+*.example.com:192.0.2.127:3600::\n',
32
- },
33
- ]
34
-
35
- const invalidRecords = [
36
- { ...defaults, owner: '', msg: /RFC/ },
37
- { ...defaults, owner: 'something*', msg: /fully/ },
38
- { ...defaults, owner: 'some*thing', msg: /fully/ },
39
- { ...defaults, owner: '*something', msg: /fully/ },
40
- { ...defaults, owner: 'something.*', msg: /fully/ },
41
- { ...defaults, address: 'hosts.not.valid.here', msg: /address must be IPv4/ },
42
- { ...defaults, address: '', msg: /address is required/ },
43
- { ...defaults, address: undefined, msg: /address is required/ },
44
- { ...defaults, address: '1.x.2.3', msg: /address must be IPv4/ },
45
- { ...defaults, address: '.1.2.3', msg: /address must be IPv4/ },
46
- { ...defaults, type: '', msg: /type is required/ },
47
- { ...defaults, type: undefined, msg: /type is required/ },
48
- { ...defaults, ttl: '', msg: /TTL must be numeric/ },
49
- { ...defaults, ttl: -299, msg: /TTL must be a 32-bit integer/ },
50
- { ...defaults, ttl: 2147483648, msg: /TTL must be a 32-bit integer/ },
51
- ]
52
-
53
- // copy invalid properties to a valid object
54
- for (let i = 0; i < invalidRecords.length; i++) {
55
- const temp = JSON.parse(JSON.stringify(validRecords[0]))
56
- Object.assign(temp, invalidRecords[i])
57
- invalidRecords[i] = temp
58
- }
59
-
60
- describe('A record', function () {
61
- base.valid(A, validRecords)
62
- base.invalid(A, invalidRecords)
63
-
64
- base.getDescription(A)
65
- base.getRFCs(A, validRecords[0])
66
- base.getRdataFields(A, ['address'])
67
- base.getFields(A, ['address'])
68
- base.getTypeId(A, 1)
69
-
70
- base.toBind(A, validRecords)
71
- base.toTinydns(A, validRecords)
72
-
73
- base.fromBind(A, validRecords)
74
- base.fromTinydns(A, validRecords)
75
- })
package/test/aaaa.js DELETED
@@ -1,86 +0,0 @@
1
- import assert from 'assert'
2
-
3
- import * as base from './base.js'
4
- import AAAA from '../rr/aaaa.js'
5
-
6
- const defaults = { class: 'IN', ttl: 3600, type: 'AAAA' }
7
-
8
- const validRecords = [
9
- {
10
- ...defaults,
11
- owner: 'test.example.com.',
12
- address: '2001:0db8:0020:000a:0000:0000:0000:0004',
13
- testB: 'test.example.com.\t3600\tIN\tAAAA\t2001:db8:20:a::4\n',
14
- testT:
15
- ':test.example.com:28:\\040\\001\\015\\270\\000\\040\\000\\012\\000\\000\\000\\000\\000\\000\\000\\004:3600::\n',
16
- },
17
- ]
18
-
19
- const invalidRecords = [
20
- {
21
- ...defaults,
22
- owner: 'test.example.com.',
23
- address: '192.0.2.204',
24
- msg: /address must be IPv6/,
25
- },
26
- ]
27
-
28
- describe('AAAA record', function () {
29
- base.valid(AAAA, validRecords)
30
- base.invalid(AAAA, invalidRecords)
31
-
32
- base.getDescription(AAAA)
33
- base.getRFCs(AAAA, validRecords[0])
34
- base.getFields(AAAA, ['address'])
35
- base.getTypeId(AAAA, 28)
36
-
37
- base.toBind(AAAA, validRecords)
38
- base.toTinydns(AAAA, validRecords)
39
-
40
- base.fromBind(AAAA, validRecords)
41
- base.fromTinydns(AAAA, validRecords)
42
-
43
- for (const val of validRecords) {
44
- it(`imports tinydns AAAA (generic) record (${val.owner})`, async function () {
45
- const r = new AAAA({ tinyline: val.testT })
46
- if (process.env.DEBUG) console.dir(r)
47
- for (const f of ['owner', 'address', 'ttl']) {
48
- assert.deepStrictEqual(
49
- r.get(f),
50
- val[f],
51
- `${f}: ${r.get(f)} !== ${val[f]}`,
52
- )
53
- }
54
- })
55
- }
56
-
57
- const tests = [
58
- { e: '2001:0db8:0020:000a:0000:0000:0000:0004', c: '2001:db8:20:a::4' },
59
- { e: '0000:0000:0000:0000:0000:0000:0000:0000', c: '::' },
60
- { e: '0000:0000:0000:0000:0000:0000:0000:0001', c: '::1' },
61
- { e: '2001:0db8:0000:0000:0000:0000:0002:0001', c: '2001:db8::2:1' },
62
- { e: '2001:0db8:0000:0001:0001:0001:0001:0001', c: '2001:db8:0:1:1:1:1:1' },
63
- {
64
- e: '2001:0DB8:0000:0000:0008:0800:200C:417A',
65
- c: '2001:DB8::8:800:200C:417A',
66
- },
67
- ]
68
-
69
- describe('compress', function () {
70
- const r = new AAAA(null)
71
- for (const t of tests) {
72
- it(`compresses IPv6 address (${t.e})`, function () {
73
- assert.equal(r.compress(t.e), t.c)
74
- })
75
- }
76
- })
77
-
78
- describe('expand', function () {
79
- const r = new AAAA(null)
80
- for (const t of tests) {
81
- it(`expands IPv6 address (${t.c})`, function () {
82
- assert.equal(r.expand(t.c), t.e)
83
- })
84
- }
85
- })
86
- })