@k03mad/dns-leak 5.0.0 → 6.0.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 +0 -12
- package/app/api/_index.js +0 -1
- package/app/helpers/text.js +20 -16
- package/app/run.js +9 -8
- package/package.json +3 -3
- package/app/api/ip-whois.js +0 -44
package/README.md
CHANGED
|
@@ -16,15 +16,3 @@ npm i @k03mad/dns-leak -g
|
|
|
16
16
|
```bash
|
|
17
17
|
dns-leak
|
|
18
18
|
```
|
|
19
|
-
|
|
20
|
-
## API
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm i @k03mad/dns-leak
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
```js
|
|
27
|
-
import {CloudPing, IPLeak, IPWhois, NextDNS} from '@k03mad/dns-leak';
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Details at [./app/api](/app/api) folder
|
package/app/api/_index.js
CHANGED
package/app/helpers/text.js
CHANGED
|
@@ -22,7 +22,7 @@ export const info = msg => gray(msg);
|
|
|
22
22
|
/**
|
|
23
23
|
* @param {string} msg
|
|
24
24
|
*/
|
|
25
|
-
export const
|
|
25
|
+
export const orgIsp = msg => green(msg);
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* @param {string} msg
|
|
@@ -31,19 +31,23 @@ export const address = msg => blue(msg);
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* @param {object} [ipInfo]
|
|
34
|
-
* @param {object} [ipInfo.connection]
|
|
35
|
-
* @param {object} [ipInfo.flag]
|
|
36
34
|
* @param {string} [ipInfo.city]
|
|
37
35
|
* @param {string} [ipInfo.country]
|
|
36
|
+
* @param {string} [ipInfo.emoji]
|
|
38
37
|
* @param {string} [ipInfo.ip]
|
|
38
|
+
* @param {string} [ipInfo.isp]
|
|
39
|
+
* @param {string} [ipInfo.ispDomain]
|
|
40
|
+
* @param {string} [ipInfo.org]
|
|
39
41
|
* @param {string} [ipInfo.region]
|
|
40
42
|
*/
|
|
41
43
|
export const formatIpInfo = ({
|
|
42
44
|
city,
|
|
43
|
-
connection,
|
|
44
45
|
country,
|
|
45
|
-
|
|
46
|
+
emoji,
|
|
46
47
|
ip,
|
|
48
|
+
isp,
|
|
49
|
+
ispDomain,
|
|
50
|
+
org,
|
|
47
51
|
region,
|
|
48
52
|
} = {}) => {
|
|
49
53
|
let output = '';
|
|
@@ -52,26 +56,26 @@ export const formatIpInfo = ({
|
|
|
52
56
|
output += `${address(ip)}\n`;
|
|
53
57
|
}
|
|
54
58
|
|
|
55
|
-
if (
|
|
56
|
-
output += `${
|
|
59
|
+
if (org) {
|
|
60
|
+
output += `${orgIsp(org)} `;
|
|
57
61
|
}
|
|
58
62
|
|
|
59
|
-
if (
|
|
60
|
-
if (
|
|
61
|
-
output +=
|
|
63
|
+
if (isp && !org?.includes(isp)) {
|
|
64
|
+
if (org) {
|
|
65
|
+
output += orgIsp('/ ');
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
output += `${
|
|
68
|
+
output += `${orgIsp(isp)} `;
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
if (
|
|
68
|
-
output += info(`(${
|
|
71
|
+
if (ispDomain) {
|
|
72
|
+
output += info(`(${ispDomain})`);
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
output += '\n';
|
|
72
76
|
|
|
73
|
-
if (
|
|
74
|
-
output += `${
|
|
77
|
+
if (emoji) {
|
|
78
|
+
output += `${emoji} `;
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
output += [
|
|
@@ -95,7 +99,7 @@ export const formatLocationInfo = ({city, country, iata}) => {
|
|
|
95
99
|
let output = '';
|
|
96
100
|
|
|
97
101
|
if (iata) {
|
|
98
|
-
output += `${
|
|
102
|
+
output += `${orgIsp(iata)}\n`;
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
if (country) {
|
package/app/run.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {ip2geo} from '@k03mad/ip2geo';
|
|
4
|
+
|
|
5
|
+
import {CloudPing, IPLeak, NextDNS, Wander} from './api/_index.js';
|
|
4
6
|
import {log} from './helpers/log.js';
|
|
5
7
|
import * as spinner from './helpers/spinner.js';
|
|
6
8
|
import {formatIpInfo, formatLocationInfo, header} from './helpers/text.js';
|
|
7
9
|
|
|
8
10
|
const LeakApi = new IPLeak();
|
|
9
11
|
const NextApi = new NextDNS();
|
|
10
|
-
const WhoisApi = new IPWhois();
|
|
11
12
|
const CloudPingApi = new CloudPing();
|
|
12
13
|
const WanderApi = new Wander();
|
|
13
14
|
|
|
14
|
-
const [leak, next,
|
|
15
|
+
const [leak, next, geoip, location, dnssec] = await Promise.allSettled([
|
|
15
16
|
LeakApi.getDnsInfoMulti({isSpinnerEnabled: true}),
|
|
16
17
|
NextApi.getTest(),
|
|
17
|
-
|
|
18
|
+
ip2geo(),
|
|
18
19
|
CloudPingApi.getCurrentLocation(),
|
|
19
20
|
WanderApi.checkDNSSEC(),
|
|
20
21
|
]);
|
|
@@ -31,7 +32,7 @@ const dnsIps = [
|
|
|
31
32
|
|
|
32
33
|
const dnsIpsInfo = await Promise.all(dnsIps.map(async ip => {
|
|
33
34
|
try {
|
|
34
|
-
const data = await
|
|
35
|
+
const data = await ip2geo(ip);
|
|
35
36
|
spinner.count(spinnerName, dnsIps.length);
|
|
36
37
|
return data;
|
|
37
38
|
} catch {}
|
|
@@ -44,10 +45,10 @@ const dnsIpsInfoFormatted = dnsIpsInfo
|
|
|
44
45
|
|
|
45
46
|
const output = [];
|
|
46
47
|
|
|
47
|
-
if (
|
|
48
|
+
if (geoip.value) {
|
|
48
49
|
output.push(
|
|
49
50
|
header('IP'),
|
|
50
|
-
formatIpInfo(
|
|
51
|
+
formatIpInfo(geoip.value),
|
|
51
52
|
);
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -60,7 +61,7 @@ if (dnsIpsInfoFormatted.length > 0) {
|
|
|
60
61
|
|
|
61
62
|
if (next.value?.ecs) {
|
|
62
63
|
try {
|
|
63
|
-
const data = await
|
|
64
|
+
const data = await ip2geo(next.value.ecs.replace(/\/.+/, ''));
|
|
64
65
|
data.ip += ` (${next.value.ecs})`;
|
|
65
66
|
|
|
66
67
|
output.push(
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k03mad/dns-leak",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "DNS leak test",
|
|
5
5
|
"maintainers": [
|
|
6
6
|
"Kirill Molchanov <k03.mad@gmail.com"
|
|
7
7
|
],
|
|
8
|
-
"main": "app/api/_index.js",
|
|
9
8
|
"bin": {
|
|
10
9
|
"dns-leak": "app/run.js"
|
|
11
10
|
},
|
|
@@ -19,6 +18,7 @@
|
|
|
19
18
|
"node": ">=20"
|
|
20
19
|
},
|
|
21
20
|
"dependencies": {
|
|
21
|
+
"@k03mad/ip2geo": "2.1.0",
|
|
22
22
|
"@k03mad/request": "5.4.1",
|
|
23
23
|
"chalk": "5.3.0",
|
|
24
24
|
"country-locale-map": "1.9.0",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"ora": "8.0.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@k03mad/eslint-config": "
|
|
30
|
+
"@k03mad/eslint-config": "19.2.0",
|
|
31
31
|
"eslint": "8.56.0",
|
|
32
32
|
"husky": "8.0.3"
|
|
33
33
|
},
|
package/app/api/ip-whois.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {requestCache} from '@k03mad/request';
|
|
2
|
-
|
|
3
|
-
/** */
|
|
4
|
-
export default class IPWhois {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @param {object} [opts]
|
|
8
|
-
* @param {number} [opts.ipRequestsCacheExpireSec] ip info requests cache ttl ms for same ip
|
|
9
|
-
* @param {number} [opts.requestsRps] parallel requests rps
|
|
10
|
-
*/
|
|
11
|
-
constructor({
|
|
12
|
-
ipRequestsCacheExpireSec = 3600,
|
|
13
|
-
requestsRps = 2,
|
|
14
|
-
} = {}) {
|
|
15
|
-
this._ipRequestsCacheExpireSec = ipRequestsCacheExpireSec;
|
|
16
|
-
this._requestsRps = requestsRps;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** */
|
|
20
|
-
static get endpoints() {
|
|
21
|
-
return {
|
|
22
|
-
|
|
23
|
-
/** @param {string} ip */
|
|
24
|
-
ip: ip => `https://ipwho.is/${ip}`,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @param {object} [opts]
|
|
30
|
-
* @param {string} [opts.ip]
|
|
31
|
-
* @returns {Promise<object>}
|
|
32
|
-
*/
|
|
33
|
-
async getIpInfo({ip = ''} = {}) {
|
|
34
|
-
const ipEndpoint = IPWhois.endpoints.ip(ip);
|
|
35
|
-
|
|
36
|
-
const {body} = await requestCache(ipEndpoint, {}, {
|
|
37
|
-
expire: this._ipRequestsCacheExpireSec,
|
|
38
|
-
rps: this._requestsRps,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
return body;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
}
|