Last fixes

This commit is contained in:
Sefinek 2025-03-21 10:29:37 +01:00
parent a2f6ac6fb6
commit cb856ccee1

View file

@ -8,7 +8,6 @@ const { MAIN, CYCLES } = require('../config.js').CONFIG;
const ipAddresses = new Set(); const ipAddresses = new Set();
let ipv6ErrorCount = 0, ipv6ErrorLogged = false; let ipv6ErrorCount = 0, ipv6ErrorLogged = false;
const IPv6Failed = 'It looks like your ISP hasn\'t assigned you any IPv6 address. I won\'t attempt to fetch it again.';
const fetchIPAddress = async family => { const fetchIPAddress = async family => {
if (family === 6 && (ipv6ErrorLogged || !MAIN.IPv6_SUPPORT)) return; if (family === 6 && (ipv6ErrorLogged || !MAIN.IPv6_SUPPORT)) return;
@ -22,11 +21,7 @@ const fetchIPAddress = async family => {
ipAddresses.add(data.message); ipAddresses.add(data.message);
if (family === 6) { if (family === 6) {
if (ipv6ErrorCount > 0) { if (ipv6ErrorCount > 0) log(0, `Uh, it looks like IPv6 has started working! It only succeeded after ${ipv6ErrorCount} attempts.`);
const IPv6Success = `Uh, it looks like IPv6 has started working! It only succeeded after ${ipv6ErrorCount} attempts.`;
log(0, IPv6Success);
}
ipv6ErrorCount = 0; ipv6ErrorCount = 0;
} }
} else { } else {
@ -40,7 +35,7 @@ const fetchIPAddress = async family => {
if (ipv6ErrorCount >= 6 && !ipv6ErrorLogged) { if (ipv6ErrorCount >= 6 && !ipv6ErrorLogged) {
ipv6ErrorLogged = true; ipv6ErrorLogged = true;
log(0, IPv6Failed); log(0, 'It looks like your ISP hasn\'t assigned you any IPv6 address. I won\'t attempt to fetch it again.');
} else { } else {
await new Promise(resolve => setTimeout(resolve, 4000)); await new Promise(resolve => setTimeout(resolve, 4000));
await fetchIPAddress(6); await fetchIPAddress(6);