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');