Some fixes

This commit is contained in:
Sefinek 2025-02-02 01:54:24 +01:00
parent 981783d78b
commit 87458dd38c
2 changed files with 4 additions and 3 deletions

View file

@ -3,7 +3,7 @@ exports.MAIN = {
UFW_LOG_FILE: '/var/log/ufw.log', UFW_LOG_FILE: '/var/log/ufw.log',
CACHE_FILE: '/tmp/ufw-abuseipdb-reporter.cache', 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. 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 // Reporting
ABUSEIPDB_API_KEY: '', // Secret API key for AbuseIPDB. ABUSEIPDB_API_KEY: '', // Secret API key for AbuseIPDB.

View file

@ -1,6 +1,7 @@
const { networkInterfaces } = require('node:os'); const { networkInterfaces } = require('node:os');
const axios = require('./axios.js'); const axios = require('./axios.js');
const isLocalIP = require('../utils/isLocalIP.js'); const isLocalIP = require('../utils/isLocalIP.js');
const log = require('../utils/log.js');
const { IP_REFRESH_INTERVAL } = require('../config.js').MAIN; const { IP_REFRESH_INTERVAL } = require('../config.js').MAIN;
const ipAddrList = new Set(); const ipAddrList = new Set();
@ -10,7 +11,7 @@ const fetchIPv4Address = async () => {
const { data } = await axios.get('https://api.sefinek.net/api/v2/ip'); const { data } = await axios.get('https://api.sefinek.net/api/v2/ip');
if (data?.success && data?.message) ipAddrList.add(data.message); if (data?.success && data?.message) ipAddrList.add(data.message);
} catch (err) { } 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); if (!internal && address && !isLocalIP(address)) ipAddrList.add(address);
}); });
} catch (err) { } catch (err) {
console.warn('Error fetching IPv6 address:', err.message); log(2, `Error fetching IPv6 address: ${err.message}`);
} }
}; };