@hackthedev/dsync-ipsec 1.0.3 → 1.0.5

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/index.mjs +7 -1
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -21,7 +21,8 @@ export default class dSyncIPSec {
21
21
  "localhost"
22
22
  ],
23
23
  //
24
- checkCache = null
24
+ checkCache = null,
25
+ setCache = null
25
26
  } = {}) {
26
27
 
27
28
  this.blockBogon = blockBogon;
@@ -40,6 +41,7 @@ export default class dSyncIPSec {
40
41
  this.blockedCountriesByCode = blockedCountryCodes;
41
42
 
42
43
  this.checkCache = checkCache;
44
+ this.setCache = setCache;
43
45
  }
44
46
 
45
47
  updateRule({
@@ -167,6 +169,10 @@ export default class dSyncIPSec {
167
169
  let ipRequest = await fetch(`https://api.ipapi.is/?q=${ip}`);
168
170
  if (ipRequest.status === 200) {
169
171
  let ipData = await ipRequest.json();
172
+
173
+ // possibility to set cache
174
+ if(this.setCache && typeof this.setCache === "function") await this.setCache(ip, ipData);
175
+
170
176
  return ipData;
171
177
  } else {
172
178
  return {error: "Failed to fetch IP data"};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hackthedev/dsync-ipsec",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "IP Based Security Library against Abuse",
5
5
  "license": "ISC",
6
6
  "author": "",