From d329d3a83d607693fa7df932784ec328a14c925f Mon Sep 17 00:00:00 2001 From: Sefinek Date: Wed, 18 Sep 2024 12:38:39 +0200 Subject: [PATCH] Add SEFINEK_API_URL --- .env.default | 5 ++++- scripts/sefinekAPI.js | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.env.default b/.env.default index d801d6e..47e2d8c 100644 --- a/.env.default +++ b/.env.default @@ -37,4 +37,7 @@ IP_REFRESH_INTERVAL=80 REPORT_TO_SEFINEK_API=false # How often should the log (reported_ips.csv) be analyzed and sent to the Sefinek API? In hours. -SEFINEK_API_INTERVAL=1 \ No newline at end of file +SEFINEK_API_INTERVAL=1 + +# Sefinek API v2 URL +SEFINEK_API_URL=https://api.sefinek.net/api/v2 \ No newline at end of file diff --git a/scripts/sefinekAPI.js b/scripts/sefinekAPI.js index 52b4a73..7eb4159 100644 --- a/scripts/sefinekAPI.js +++ b/scripts/sefinekAPI.js @@ -3,7 +3,7 @@ const { readReportedIPs, updateSefinekAPIInCSV } = require('./csv.js'); const log = require('./log.js'); const clientIp = require('./clientIp.js'); -const SEFINEK_API_URL = process.env.SEFINEK_API_URL || `${process.env.NODE_ENV === 'production' ? 'https://api.sefinek.net' : 'http://127.0.0.1:4010'}/api/v2/cloudflare-waf-abuseipdb/post`; +const API_URL = `${process.env.SEFINEK_API_URL}/api/v2/cloudflare-waf-abuseipdb/post`; module.exports = async () => { const userIp = clientIp.getAddress(); @@ -20,7 +20,7 @@ module.exports = async () => { if (!uniqueLogs?.length) return log('log', 'No unique IPs to send to Sefinek API'); try { - const res = await axios.post(SEFINEK_API_URL, { + const res = await axios.post(API_URL, { reportedIPs: uniqueLogs.map(ip => ({ rayId: ip.rayId, ip: ip.ip,