Add EXTENDED_LOGS

This commit is contained in:
Sefinek committed 2025-04-27 02:36:28 +02:00
1 parent 21b69d1e1a
commit 2981fd661e
2 files changed
+5 -2

No files matched your search

+2
View File
@@ -3,6 +3,7 @@ exports.MAIN = {
UFW_LOG_FILE: '/var/log/ufw.log', UFW_LOG_FILE: '/var/log/ufw.log',
CACHE_FILE: '/var/cache/sefinek/ufw-abuseipdb-reporter.cache', CACHE_FILE: '/var/cache/sefinek/ufw-abuseipdb-reporter.cache',
SERVER_ID: null, // The server name that will be visible in reports (e.g., homeserver1, de1). Leave as null if you don't want to define it. SERVER_ID: null, // The server name that will be visible in reports (e.g., homeserver1, de1). Leave as null if you don't want to define it.
EXTENDED_LOGS: false, // Specifies whether the script should display additional information in the logs.
// Network // Network
IP_REFRESH_SCHEDULE: '0 */6 * * *', // CRON: How often the script should check the IP address assigned by the ISP to prevent accidental self-reporting. If you have a static IP, you can set it to '0 0 1 * *' (once a month). Default: every 6 hours IP_REFRESH_SCHEDULE: '0 */6 * * *', // CRON: How often the script should check the IP address assigned by the ISP to prevent accidental self-reporting. If you have a static IP, you can set it to '0 0 1 * *' (once a month). Default: every 6 hours
@@ -22,6 +23,7 @@ exports.MAIN = {
DISCORD_WEBHOOK_USERNAME: 'SERVER_ID', // The name displayed as the message author on Discord. If you don't want to set it, leave the value as null. Providing SERVER_ID as a string will display this.MAIN.SERVER_ID. DISCORD_WEBHOOK_USERNAME: 'SERVER_ID', // The name displayed as the message author on Discord. If you don't want to set it, leave the value as null. Providing SERVER_ID as a string will display this.MAIN.SERVER_ID.
}; };
// Generates a report submission. // Generates a report submission.
const serverId = this.MAIN.SERVER_ID ? `on ${this.MAIN.SERVER_ID} ` : ''; const serverId = this.MAIN.SERVER_ID ? `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) => exports.REPORT_COMMENT = ({ date, srcIp, dstIp, proto, spt, dpt, In, Out, mac, len, ttl, id, tos, prec, res, window, urgp, syn }, fullLog) =>
+3 -2
View File
@@ -13,7 +13,7 @@ const isLocalIP = require('./scripts/utils/isLocalIP.js');
const { parseNumber, parseTimestamp } = require('./scripts/utils/parse.js'); const { parseNumber, parseTimestamp } = require('./scripts/utils/parse.js');
const log = require('./scripts/utils/log.js'); const log = require('./scripts/utils/log.js');
const config = require('./config.js'); const config = require('./config.js');
const { UFW_LOG_FILE, ABUSEIPDB_API_KEY, SERVER_ID, AUTO_UPDATE_ENABLED, AUTO_UPDATE_SCHEDULE, DISCORD_WEBHOOKS_ENABLED, DISCORD_WEBHOOKS_URL } = config.MAIN; const { UFW_LOG_FILE, ABUSEIPDB_API_KEY, SERVER_ID, EXTENDED_LOGS, AUTO_UPDATE_ENABLED, AUTO_UPDATE_SCHEDULE, DISCORD_WEBHOOKS_ENABLED, DISCORD_WEBHOOKS_URL } = config.MAIN;
const ABUSE_STATE = { isLimited: false, isBuffering: false, sentBulk: false }; const ABUSE_STATE = { isLimited: false, isBuffering: false, sentBulk: false };
const RATE_LIMIT_LOG_INTERVAL = 10 * 60 * 1000; const RATE_LIMIT_LOG_INTERVAL = 10 * 60 * 1000;
@@ -144,7 +144,8 @@ const processLogLine = async (line, test = false) => {
minutes && `${minutes}m`, minutes && `${minutes}m`,
(seconds || (!days && !hours && !minutes)) && `${seconds}s`, (seconds || (!days && !hours && !minutes)) && `${seconds}s`,
].filter(Boolean).join(' '); ].filter(Boolean).join(' ');
log(`${srcIp} was last reported on ${new Date(lastReportedTime * 1000).toLocaleString()} (${timeAgo} ago)`);
if (EXTENDED_LOGS) log(`${srcIp} was last reported on ${new Date(lastReportedTime * 1000).toLocaleString()} (${timeAgo} ago)`);
return; return;
} }