This commit is contained in:
Sefinek committed 2025-01-18 15:29:40 +01:00
1 parent 39ce553892
commit 699354b85a
6 files changed
+25 -21

No files matched your search

+2 -2
View File
@@ -1,5 +1,5 @@
const fs = require('node:fs');
const { CACHE_FILE, REPORT_INTERVAL } = require('../config.js').MAIN;
const { CACHE_FILE, IP_REPORT_COOLDOWN } = require('../config.js').MAIN;
const log = require('../utils/log.js');
const reportedIPs = new Map();
@@ -22,7 +22,7 @@ const saveReportedIPs = () => fs.writeFileSync(CACHE_FILE, Array.from(reportedIP
const isIPReportedRecently = ip => {
const reportedTime = reportedIPs.get(ip);
return reportedTime && (Date.now() / 1000 - reportedTime < REPORT_INTERVAL / 1000);
return reportedTime && (Date.now() / 1000 - reportedTime < IP_REPORT_COOLDOWN / 1000);
};
const markIPAsReported = ip => reportedIPs.set(ip, Math.floor(Date.now() / 1000));
-10
View File
@@ -1,10 +0,0 @@
const ipaddr = require('ipaddr.js');
module.exports = ip => {
const range = ipaddr.parse(ip).range();
return [
'unspecified', 'multicast', 'linkLocal', 'loopback', 'reserved', 'benchmarking',
'amt', 'broadcast', 'carrierGradeNat', 'private', 'as112', 'uniqueLocal',
'ipv4Mapped', 'rfc6145', '6to4', 'teredo', 'as112v6', 'orchid2', 'droneRemoteIdProtocolEntityTags',
].includes(range);
};
+3 -2
View File
@@ -1,6 +1,7 @@
const os = require('node:os');
const axios = require('./axios.js');
const isLocalIP = require('./isLocalIP.js');
const isLocalIP = require('../utils/isLocalIP.js');
const { MAIN } = require('../config.js');
const ipAddressList = new Set();
@@ -34,7 +35,7 @@ const fetchIPAddress = async () => {
(async () => {
await fetchIPAddress();
setInterval(fetchIPAddress, 25 * 1000);
setInterval(fetchIPAddress, MAIN.REFRESHING_IP_ADDRESS);
// console.debug(ipAddressList);
})();