From dbb4557071e3b7dabdd5bf59bc6e736f3b79f01e Mon Sep 17 00:00:00 2001 From: Sefinek Date: Thu, 5 Feb 2026 18:01:19 +0100 Subject: [PATCH] Update index.js --- index.js | 12 ++++++++++-- scripts | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 57cf98f..56cf5d0 100644 --- a/index.js +++ b/index.js @@ -15,8 +15,10 @@ const isSpecialPurposeIP = require('./scripts/isSpecialPurposeIP.js'); const logger = require('./scripts/logger.js'); const config = require('./config.js'); const { UFW_LOG_FILE, SERVER_ID, EXTENDED_LOGS, AUTO_UPDATE_ENABLED, AUTO_UPDATE_SCHEDULE, DISCORD_WEBHOOK_ENABLED, DISCORD_WEBHOOK_URL } = config.MAIN; + const RATE_LIMIT_LOG_INTERVAL = 10 * 60 * 1000; const BUFFER_STATS_INTERVAL = 5 * 60 * 1000; +const MAX_BUFFER_SIZE = 100000; const nextRateLimitReset = () => { const now = new Date(); @@ -52,10 +54,16 @@ const reportIp = async ({ srcIp, dpt = 'N/A', proto = 'N/A', timestamp }, catego if (ABUSE_STATE.isBuffering) { if (BULK_REPORT_BUFFER.has(srcIp)) return; + + // Check buffer size limit to prevent memory overflow + if (BULK_REPORT_BUFFER.size >= MAX_BUFFER_SIZE) { + logger.warn(`Buffer full (${MAX_BUFFER_SIZE} IPs). Skipping ${srcIp} to prevent memory overflow.`); + return; + } + BULK_REPORT_BUFFER.set(srcIp, { categories, timestamp, comment }); await saveBufferToFile(); - logger.success(`Queued ${srcIp} for bulk report (collected ${BULK_REPORT_BUFFER.size} IPs)`); - return; + return logger.success(`Queued ${srcIp} for bulk report (collected ${BULK_REPORT_BUFFER.size} IPs)`); } try { diff --git a/scripts b/scripts index 43e0edf..808ed28 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 43e0edfc8ccf35d64280d90818bc052b1d16f5e4 +Subproject commit 808ed282aaa4a78faa462e5ce9170f90bc2efaa6