diff --git a/index.js b/index.js index f698607..ef5269a 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ const { execSync } = require('child_process'); -const { get, post } = require('./modules/fetchHandler'); +const { get } = require('./modules/fetchHandler'); const fs = require('node:fs'); const os = require('os'); @@ -20,7 +20,7 @@ async function consoleLog(message, type) { if (process.env.MCR_BOT_WEBHOOK) { const webhook = process.env.MCR_BOT_WEBHOOK; const botUsername = `m${process.env.MCR_BOT_WEBHOOK_NAME}`; - await post(webhook, { content: message, username: botUsername }); + execSync(`curl --silent -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data "{"content": "${message}", "username": "${botUsername}"}" "${webhook}"`); } } @@ -52,13 +52,13 @@ async function vpnConnect(vpnName) { const status = await execSync('nmcli connection show --active') .toString() .includes(vpnName); - console.log(status); - if (status) { + console.log('Is connected: ' + status); + 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 { + else if (status == false) { consoleLog(`[${host}] Failed to connect to VPN: ${vpnName}. Retrying (attempt ${attempt} of ${maxAttempts})...`, 'error'); await sleep(1000); }