From 87ba156f0341642ab66000bbef9b41eb81e7e52b Mon Sep 17 00:00:00 2001 From: Sefinek Date: Sat, 22 Mar 2025 23:42:29 +0100 Subject: [PATCH] Update --- config.default.js | 16 +++++++--------- index.js | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/config.default.js b/config.default.js index 8ff943a..11ec5c6 100644 --- a/config.default.js +++ b/config.default.js @@ -20,23 +20,21 @@ exports.MAIN = { }; -/** - * Generates a report submission to AbuseIPDB. - * @returns {string} A formatted string report. - */ -exports.REPORT_COMMENT = ({ date, srcIp, dstIp, proto, spt, dpt, In, Out, mac, len, ttl, id, tos, prec, res, window, urgp, syn }, fullLog, serverName) => - `Blocked by UFW ${serverName ? `on ${serverName} ` : ''}[${dpt || 'N/A'}/${proto?.toLowerCase() || 'N/A'}] +// Generates a report submission to AbuseIPDB. +const serverId = this.MAIN.SERVER_ID && this.MAIN.SERVER_ID !== 'null' ? `on ${this.MAIN.SERVER_ID} ` : ''; +exports.REPORT_COMMENT = ({ date, srcIp, dstIp, proto, spt, dpt, In, Out, mac, len, ttl, id, tos, prec, res, window, urgp, syn }, fullLog) => + `Blocked by UFW ${serverId}[${dpt || 'N/A'}/${proto?.toLowerCase() || 'N/A'}] Source port: ${spt || 'N/A'} TTL: ${ttl || 'N/A'} Packet length: ${len || 'N/A'} TOS: ${tos || 'N/A'} This report was generated by: -https://github.com/sefinek/UFW-AbuseIPDB-Reporter`; // Please do not delete this URL. I would be very grateful, thank you! 💙 +https://github.com/sefinek/UFW-AbuseIPDB-Reporter`; // Please, don't delete this URL. I would be very grateful! Thank you. 💙 // Alternative version: -// exports.REPORT_COMMENT = ({ date, srcIp, dstIp, proto, spt, dpt, In, Out, mac, len, ttl, id, tos, prec, res, window, urgp, syn }, fullLog, serverName) => -// `Blocked by UFW ${serverName ? `on ${serverName} ` : ''}[${dpt}/${proto?.toLowerCase()}]. Generated by: https://github.com/sefinek/UFW-AbuseIPDB-Reporter`; +// exports.REPORT_COMMENT = ({ date, srcIp, dstIp, proto, spt, dpt, In, Out, mac, len, ttl, id, tos, prec, res, window, urgp, syn }, fullLog) => +// `Blocked by UFW ${serverId}[${dpt}/${proto?.toLowerCase()}]. Generated by: https://github.com/sefinek/UFW-AbuseIPDB-Reporter`; // See: https://www.abuseipdb.com/categories diff --git a/index.js b/index.js index 22aa07d..57486ef 100644 --- a/index.js +++ b/index.js @@ -108,7 +108,7 @@ const processLogLine = async (line, test = false) => { } const categories = config.DETERMINE_CATEGORIES(logData); - const comment = config.REPORT_COMMENT(logData, line, SERVER_ID); + const comment = config.REPORT_COMMENT(logData, line); if (await reportToAbuseIPDb(logData, categories, comment)) { markIPAsReported(srcIp);