diff --git a/config.default.js b/config.default.js index ce3c42e..43a57e6 100644 --- a/config.default.js +++ b/config.default.js @@ -3,6 +3,7 @@ exports.MAIN = { UFW_LOG_FILE: '/var/log/ufw.log', 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. + EXTENDED_LOGS: false, // Specifies whether the script should display additional information in the logs. // 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 @@ -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. }; + // Generates a report submission. 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) => diff --git a/index.js b/index.js index b41b019..eb0d647 100644 --- a/index.js +++ b/index.js @@ -13,7 +13,7 @@ const isLocalIP = require('./scripts/utils/isLocalIP.js'); const { parseNumber, parseTimestamp } = require('./scripts/utils/parse.js'); const log = require('./scripts/utils/log.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 RATE_LIMIT_LOG_INTERVAL = 10 * 60 * 1000; @@ -144,7 +144,8 @@ const processLogLine = async (line, test = false) => { minutes && `${minutes}m`, (seconds || (!days && !hours && !minutes)) && `${seconds}s`, ].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; }