From 8e439a0e68d85dd2ea5ae249cadcd27eb5c14ef7 Mon Sep 17 00:00:00 2001 From: Lightemerald Date: Sun, 25 Jun 2023 14:12:29 +0200 Subject: [PATCH] Fix7 --- index.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 7b8dca4..3d4add3 100644 --- a/index.js +++ b/index.js @@ -75,21 +75,14 @@ async function vpnConnect(vpnName) { const status = await execSync('nmcli connection show --active').toString().includes(vpnName); if (!status) { - console.log('Not connected!'); + consoleLog(`[${host}] Failed to connect to VPN: ${vpnName}. Retrying (attempt ${attempt} of ${maxAttempts})...`, 'error'); + await sleep(1000); } else { - console.log('Connected!'); - } - - if (status == true) { const ip = await get('https://api.ipify.org'); consoleLog(`[${host}] VPN connection successfully established to ${vpnName} (IP: ${ip.data}).`, 'info'); return 0; } - else { - consoleLog(`[${host}] Failed to connect to VPN: ${vpnName}. Retrying (attempt ${attempt} of ${maxAttempts})...`, 'error'); - await sleep(1000); - } } catch (error) { consoleLog(`[${host}] Failed to connect to VPN: ${vpnName}. Retrying (attempt ${attempt} of ${maxAttempts})...`, 'error');