diff --git a/config.default.js b/config.default.js index 3d50d68..9dbcf28 100644 --- a/config.default.js +++ b/config.default.js @@ -13,6 +13,7 @@ exports.MAIN = { /* --------------------------- Reports --------------------------- */ ABUSEIPDB_API_KEY: '', // https://www.abuseipdb.com/account/api IP_REPORT_COOLDOWN: 12 * 60 * 60 * 1000, // Minimum time between reports of the same IP. Must be >= 15 minutes. Do not set too low values, as it would waste API quota due to daily rate limits. + IGNORED_PORTS: [], // Destination ports to never report. Useful when running a BitTorrent client on the same machine, as peers connecting to that port would otherwise be falsely reported as port scanners. Example: [12345, 51413] /* --------------------------- Automatic Updates --------------------------- */ AUTO_UPDATE_ENABLED: false, // Set to true to enable automatic updates via "git pull", false to disable. This option is discouraged due to potential future incompatibilities. Enable it only if you actively monitor the server and want the latest version. diff --git a/index.js b/index.js index ee5ba5a..4a25408 100644 --- a/index.js +++ b/index.js @@ -15,7 +15,7 @@ const { repoSlug, repoUrl } = require('./scripts/repo.js'); const isSpecialPurposeIP = require('./scripts/isSpecialPurposeIP.js'); const { initWhitelist, isWhitelisted } = require('./scripts/services/whitelist.js'); const logger = require('./scripts/logger.js'); -const { UFW_LOG_FILE, SERVER_ID, EXTENDED_LOGS, AUTO_UPDATE_ENABLED, AUTO_UPDATE_SCHEDULE, DISCORD_WEBHOOK_ENABLED, DISCORD_WEBHOOK_URL } = config.MAIN; +const { UFW_LOG_FILE, SERVER_ID, EXTENDED_LOGS, AUTO_UPDATE_ENABLED, AUTO_UPDATE_SCHEDULE, DISCORD_WEBHOOK_ENABLED, DISCORD_WEBHOOK_URL, IGNORED_PORTS } = config.MAIN; const RATE_LIMIT_LOG_INTERVAL = 10 * 60 * 1000; const BUFFER_STATS_INTERVAL = 5 * 60 * 1000; @@ -138,6 +138,11 @@ const processLogLine = async (line, test = false) => { return; } + if (Array.isArray(IGNORED_PORTS) && IGNORED_PORTS.includes(Number(dpt))) { + if (EXTENDED_LOGS) logger.info(`Skipping ignored port: PROTO=${proto?.toLowerCase()} SRC=${srcIp} DPT=${dpt} ID=${data.id}`); + return; + } + if (test) return data; // Report