This commit is contained in:
2023-06-25 14:06:15 +02:00
parent 80f4b9a224
commit c1717d80b6

View File

@@ -47,18 +47,14 @@ async function vpnConnect(vpnName) {
const maxAttempts = process.env.RETRIES;
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
try {
execSync(`nmcli connection up "${vpnName}"`);
await execSync(`nmcli connection up "${vpnName}"`);
const status = await execSync('nmcli connection show --active')
.toString()
.includes(vpnName);
console.log('Is connected: ' + status);
if (status == true) {
if (await execSync('nmcli connection show --active').toString().includes(vpnName) == true) {
const ip = await get('https://api.ipify.org');
consoleLog(`[${host}] VPN connection successfully established to ${vpnName} (IP: ${ip.data}).`, 'info');
return 0;
}
else if (status == false) {
else {
consoleLog(`[${host}] Failed to connect to VPN: ${vpnName}. Retrying (attempt ${attempt} of ${maxAttempts})...`, 'error');
await sleep(1000);
}