From 87458dd38cac4c9bd6c04841b87363e497deb5c3 Mon Sep 17 00:00:00 2001 From: Sefinek Date: Sun, 2 Feb 2025 01:54:24 +0100 Subject: [PATCH] Some fixes --- default.config.js | 2 +- services/fetchServerIP.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/default.config.js b/default.config.js index 60e3a53..4b96d01 100644 --- a/default.config.js +++ b/default.config.js @@ -3,7 +3,7 @@ exports.MAIN = { UFW_LOG_FILE: '/var/log/ufw.log', CACHE_FILE: '/tmp/ufw-abuseipdb-reporter.cache', SERVER_ID: null, // The server name that will be visible in the reports (e.g., 'homeserver1'). If you don't want to define it, leave the value as null. - IP_REFRESH_INTERVAL: 5 * 60 * 1000, // How often should (every 5 minutes) the script check the server's IP address to avoid accidental self-reports? + IP_REFRESH_INTERVAL: 8 * 60 * 1000, // How often should (every 5 minutes) the script check the server's IP address to avoid accidental self-reports? // Reporting ABUSEIPDB_API_KEY: '', // Secret API key for AbuseIPDB. diff --git a/services/fetchServerIP.js b/services/fetchServerIP.js index 3503230..536815a 100644 --- a/services/fetchServerIP.js +++ b/services/fetchServerIP.js @@ -1,6 +1,7 @@ const { networkInterfaces } = require('node:os'); const axios = require('./axios.js'); const isLocalIP = require('../utils/isLocalIP.js'); +const log = require('../utils/log.js'); const { IP_REFRESH_INTERVAL } = require('../config.js').MAIN; const ipAddrList = new Set(); @@ -10,7 +11,7 @@ const fetchIPv4Address = async () => { const { data } = await axios.get('https://api.sefinek.net/api/v2/ip'); if (data?.success && data?.message) ipAddrList.add(data.message); } catch (err) { - console.warn('Error fetching IPv4 address:', err.message); + log(2, `Error fetching IPv4 address: ${err.message}`); } }; @@ -20,7 +21,7 @@ const fetchIPv6Address = () => { if (!internal && address && !isLocalIP(address)) ipAddrList.add(address); }); } catch (err) { - console.warn('Error fetching IPv6 address:', err.message); + log(2, `Error fetching IPv6 address: ${err.message}`); } };