@roflsec/fail2scan 0.0.9 → 0.0.11
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/bin/daemon.js +11 -22
- package/package.json +1 -1
package/bin/daemon.js
CHANGED
|
@@ -5,28 +5,18 @@ const { execFile, spawn } = require('child_process');
|
|
|
5
5
|
const { promisify } = require('util');
|
|
6
6
|
const execFileP = promisify(execFile);
|
|
7
7
|
require('dotenv').config({ quiet:true})
|
|
8
|
+
const IPGeolocationAPI = require("ip-geolocation-api-javascript-sdk");
|
|
8
9
|
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
params.setIPAddress(ip);
|
|
20
|
-
params.setFields("geo,time_zone,currency,asn,security");
|
|
21
|
-
|
|
22
|
-
return await new Promise((resolve, reject) => {
|
|
23
|
-
geoApi.getGeolocation(resolve, reject, params);
|
|
24
|
-
});
|
|
25
|
-
} catch {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
10
|
+
// ----------- Geo setup (fixed) -----------
|
|
11
|
+
const geoApi = new IPGeolocationAPI(process.env.IPGEO_API_KEY, true);
|
|
12
|
+
const getGeo = async (ip) => {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
geoApi.getGeolocation(
|
|
15
|
+
(res) => resolve(res),
|
|
16
|
+
{ ip, fields: "geo,time_zone,currency,asn,security" }
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
30
20
|
|
|
31
21
|
// -------------------- CLI / CONFIG --------------------
|
|
32
22
|
const argv = process.argv.slice(2);
|
|
@@ -70,7 +60,6 @@ const STATE=loadState();
|
|
|
70
60
|
|
|
71
61
|
// -------------------- IP extraction --------------------
|
|
72
62
|
function extractIpFromLine(line){
|
|
73
|
-
// garde ton extracteur d’origine (IPv4 + IPv6)
|
|
74
63
|
const v4 = line.match(/\b(?:\d{1,3}\.){3}\d{1,3}\b/);
|
|
75
64
|
if(v4&&v4[0]) return v4[0];
|
|
76
65
|
const v6 = line.match(/\b([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}\b/);
|