@hackthedev/dsync-ipsec 1.0.3 → 1.0.4
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/index.mjs +6 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -22,6 +22,7 @@ export default class dSyncIPSec {
|
|
|
22
22
|
],
|
|
23
23
|
//
|
|
24
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"};
|