dnscmp 0.0.3 → 0.0.5

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/README.md CHANGED
@@ -1,15 +1,27 @@
1
1
  # dnscmp
2
2
 
3
- To install dependencies:
3
+ Command-line tool for benchmarking and comparing DNS resolution times across DNS providers.
4
+
5
+ ## Usage
4
6
 
5
7
  ```bash
6
- bun install
8
+ npx dnscmp
9
+ # Cloudflare (1.1.1.1): 3.42ms
10
+ # Google (8.8.8.8): 7.81ms
11
+ # Quad9 (9.9.9.9): 12.50ms
7
12
  ```
8
13
 
9
- To run:
14
+ Results are sorted fastest-first. Each provider is tested 10 times across 3 domains (`example.com`, `example.org`, `example.net`). Providers with multiple IPs are all tested; only the fastest is shown. Providers that fail to respond show `failed`.
10
15
 
11
16
  ```bash
12
- bun run index.ts
17
+ npx dnscmp 1.1.1.1 9.9.9.9 # test specific IPs
18
+ npx dnscmp -f resolvers.txt # test from a file (one IP per line)
19
+ npx dnscmp --defaults 9.9.9.9 # default providers plus an extra IP
20
+ npx dnscmp --help # show all options
13
21
  ```
14
22
 
15
- This project was created using `bun init` in bun v1.3.11. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
23
+ ## Development
24
+
25
+ ```bash
26
+ bun run start
27
+ ```
package/dist/index.js ADDED
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
3
+ var __defProp = Object.defineProperty;
4
+ var __returnValue = (v) => v;
5
+ function __exportSetter(name, newValue) {
6
+ this[name] = __returnValue.bind(null, newValue);
7
+ }
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true,
13
+ configurable: true,
14
+ set: __exportSetter.bind(all, name)
15
+ });
16
+ };
17
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
18
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
19
+
20
+ // src/parse-file.ts
21
+ var exports_parse_file = {};
22
+ __export(exports_parse_file, {
23
+ parseFile: () => parseFile
24
+ });
25
+ import { readFile } from "node:fs/promises";
26
+ async function parseFile(filePath) {
27
+ const text = await readFile(filePath, "utf8");
28
+ const providers = [];
29
+ for (const rawLine of text.split(`
30
+ `)) {
31
+ const line = rawLine.trim();
32
+ if (line === "" || line.startsWith("#"))
33
+ continue;
34
+ const spaceIdx = line.search(/\s+/);
35
+ if (spaceIdx === -1) {
36
+ providers.push({ name: line, resolvers: [line] });
37
+ } else {
38
+ const ip = line.slice(0, spaceIdx);
39
+ const name = line.slice(spaceIdx).trim();
40
+ providers.push({ name, resolvers: [ip] });
41
+ }
42
+ }
43
+ return providers;
44
+ }
45
+ var init_parse_file = () => {};
46
+
47
+ // src/index.ts
48
+ import { dnscmp } from "@dnscmp/core";
49
+ import { parseArgs } from "node:util";
50
+ var { values, positionals } = parseArgs({
51
+ args: process.argv.slice(2),
52
+ options: {
53
+ defaults: { type: "boolean", short: "d", default: false },
54
+ file: { type: "string", short: "f" },
55
+ help: { type: "boolean", short: "h", default: false }
56
+ },
57
+ allowPositionals: true
58
+ });
59
+ if (values.help) {
60
+ process.stdout.write([
61
+ "Usage: dnscmp [options] [resolver...]",
62
+ "",
63
+ " dnscmp Test default providers",
64
+ " dnscmp 1.1.1.1 8.8.8.8 Test specific resolvers",
65
+ " dnscmp -f resolvers.txt Test resolvers from a file",
66
+ " dnscmp --defaults 9.9.9.9 Test default providers plus extra resolver(s)",
67
+ "",
68
+ "Options:",
69
+ " -d, --defaults Include default providers alongside explicit input",
70
+ " -f, --file Path to file with one resolver IP per line (optional name after whitespace)",
71
+ " -h, --help Show this help message",
72
+ ""
73
+ ].join(`
74
+ `));
75
+ process.exit(0);
76
+ }
77
+ var hasExplicitInput = positionals.length > 0 || values.file != null;
78
+ var input = [];
79
+ if (!hasExplicitInput || values.defaults) {
80
+ const { providers } = await import("@dnscmp/providers");
81
+ input.push(...providers);
82
+ }
83
+ if (values.file != null) {
84
+ const { parseFile: parseFile2 } = await Promise.resolve().then(() => (init_parse_file(), exports_parse_file));
85
+ input.push(...await parseFile2(values.file));
86
+ }
87
+ for (const ip of positionals) {
88
+ input.push({ name: ip, resolvers: [ip] });
89
+ }
90
+ var results = await dnscmp({ providers: input });
91
+ for (const { name, resolver, avg } of results) {
92
+ const value = avg === null ? "failed" : `${avg.toFixed(2)}ms`;
93
+ const label = name === resolver ? name : `${name} (${resolver})`;
94
+ process.stdout.write(`${label}: ${value}
95
+ `);
96
+ }
97
+ process.exit(0);
package/package.json CHANGED
@@ -1,27 +1,36 @@
1
1
  {
2
2
  "name": "dnscmp",
3
- "version": "0.0.3",
3
+ "description": "Command-line tool for benchmarking and comparing DNS resolution times across DNS providers.",
4
+ "version": "0.0.5",
4
5
  "type": "module",
5
- "exports": {
6
- ".": {
7
- "types": "./dist/lib.d.ts",
8
- "default": "./dist/lib.js"
9
- }
10
- },
11
6
  "bin": {
12
- "dnscmp": "dist/cli.js"
7
+ "dnscmp": "dist/index.js"
13
8
  },
14
9
  "files": [
15
10
  "dist"
16
11
  ],
12
+ "homepage": "https://github.com/oBusk/dnscmp#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/oBusk/dnscmp/issues"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/oBusk/dnscmp.git",
19
+ "directory": "packages/cli"
20
+ },
21
+ "license": "MIT",
22
+ "author": "Oscar Busk (https://github.com/oBusk)",
17
23
  "scripts": {
18
24
  "build": "bun run build.ts",
19
- "start": "bun run src/cli.ts"
25
+ "start": "bun run src/index.ts"
26
+ },
27
+ "dependencies": {
28
+ "@dnscmp/core": "0.0.1",
29
+ "@dnscmp/providers": "0.0.1",
30
+ "@dnscmp/types": "0.0.1"
20
31
  },
