From ce1b231dc87c062dee1cf9f229e9a9b9f80b3e56 Mon Sep 17 00:00:00 2001 From: Sefinek Date: Thu, 19 Dec 2024 15:40:28 +0100 Subject: [PATCH] Add `SERVER_IDENTIFIER` --- default.config.js | 12 ++++++++---- index.js | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/default.config.js b/default.config.js index e68f7e6..2765a57 100644 --- a/default.config.js +++ b/default.config.js @@ -1,15 +1,19 @@ exports.MAIN = { + // Server LOG_FILE: '/var/log/ufw.log', CACHE_FILE: '/tmp/ufw-abuseipdb-reporter.cache', + SERVER_IDENTIFIER: null, + // Reporting ABUSEIPDB_API_KEY: '', - GITHUB_REPO: 'https://github.com/sefinek/UFW-AbuseIPDB-Reporter', - REPORT_INTERVAL: 12 * 60 * 60 * 1000, // 12h + + // Project + GITHUB_REPO: 'https://github.com/sefinek/UFW-AbuseIPDB-Reporter', }; -exports.REPORT_COMMENT = (timestamp, srcIp, dstIp, proto, spt, dpt, ttl, len, tos) => { - return `Blocked by UFW (${proto} on ${dpt}) +exports.REPORT_COMMENT = (timestamp, srcIp, dstIp, proto, spt, dpt, ttl, len, tos, serverName) => { + return `Blocked by UFW ${serverName ? `on ${serverName} ` : ''}[${dpt}/${proto?.toLowerCase()}] Source port: ${spt} TTL: ${ttl || 'N/A'} Packet length: ${len || 'N/A'} diff --git a/index.js b/index.js index ac5c3ee..0617b58 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ const log = require('./utils/log.js'); const axios = require('./services/axios.js'); const config = require('./config.js'); const { version } = require('./package.json'); -const { LOG_FILE, ABUSEIPDB_API_KEY } = config.MAIN; +const { LOG_FILE, ABUSEIPDB_API_KEY, SERVER_IDENTIFIER } = config.MAIN; let fileOffset = 0; @@ -71,9 +71,9 @@ const processLogLine = async line => { } const categories = config.DETERMINE_CATEGORIES(proto, dpt); - const comment = config.REPORT_COMMENT(match.timestamp, srcIp, match.dstIp, proto, match.spt, dpt, match.ttl, match.len, match.tos); + const comment = config.REPORT_COMMENT(match.timestamp, srcIp, match.dstIp, proto, match.spt, dpt, match.ttl, match.len, match.tos, SERVER_IDENTIFIER); - log(0, `Reporting IP ${srcIp} (${proto} ${dpt}) with categories ${categories}`); + log(0, `Reporting IP ${srcIp} (${proto} ${dpt}) with categories: ${categories}`); if (await reportToAbuseIpDb(srcIp, categories, comment)) { markIpAsReported(srcIp);