@k03mad/dns-leak 3.0.0 → 3.1.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/README.md CHANGED
@@ -10,7 +10,9 @@ Using API/tools:\
10
10
 
11
11
  ```bash
12
12
  npm i @k03mad/dns-leak -g
13
+ ```
13
14
 
15
+ ```bash
14
16
  dns-leak
15
17
  ```
16
18
 
@@ -21,6 +23,7 @@ npm i @k03mad/dns-leak
21
23
  ```
22
24
 
23
25
  ```js
24
- import {CloudPing, IPLeak, IPWhois, NextDNS} from './api/_index.js';
25
- // details at ./app/api folder
26
+ import {CloudPing, IPLeak, IPWhois, NextDNS} from '@k03mad/dns-leak';
26
27
  ```
28
+
29
+ Details at [./app/api](/app/api) folder
@@ -2,4 +2,4 @@
2
2
  * @param {any} msg
3
3
  */
4
4
  // eslint-disable-next-line no-console
5
- export const log = (...msg) => msg.forEach(elem => console.log(elem));
5
+ export const log = msg => console.log(msg);
package/app/run.js CHANGED
@@ -9,7 +9,7 @@ const NextApi = new NextDNS();
9
9
  const WhoisApi = new IPWhois();
10
10
  const CloudPingApi = new CloudPing();
11
11
 
12
- const [leak, next, whois, location] = await Promise.all([
12
+ const [leak, next, whois, location] = await Promise.allSettled([
13
13
  LeakApi.getDnsInfoMulti({isSpinnerEnabled: true}),
14
14
  NextApi.getTest(),
15
15
  WhoisApi.getIpInfo(),
@@ -19,43 +19,60 @@ const [leak, next, whois, location] = await Promise.all([
19
19
  const spinnerName = 'IP info';
20
20
  spinner.start(spinnerName, true);
21
21
 
22
- const dnsIps = [...new Set([...Object.keys(leak.ip), next.resolver])];
22
+ const dnsIps = [
23
+ ...new Set([
24
+ ...Object.keys(leak.value?.ip || []),
25
+ next.value?.resolver || '',
26
+ ]),
27
+ ].filter(Boolean);
23
28
 
24
- const dnsData = await Promise.all(dnsIps.map(async ip => {
25
- const data = await WhoisApi.getIpInfo({ip});
26
- spinner.count(spinnerName, dnsIps.length);
27
- return data;
29
+ const dnsIpsInfo = await Promise.all(dnsIps.map(async ip => {
30
+ try {
31
+ const data = await WhoisApi.getIpInfo({ip});
32
+ spinner.count(spinnerName, dnsIps.length);
33
+ return data;
34
+ } catch {}
28
35
  }));
29
36
 
30
- spinner.stop(spinnerName);
37
+ const dnsIpsInfoFormatted = dnsIpsInfo
38
+ .filter(Boolean)
39
+ .sort((a, b) => a?.ip?.localeCompare(b?.ip))
40
+ .flatMap(data => formatIpInfo(data));
41
+
42
+ const output = [];
43
+
44
+ if (whois.value) {
45
+ output.push(
46
+ header('IP'),
47
+ formatIpInfo(whois.value),
48
+ );
49
+ }
50
+
51
+ if (dnsIpsInfoFormatted.length > 0) {
52
+ output.push(
53
+ header('DNS'),
54
+ ...dnsIpsInfoFormatted,
55
+ );
56
+ }
57
+
58
+ if (next.value?.ecs) {
59
+ try {
60
+ const data = await WhoisApi.getIpInfo({ip: next.value.ecs.replace(/\/.+/, '')});
61
+ data.ip += ` (${next.value.ecs})`;
31
62
 
32
- log(
33
- '',
34
- header('IP'),
35
- '',
36
- formatIpInfo(whois),
37
- '',
38
- header('DNS'),
39
- '',
40
- ...dnsData
41
- .sort((a, b) => a?.ip?.localeCompare(b?.ip))
42
- .flatMap(data => [formatIpInfo(data), '']),
43
- );
44
-
45
- if (next.ecs) {
46
- const data = await WhoisApi.getIpInfo({ip: next.ecs.replace(/\/.+/, '')});
47
- data.ip += ` (${next.ecs})`;
48
-
49
- log(
50
- header('DNS ECS'),
51
- '',
52
- formatIpInfo(data),
53
- '',
63
+ output.push(
64
+ header('DNS ECS'),
65
+ formatIpInfo(data),
66
+ );
67
+ } catch {}
68
+ }
69
+
70
+ if (location.value) {
71
+ output.push(
72
+ header('CLOUDFRONT CDN'),
73
+ formatLocationInfo(location.value),
54
74
  );
55
75
  }
56
76
 
57
- log(
58
- header('CLOUDFRONT CDN'),
59
- '',
60
- formatLocationInfo(location),
61
- );
77
+ spinner.stop(spinnerName);
78
+ log(`\n${output.join('\n\n')}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k03mad/dns-leak",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "DNS leak test",
5
5
  "maintainers": [
6
6
  "Kirill Molchanov <k03.mad@gmail.com"