Fix5
This commit is contained in:
10
index.js
10
index.js
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user