@k03mad/dns-leak 3.0.1 → 3.2.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
@@ -4,7 +4,8 @@ Using API/tools:\
4
4
  — [ipleak.net](https://airvpn.org/forums/topic/14737-api)\
5
5
  — [ipwhois.io](https://ipwhois.io/documentation)\
6
6
  — [cloudping.cloud](https://www.cloudping.cloud/cdn)\
7
- — [nextdns.io](https://test.nextdns.io/)
7
+ — [nextdns.io](https://test.nextdns.io/)\
8
+ — [wander.science](https://wander.science/projects/dns/dnssec-resolver-test/)
8
9
 
9
10
  ## Global
10
11
 
@@ -0,0 +1,49 @@
1
+ import {request} from '@k03mad/request';
2
+ import chalk from 'chalk';
3
+
4
+ const {green, red, yellow} = chalk;
5
+
6
+ /** */
7
+ export default class Wander {
8
+
9
+ /**
10
+ * @param {object} [opts]
11
+ * @param {number} [opts.requestsRps] parallel requests rps
12
+ */
13
+ constructor({
14
+ requestsRps = 2,
15
+ } = {}) {
16
+ this._requestsRps = requestsRps;
17
+ }
18
+
19
+ /** */
20
+ get _endpoints() {
21
+ return {
22
+
23
+ /** */
24
+ sigfail: () => 'https://sigfail.rsa2048-sha256.ippacket.stream/noerror.png',
25
+ };
26
+ }
27
+
28
+ /**
29
+ * @returns {Promise<object>}
30
+ */
31
+ async checkDNSSEC() {
32
+ const testEndpoint = this._endpoints.sigfail();
33
+
34
+ try {
35
+ await request(testEndpoint, {}, {
36
+ rps: this._requestsRps,
37
+ });
38
+
39
+ return {name: 'OFF', code: 0, color: red};
40
+ } catch (err) {
41
+ if (err.code === 'ESERVFAIL') {
42
+ return {name: 'ON', code: 1, color: green};
43
+ }
44
+
45
+ return {name: 'unknown', code: -1, color: yellow};
46
+ }
47
+ }
48
+
49
+ }
package/app/api/_index.js CHANGED
@@ -2,3 +2,4 @@ export {default as CloudPing} from './CloudPing.js';
2
2
  export {default as IPLeak} from './IPLeak.js';
3
3
  export {default as IPWhois} from './IPWhois.js';
4
4
  export {default as NextDNS} from './NextDNS.js';
5
+ export {default as Wander} from './Wander.js';
@@ -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
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import {CloudPing, IPLeak, IPWhois, NextDNS} from './api/_index.js';
2
+
3
+ import {CloudPing, IPLeak, IPWhois, NextDNS, Wander} from './api/_index.js';
3
4
  import {log} from './helpers/log.js';
4
5
  import * as spinner from './helpers/spinner.js';
5
6
  import {formatIpInfo, formatLocationInfo, header} from './helpers/text.js';
@@ -8,54 +9,80 @@ const LeakApi = new IPLeak();
8
9
  const NextApi = new NextDNS();
9
10
  const WhoisApi = new IPWhois();
10
11
  const CloudPingApi = new CloudPing();
12
+ const WanderApi = new Wander();
11
13
 
12
- const [leak, next, whois, location] = await Promise.all([
14
+ const [leak, next, whois, location, dnssec] = await Promise.allSettled([
13
15
  LeakApi.getDnsInfoMulti({isSpinnerEnabled: true}),
14
16
  NextApi.getTest(),
15
17
  WhoisApi.getIpInfo(),
16
18
  CloudPingApi.getCurrentLocation(),
19
+ WanderApi.checkDNSSEC(),
17
20
  ]);
18
21
 
19
22
  const spinnerName = 'IP info';
20
23
  spinner.start(spinnerName, true);
21
24
 
22
- const dnsIps = [...new Set([...Object.keys(leak.ip), next.resolver])];
25
+ const dnsIps = [
26
+ ...new Set([
27
+ ...Object.keys(leak.value?.ip || []),
28
+ next.value?.resolver || '',
29
+ ]),
30
+ ].filter(Boolean);
23
31
 
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;
32
+ const dnsIpsInfo = await Promise.all(dnsIps.map(async ip => {
33
+ try {
34
+ const data = await WhoisApi.getIpInfo({ip});
35
+ spinner.count(spinnerName, dnsIps.length);
36
+ return data;
37
+ } catch {}
28
38
  }));
29
39
 
30
- spinner.stop(spinnerName);
40
+ const dnsIpsInfoFormatted = dnsIpsInfo
41
+ .filter(Boolean)
42
+ .sort((a, b) => a?.ip?.localeCompare(b?.ip))
43
+ .flatMap(data => formatIpInfo(data));
44
+
45
+ const output = [];
46
+
47
+ if (whois.value) {
48
+ output.push(
49
+ header('IP'),
50
+ formatIpInfo(whois.value),
51
+ );
52
+ }
53
+
54
+ if (dnsIpsInfoFormatted.length > 0) {
55
+ output.push(
56
+ header('DNS'),
57
+ ...dnsIpsInfoFormatted,
58
+ );
59
+ }
60
+
61
+ if (next.value?.ecs) {
62
+ try {
63
+ const data = await WhoisApi.getIpInfo({ip: next.value.ecs.replace(/\/.+/, '')});
64
+ data.ip += ` (${next.value.ecs})`;
65
+
66
+ output.push(
67
+ header('DNS ECS'),
68
+ formatIpInfo(data),
69
+ );
70
+ } catch {}
71
+ }
31
72
 
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
- '',
73
+ if (dnssec.value?.name) {
74
+ output.push(
75
+ header('DNSSEC'),
76
+ dnssec.value.color(dnssec.value.name),
54
77
  );
55
78
  }
56
79
 
57
- log(
58
- header('CLOUDFRONT CDN'),
59
- '',
60
- formatLocationInfo(location),
61
- );
80
+ if (location.value) {
81
+ output.push(
82
+ header('CLOUDFRONT CDN'),
83
+ formatLocationInfo(location.value),
84
+ );
85
+ }
86
+
87
+ spinner.stop(spinnerName);
88
+ 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.1",
3
+ "version": "3.2.0",
4
4
  "description": "DNS leak test",
5
5
  "maintainers": [
6
6
  "Kirill Molchanov <k03.mad@gmail.com"