@roflsec/fail2scan 0.0.9 → 0.0.10

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.
Files changed (2) hide show
  1. package/bin/daemon.js +7 -20
  2. package/package.json +1 -1
package/bin/daemon.js CHANGED
@@ -5,28 +5,15 @@ 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
- // -------------------- IPGeolocation --------------------
10
- let getGeo = async (ip) => null;
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 }));
10
+ const geoApi = new IPGeolocationAPI(process.env.IPGEO_API_KEY, true);
11
+ const getGeo = async (ip) => {
12
+ return new Promise((resolve, reject) => {
13
+ geoApi.getGeolocation(resolve, { ip, fields: "geo,time_zone,currency,asn,security" });
14
+ });
15
+ };
15
16
 
16
- getGeo = async (ip) => {
17
- try {
18
- const params = new GeolocationParams({ apiKey: process.env.IPGEO_API_KEY });
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
- }
30
17
 
31
18
  // -------------------- CLI / CONFIG --------------------
32
19
  const argv = process.argv.slice(2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roflsec/fail2scan",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Fail2Scan daemon - watches fail2ban logs and scans banned IPs using nmap, dig and whois.",
5
5
  "bin": {
6
6
  "fail2scan-daemon": "./bin/daemon.js"