From 58e45103bcf569a41b8d79a76f65d3a3d8231796 Mon Sep 17 00:00:00 2001 From: Sefinek Date: Wed, 25 Dec 2024 01:03:26 +0100 Subject: [PATCH] Fixes --- index.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index a039088..e9986dd 100644 --- a/index.js +++ b/index.js @@ -11,13 +11,13 @@ const { UFW_FILE, ABUSEIPDB_API_KEY, SERVER_ID, GITHUB_REPO } = config.MAIN; let fileOffset = 0; -const reportToAbuseIPDb = async (ip, categories, comment) => { +const reportToAbuseIPDb = async (logData, categories, comment) => { try { - const { data } = await axios.post('https://api.abuseipdb.com/api/v2/report', new URLSearchParams({ ip, categories, comment }), { + const { data } = await axios.post('https://api.abuseipdb.com/api/v2/report', new URLSearchParams({ ip: logData.ip, categories, comment }), { headers: { 'Key': ABUSEIPDB_API_KEY }, }); - log(0, `Successfully reported IP ${ip} (abuse: ${data.data.abuseConfidenceScore}%)`); + log(0, `Successfully reported ${logData.srcIp} (${logData.dpt}/${logData.proto}) with categories ${categories}; Abuse: ${data.data.abuseConfidenceScore}%`); return true; } catch (err) { log(2, `${err.message}\n${JSON.stringify(err.response.data?.errors || err.response.data)}`); @@ -96,9 +96,7 @@ const processLogLine = async line => { const categories = config.DETERMINE_CATEGORIES(proto, dpt); const comment = config.REPORT_COMMENT(logData, line, SERVER_ID); - log(0, `Reporting ${srcIp} (${dpt}/${proto}) with categories: ${categories}`); - - if (await reportToAbuseIPDb(srcIp, categories, comment)) { + if (await reportToAbuseIPDb(logData, categories, comment)) { markIPAsReported(srcIp); saveReportedIPs(); }