Update scripts

This commit is contained in:
Sefinek committed 2025-04-29 07:34:14 +02:00
1 parent b33442435d
commit 41f9e1e242
2 files changed
+13 -13

No files matched your search

+12 -12
View File
@@ -49,15 +49,12 @@ const checkRateLimit = async () => {
const reportIp = async ({ srcIp, dpt = 'N/A', proto = 'N/A', id, timestamp }, categories, comment) => { const reportIp = async ({ srcIp, dpt = 'N/A', proto = 'N/A', id, timestamp }, categories, comment) => {
if (!srcIp) return log('Missing source IP (srcIp)', 3); if (!srcIp) return log('Missing source IP (srcIp)', 3);
if (getServerIPs().includes(srcIp)) return;
if (isIPReportedRecently(srcIp)) return;
await checkRateLimit(); await checkRateLimit();
if (ABUSE_STATE.isBuffering) { if (ABUSE_STATE.isBuffering) {
if (BULK_REPORT_BUFFER.has(srcIp)) return; if (BULK_REPORT_BUFFER.has(srcIp)) return;
BULK_REPORT_BUFFER.set(srcIp, { categories, timestamp, comment }); BULK_REPORT_BUFFER.set(srcIp, { categories, timestamp, comment });
saveBufferToFile(); await saveBufferToFile();
log(`Queued ${srcIp} for bulk report (collected ${BULK_REPORT_BUFFER.size} IPs)`, 1); log(`Queued ${srcIp} for bulk report (collected ${BULK_REPORT_BUFFER.size} IPs)`, 1);
return; return;
} }
@@ -80,14 +77,17 @@ const reportIp = async ({ srcIp, dpt = 'N/A', proto = 'N/A', id, timestamp }, ca
ABUSE_STATE.sentBulk = false; ABUSE_STATE.sentBulk = false;
LAST_RATELIMIT_LOG = Date.now(); LAST_RATELIMIT_LOG = Date.now();
RATELIMIT_RESET = nextRateLimitReset(); RATELIMIT_RESET = nextRateLimitReset();
log(`Daily AbuseIPDB limit reached. Buffering reports until ${RATELIMIT_RESET.toISOString()}`); log(`Daily AbuseIPDB limit reached. Buffering reports until ${RATELIMIT_RESET.toISOString()}`, 0, true);
} }
if (!BULK_REPORT_BUFFER.has(srcIp)) { if (BULK_REPORT_BUFFER.has(srcIp)) {
BULK_REPORT_BUFFER.set(srcIp, { timestamp, categories, comment }); log(`${srcIp} is already in buffer, skipping`);
saveBufferToFile(); return;
log(`Queued ${srcIp} for bulk report due to rate limit`, 1);
} }
BULK_REPORT_BUFFER.set(srcIp, { timestamp, categories, comment });
await saveBufferToFile();
log(`Queued ${srcIp} for bulk report due to rate limit`);
} else { } else {
log(`Failed to report ${srcIp} [${dpt}/${proto}]; ${err.response?.data?.errors ? JSON.stringify(err.response.data.errors) : err.message}`, status === 429 ? 0 : 3); log(`Failed to report ${srcIp} [${dpt}/${proto}]; ${err.response?.data?.errors ? JSON.stringify(err.response.data.errors) : err.message}`, status === 429 ? 0 : 3);
} }
@@ -136,15 +136,15 @@ const processLogLine = async (line, test = false) => {
if (await reportIp(data, categories, comment)) { if (await reportIp(data, categories, comment)) {
markIPAsReported(srcIp); markIPAsReported(srcIp);
saveReportedIPs(); await saveReportedIPs();
} }
}; };
(async () => { (async () => {
log(`${repoFullUrl} - v${version} | Author: ${authorEmailWebsite}`); log(`${repoFullUrl} - v${version} | Author: ${authorEmailWebsite}`);
loadReportedIPs(); await loadReportedIPs();
loadBufferFromFile(); await loadBufferFromFile();
if (BULK_REPORT_BUFFER.size > 0 && !ABUSE_STATE.isLimited) { if (BULK_REPORT_BUFFER.size > 0 && !ABUSE_STATE.isLimited) {
log(`Found ${BULK_REPORT_BUFFER.size} IPs in buffer after restart. Sending bulk report...`); log(`Found ${BULK_REPORT_BUFFER.size} IPs in buffer after restart. Sending bulk report...`);
+1 -1
Submodule scripts updated: a1b09d47d3...e153b104b5.