0.1.2
This commit is contained in:
1 parent
d5921f19e7
commit
5320952ccb
8 files changed
+47
-49
No files matched your search
+4
-4
@@ -1,12 +1,12 @@
|
||||
const fs = require('node:fs');
|
||||
const { existsSync, readFileSync, writeFileSync } = require('node:fs');
|
||||
const { CACHE_FILE, IP_REPORT_COOLDOWN } = require('../config.js').MAIN;
|
||||
const log = require('../utils/log.js');
|
||||
|
||||
const reportedIPs = new Map();
|
||||
|
||||
const loadReportedIPs = () => {
|
||||
if (fs.existsSync(CACHE_FILE)) {
|
||||
fs.readFileSync(CACHE_FILE, 'utf8')
|
||||
if (existsSync(CACHE_FILE)) {
|
||||
readFileSync(CACHE_FILE, 'utf8')
|
||||
.split('\n')
|
||||
.forEach(line => {
|
||||
const [ip, time] = line.split(' ');
|
||||
@@ -18,7 +18,7 @@ const loadReportedIPs = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const saveReportedIPs = () => fs.writeFileSync(CACHE_FILE, Array.from(reportedIPs).map(([ip, time]) => `${ip} ${time}`).join('\n'), 'utf8');
|
||||
const saveReportedIPs = () => writeFileSync(CACHE_FILE, Array.from(reportedIPs).map(([ip, time]) => `${ip} ${time}`).join('\n'), 'utf8');
|
||||
|
||||
const isIPReportedRecently = ip => {
|
||||
const reportedTime = reportedIPs.get(ip);
|
||||
|
||||
Reference in new issue
Block a user