From dc7bb8e5d5f4c7a0ec6baa2bb8a8dab31552e598 Mon Sep 17 00:00:00 2001 From: localhost Date: Sat, 30 May 2026 07:44:19 +0200 Subject: [PATCH] switch every 3rd attempt --- index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.ts b/index.ts index 33a4ef0..80e947c 100644 --- a/index.ts +++ b/index.ts @@ -43,8 +43,8 @@ app.get('/health', async (req, res) => { consecutiveFailures++; console.log(`Health check failed. Consecutive failures: ${consecutiveFailures}`); - if (consecutiveFailures === 3) { - console.log('3 consecutive failures reached. Switching IP in background...'); + if (consecutiveFailures % 3 === 0) { + console.log(`${consecutiveFailures} consecutive failures reached. Switching IP in background...`); switchIps().catch(err => console.error('Failed to switch IP:', err)); } @@ -58,8 +58,8 @@ app.get('/health', async (req, res) => { consecutiveFailures++; console.error(`Health check error. Consecutive failures: ${consecutiveFailures}. Error:`, error.message); - if (consecutiveFailures === 3) { - console.log('3 consecutive failures reached (from error). Switching IP in background...'); + if (consecutiveFailures % 3 === 0) { + console.log(`${consecutiveFailures} consecutive failures reached (from error). Switching IP in background...`); switchIps().catch(err => console.error('Failed to switch IP:', err)); }