Fix7
This commit is contained in:
11
index.js
11
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');
|
||||
|
||||
Reference in New Issue
Block a user