@roflsec/fail2scan 0.0.8 → 0.0.9
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 +15 -10
- package/package.json +1 -1
package/bin/daemon.js
CHANGED
|
@@ -8,18 +8,23 @@ require('dotenv').config({ quiet:true})
|
|
|
8
8
|
|
|
9
9
|
// -------------------- IPGeolocation --------------------
|
|
10
10
|
let getGeo = async (ip) => null;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const GeolocationParams = require("ip-geolocation-api-javascript-sdk
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
getGeo = (ip) => {
|
|
17
|
-
|
|
18
|
-
const params = new GeolocationParams();
|
|
11
|
+
|
|
12
|
+
if (process.env.IPGEO_API_KEY) {
|
|
13
|
+
const { IPGeolocationAPI, GeolocationParams } = require("ip-geolocation-api-javascript-sdk");
|
|
14
|
+
const geoApi = new IPGeolocationAPI(new GeolocationParams({ apiKey: process.env.IPGEO_API_KEY }));
|
|
15
|
+
|
|
16
|
+
getGeo = async (ip) => {
|
|
17
|
+
try {
|
|
18
|
+
const params = new GeolocationParams({ apiKey: process.env.IPGEO_API_KEY });
|
|
19
19
|
params.setIPAddress(ip);
|
|
20
20
|
params.setFields("geo,time_zone,currency,asn,security");
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
|
|
22
|
+
return await new Promise((resolve, reject) => {
|
|
23
|
+
geoApi.getGeolocation(resolve, reject, params);
|
|
24
|
+
});
|
|
25
|
+
} catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
23
28
|
};
|
|
24
29
|
}
|
|
25
30
|
|