@k03mad/dns-leak 4.2.0 → 5.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/.github/workflows/lint.yml +0 -3
- package/README.md +2 -2
- package/app/api/cloud-ping.js +10 -10
- package/app/api/ip-leak.js +30 -30
- package/app/api/ip-whois.js +4 -4
- package/app/api/wander.js +3 -3
- package/app/helpers/spinner.js +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Using API/tools:\
|
|
|
10
10
|
## Global
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
|
|
13
|
+
npm i @k03mad/dns-leak -g
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
```bash
|
|
@@ -20,7 +20,7 @@ dns-leak
|
|
|
20
20
|
## API
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
|
|
23
|
+
npm i @k03mad/dns-leak
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
```js
|
package/app/api/cloud-ping.js
CHANGED
|
@@ -26,29 +26,29 @@ export default class CloudPing {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* @returns {Promise<
|
|
29
|
+
* @returns {Promise<object>}
|
|
30
30
|
*/
|
|
31
|
-
async
|
|
32
|
-
const
|
|
31
|
+
async getAllLocations() {
|
|
32
|
+
const locationsEndpoint = CloudPing.endpoints.locations();
|
|
33
33
|
|
|
34
|
-
const {
|
|
34
|
+
const {body} = await request(locationsEndpoint, {}, {
|
|
35
35
|
rps: this._requestsRps,
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
return
|
|
38
|
+
return body.nodes;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* @returns {Promise<
|
|
42
|
+
* @returns {Promise<string>}
|
|
43
43
|
*/
|
|
44
|
-
async
|
|
45
|
-
const
|
|
44
|
+
async getCurrentIataCode() {
|
|
45
|
+
const testEndpoint = CloudPing.endpoints.edge();
|
|
46
46
|
|
|
47
|
-
const {
|
|
47
|
+
const {headers} = await request(testEndpoint, {}, {
|
|
48
48
|
rps: this._requestsRps,
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
return
|
|
51
|
+
return headers['x-amz-cf-pop'];
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
package/app/api/ip-leak.js
CHANGED
|
@@ -14,7 +14,7 @@ export default class IPLeak {
|
|
|
14
14
|
* @param {number} [opts.dnsRequestsWaitBeforeLastMs] dns leak multi requests wait before the last request (with all ips gathered)
|
|
15
15
|
* @param {number} [opts.dnsSessionStringLength] dns leak session string length, only works with 40 characters for now
|
|
16
16
|
* @param {number} [opts.dnsUniqStringLength] dns leak unique string length for subdomain
|
|
17
|
-
* @param {number} [opts.
|
|
17
|
+
* @param {number} [opts.ipRequestsCacheExpireSec] ip info requests cache ttl ms for same ip
|
|
18
18
|
* @param {number} [opts.requestsRps] parallel requests rps
|
|
19
19
|
*/
|
|
20
20
|
constructor({
|
|
@@ -22,14 +22,14 @@ export default class IPLeak {
|
|
|
22
22
|
dnsRequestsWaitBeforeLastMs = 2000,
|
|
23
23
|
dnsSessionStringLength = 40,
|
|
24
24
|
dnsUniqStringLength = 20,
|
|
25
|
-
|
|
25
|
+
ipRequestsCacheExpireSec = 3600,
|
|
26
26
|
requestsRps = 2,
|
|
27
27
|
} = {}) {
|
|
28
28
|
this._dnsRequestsCount = dnsRequestsCount;
|
|
29
29
|
this._dnsRequestsWaitBeforeLastMs = dnsRequestsWaitBeforeLastMs;
|
|
30
30
|
this._dnsSessionStringLength = dnsSessionStringLength;
|
|
31
31
|
this._dnsUniqStringLength = dnsUniqStringLength;
|
|
32
|
-
this.
|
|
32
|
+
this._ipRequestsCacheExpireSec = ipRequestsCacheExpireSec;
|
|
33
33
|
this._requestsRps = requestsRps;
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -37,14 +37,14 @@ export default class IPLeak {
|
|
|
37
37
|
static get endpoints() {
|
|
38
38
|
return {
|
|
39
39
|
|
|
40
|
-
/** @param {string} ip */
|
|
41
|
-
ip: ip => `https://ipleak.net/json/${ip}`,
|
|
42
|
-
|
|
43
40
|
/**
|
|
44
41
|
* @param {string} session
|
|
45
42
|
* @param {string} uniq
|
|
46
43
|
*/
|
|
47
44
|
dns: (session, uniq) => `https://${session}-${uniq}.ipleak.net/dnsdetection/`,
|
|
45
|
+
|
|
46
|
+
/** @param {string} ip */
|
|
47
|
+
ip: ip => `https://ipleak.net/json/${ip}`,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -60,18 +60,26 @@ export default class IPLeak {
|
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* @param {object} [opts]
|
|
63
|
-
* @param {string} [opts.
|
|
63
|
+
* @param {string} [opts.session]
|
|
64
|
+
* @param {boolean} [opts.isSpinnerEnabled]
|
|
64
65
|
* @returns {Promise<object>}
|
|
65
66
|
*/
|
|
66
|
-
async
|
|
67
|
-
const
|
|
67
|
+
async getDnsInfoMulti({isSpinnerEnabled, session = this._dnsSessionString} = {}) {
|
|
68
|
+
const spinnerName = 'DNS info';
|
|
69
|
+
const arrayFromLen = Array.from({length: this._dnsRequestsCount - 1});
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
expire: this._ipRequestsCacheExpireMs,
|
|
71
|
-
rps: this._requestsRps,
|
|
72
|
-
});
|
|
71
|
+
spinner.start(spinnerName, isSpinnerEnabled);
|
|
73
72
|
|
|
74
|
-
|
|
73
|
+
await Promise.all(arrayFromLen.map(async () => {
|
|
74
|
+
await this.getDnsInfoOnce({session});
|
|
75
|
+
spinner.count(spinnerName, this._dnsRequestsCount);
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
await sleep(this._dnsRequestsWaitBeforeLastMs);
|
|
79
|
+
const info = await this.getDnsInfoOnce({session});
|
|
80
|
+
|
|
81
|
+
spinner.stop(spinnerName);
|
|
82
|
+
return info;
|
|
75
83
|
}
|
|
76
84
|
|
|
77
85
|
/**
|
|
@@ -93,26 +101,18 @@ export default class IPLeak {
|
|
|
93
101
|
|
|
94
102
|
/**
|
|
95
103
|
* @param {object} [opts]
|
|
96
|
-
* @param {string} [opts.
|
|
97
|
-
* @param {boolean} [opts.isSpinnerEnabled]
|
|
104
|
+
* @param {string} [opts.ip]
|
|
98
105
|
* @returns {Promise<object>}
|
|
99
106
|
*/
|
|
100
|
-
async
|
|
101
|
-
const
|
|
102
|
-
const arrayFromLen = Array.from({length: this._dnsRequestsCount - 1});
|
|
103
|
-
|
|
104
|
-
spinner.start(spinnerName, isSpinnerEnabled);
|
|
105
|
-
|
|
106
|
-
await Promise.all(arrayFromLen.map(async () => {
|
|
107
|
-
await this.getDnsInfoOnce({session});
|
|
108
|
-
spinner.count(spinnerName, this._dnsRequestsCount);
|
|
109
|
-
}));
|
|
107
|
+
async getIpInfo({ip = ''} = {}) {
|
|
108
|
+
const ipEndpoint = IPLeak.endpoints.ip(ip);
|
|
110
109
|
|
|
111
|
-
await
|
|
112
|
-
|
|
110
|
+
const {body} = await requestCache(ipEndpoint, {}, {
|
|
111
|
+
expire: this._ipRequestsCacheExpireSec,
|
|
112
|
+
rps: this._requestsRps,
|
|
113
|
+
});
|
|
113
114
|
|
|
114
|
-
|
|
115
|
-
return info;
|
|
115
|
+
return body;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
}
|
package/app/api/ip-whois.js
CHANGED
|
@@ -5,14 +5,14 @@ export default class IPWhois {
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @param {object} [opts]
|
|
8
|
-
* @param {number} [opts.
|
|
8
|
+
* @param {number} [opts.ipRequestsCacheExpireSec] ip info requests cache ttl ms for same ip
|
|
9
9
|
* @param {number} [opts.requestsRps] parallel requests rps
|
|
10
10
|
*/
|
|
11
11
|
constructor({
|
|
12
|
-
|
|
12
|
+
ipRequestsCacheExpireSec = 3600,
|
|
13
13
|
requestsRps = 2,
|
|
14
14
|
} = {}) {
|
|
15
|
-
this.
|
|
15
|
+
this._ipRequestsCacheExpireSec = ipRequestsCacheExpireSec;
|
|
16
16
|
this._requestsRps = requestsRps;
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -34,7 +34,7 @@ export default class IPWhois {
|
|
|
34
34
|
const ipEndpoint = IPWhois.endpoints.ip(ip);
|
|
35
35
|
|
|
36
36
|
const {body} = await requestCache(ipEndpoint, {}, {
|
|
37
|
-
expire: this.
|
|
37
|
+
expire: this._ipRequestsCacheExpireSec,
|
|
38
38
|
rps: this._requestsRps,
|
|
39
39
|
});
|
|
40
40
|
|
package/app/api/wander.js
CHANGED
|
@@ -36,13 +36,13 @@ export default class Wander {
|
|
|
36
36
|
rps: this._requestsRps,
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
return {
|
|
39
|
+
return {code: 0, color: red, name: 'OFF'};
|
|
40
40
|
} catch (err) {
|
|
41
41
|
if (err.code === 'ESERVFAIL') {
|
|
42
|
-
return {
|
|
42
|
+
return {code: 1, color: green, name: 'ON'};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
return {
|
|
45
|
+
return {code: -1, color: yellow, name: 'unknown'};
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
package/app/helpers/spinner.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k03mad/dns-leak",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "DNS leak test",
|
|
5
5
|
"maintainers": [
|
|
6
6
|
"Kirill Molchanov <k03.mad@gmail.com"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"node": ">=20"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@k03mad/request": "5.4.
|
|
22
|
+
"@k03mad/request": "5.4.1",
|
|
23
23
|
"chalk": "5.3.0",
|
|
24
24
|
"country-locale-map": "1.9.0",
|
|
25
25
|
"nanoid": "5.0.4",
|
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
"ora": "8.0.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@k03mad/eslint-config": "
|
|
30
|
+
"@k03mad/eslint-config": "18.1.0",
|
|
31
31
|
"eslint": "8.56.0",
|
|
32
32
|
"husky": "8.0.3"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"lint": "
|
|
35
|
+
"lint": "npm run lint:eslint",
|
|
36
36
|
"lint:eslint": "eslint ./ --cache",
|
|
37
|
-
"clean": "
|
|
37
|
+
"clean": "npm run clean:modules && npm run clean:eslint:cache",
|
|
38
38
|
"clean:modules": "rm -rf ./node_modules || true",
|
|
39
39
|
"clean:eslint:cache": "rm -rf .eslintcache || true",
|
|
40
|
-
"setup": "
|
|
40
|
+
"setup": "npm run clean && npm i",
|
|
41
41
|
"prepare": "husky install || true"
|
|
42
42
|
}
|
|
43
43
|
}
|