21
32
  "devDependencies": {
22
33
  "@types/bun": "latest",
23
- "bun-plugin-isolated-decl": "^0.2",
24
- "oxc-transform": "~0.123",
25
34
  "typescript": "^5"
26
35
  }
27
36
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Oscar Busk
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/dist/cli.js DELETED
@@ -1,37 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/lib.ts
4
- import { Resolver } from "dns/promises";
5
- var DOMAINS = ["example.com", "example.org", "example.net"];
6
- var TRIES = 10;
7
- var SERVERS = [
8
- { name: "Cloudflare", ip: "1.1.1.1" },
9
- { name: "Google", ip: "8.8.8.8" }
10
- ];
11
- async function measureAvg(ip) {
12
- const resolver = new Resolver;
13
- resolver.setServers([ip]);
14
- let total = 0;
15
- for (let i = 0;i < TRIES; i++) {
16
- for (const domain of DOMAINS) {
17
- const start = performance.now();
18
- await resolver.resolve4(domain);
19
- total += performance.now() - start;
20
- }
21
- }
22
- return total / (TRIES * DOMAINS.length);
23
- }
24
- async function dnscmp() {
25
- const results = await Promise.all(SERVERS.map(async ({ name, ip }) => ({
26
- name,
27
- ip,
28
- avg: await measureAvg(ip)
29
- })));
30
- results.sort((a, b) => a.avg - b.avg);
31
- for (const { name, ip, avg } of results) {
32
- console.log(`${name} (${ip}): ${avg.toFixed(2)}ms`);
33
- }
34
- }
35
-
36
- // src/cli.ts
37
- await dnscmp();
package/dist/lib.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function dnscmp(): Promise<void>;
package/dist/lib.js DELETED
@@ -1,35 +0,0 @@
1
- // src/lib.ts
2
- import { Resolver } from "dns/promises";
3
- var DOMAINS = ["example.com", "example.org", "example.net"];
4
- var TRIES = 10;
5
- var SERVERS = [
6
- { name: "Cloudflare", ip: "1.1.1.1" },
7
- { name: "Google", ip: "8.8.8.8" }
8
- ];
9
- async function measureAvg(ip) {
10
- const resolver = new Resolver;
11
- resolver.setServers([ip]);
12
- let total = 0;
13
- for (let i = 0;i < TRIES; i++) {
14
- for (const domain of DOMAINS) {
15
- const start = performance.now();
16
- await resolver.resolve4(domain);
17
- total += performance.now() - start;
18
- }
19
- }
20
- return total / (TRIES * DOMAINS.length);
21
- }
22
- async function dnscmp() {
23
- const results = await Promise.all(SERVERS.map(async ({ name, ip }) => ({
24
- name,
25
- ip,
26
- avg: await measureAvg(ip)
27
- })));
28
- results.sort((a, b) => a.avg - b.avg);
29
- for (const { name, ip, avg } of results) {
30
- console.log(`${name} (${ip}): ${avg.toFixed(2)}ms`);
31
- }
32
- }
33
- export {
34
- dnscmp
35
- };