@k03mad/dns-leak 4.2.1 → 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.
@@ -25,9 +25,6 @@ jobs:
25
25
  with:
26
26
  node-version-file: '.nvmrc'
27
27
 
28
- - name: Install PNPM
29
- run: npm i pnpm -g
30
-
31
28
  - name: Run setup
32
29
  run: npm run setup
33
30
 
package/README.md CHANGED
@@ -10,21 +10,9 @@ Using API/tools:\
10
10
  ## Global
11
11
 
12
12
  ```bash
13
- pnpm i @k03mad/dns-leak -g
13
+ npm i @k03mad/dns-leak -g
14
14
  ```
15
15
 
16
16
  ```bash
17
17
  dns-leak
18
18
  ```
19
-
20
- ## API
21
-
22
- ```bash
23
- pnpm 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
@@ -1,5 +1,4 @@
1
1
  export {default as CloudPing} from './cloud-ping.js';
2
2
  export {default as IPLeak} from './ip-leak.js';
3
- export {default as IPWhois} from './ip-whois.js';
4
3
  export {default as NextDNS} from './next-dns.js';
5
4
  export {default as Wander} from './wander.js';
@@ -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.ipRequestsCacheExpireMs] ip info requests cache ttl ms for same ip
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
- ipRequestsCacheExpireMs = 3_600_000,
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._ipRequestsCacheExpireMs = ipRequestsCacheExpireMs;
32
+ this._ipRequestsCacheExpireSec = ipRequestsCacheExpireSec;
33
33
  this._requestsRps = requestsRps;
34
34
  }
35
35
 
@@ -108,7 +108,7 @@ export default class IPLeak {
108
108
  const ipEndpoint = IPLeak.endpoints.ip(ip);
109
109
 
110
110
  const {body} = await requestCache(ipEndpoint, {}, {
111
- expire: this._ipRequestsCacheExpireMs,
111
+ expire: this._ipRequestsCacheExpireSec,
112
112
  rps: this._requestsRps,
113
113
  });
114
114
 
@@ -22,7 +22,7 @@ export const info = msg => gray(msg);
22
22
  /**
23
23
  * @param {string} msg
24
24
  */
25
- export const org = msg => green(msg);
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
- flag,
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 (connection?.org) {
56
- output += `${org(connection.org)} `;
59
+ if (org) {
60
+ output += `${orgIsp(org)} `;
57
61
  }
58
62
 
59
- if (connection?.isp && !connection?.org?.includes(connection?.isp)) {
60
- if (connection?.org) {
61
- output += org('/ ');
63
+ if (isp && !org?.includes(isp)) {
64
+ if (org) {
65
+ output += orgIsp('/ ');
62
66
  }
63
67
 
64
- output += `${org(connection.isp)} `;
68
+ output += `${orgIsp(isp)} `;
65
69
  }
66
70
 
67
- if (connection?.domain) {
68
- output += info(`(${connection.domain})`);
71
+ if (ispDomain) {
72
+ output += info(`(${ispDomain})`);
69
73
  }
70
74
 
71
75
  output += '\n';
72
76
 
73
- if (flag?.emoji) {
74
- output += `${flag.emoji} `;
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 += `${org(iata)}\n`;
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 {CloudPing, IPLeak, IPWhois, NextDNS, Wander} from './api/_index.js';
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, whois, location, dnssec] = await Promise.allSettled([
15
+ const [leak, next, geoip, location, dnssec] = await Promise.allSettled([
15
16
  LeakApi.getDnsInfoMulti({isSpinnerEnabled: true}),
16
17
  NextApi.getTest(),
17
- WhoisApi.getIpInfo(),
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 WhoisApi.getIpInfo({ip});
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 (whois.value) {
48
+ if (geoip.value) {
48
49
  output.push(
49
50
  header('IP'),
50
- formatIpInfo(whois.value),
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 WhoisApi.getIpInfo({ip: next.value.ecs.replace(/\/.+/, '')});
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": "4.2.1",
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,17 +27,17 @@
27
27
  "ora": "8.0.1"
28
28
  },
29
29
  "devDependencies": {
30
- "@k03mad/eslint-config": "18.0.0",
30
+ "@k03mad/eslint-config": "19.2.0",
31
31
  "eslint": "8.56.0",
32
32
  "husky": "8.0.3"
33
33
  },
34
34
  "scripts": {
35
- "lint": "pnpm run lint:eslint",
35
+ "lint": "npm run lint:eslint",
36
36
  "lint:eslint": "eslint ./ --cache",
37
- "clean": "pnpm run clean:modules && pnpm run clean:eslint:cache",
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": "pnpm run clean && pnpm i",
40
+ "setup": "npm run clean && npm i",
41
41
  "prepare": "husky install || true"
42
42
  }
43
43
  }
@@ -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.ipRequestsCacheExpireMs] ip info requests cache ttl ms for same ip
9
- * @param {number} [opts.requestsRps] parallel requests rps
10
- */
11
- constructor({
12
- ipRequestsCacheExpireMs = 3_600_000,
13
- requestsRps = 2,
14
- } = {}) {
15
- this._ipRequestsCacheExpireMs = ipRequestsCacheExpireMs;
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._ipRequestsCacheExpireMs,
38
- rps: this._requestsRps,
39
- });
40
-
41
- return body;
42
- }
43
-
44
- }