This commit is contained in:
2023-06-25 14:20:15 +02:00
parent 8e439a0e68
commit 93bac87ae1
3 changed files with 10 additions and 107 deletions

View File

@@ -1,5 +1,4 @@
const { execSync } = require('child_process');
const { get } = require('./modules/fetchHandler');
const fs = require('node:fs');
const os = require('os');
@@ -26,7 +25,7 @@ async function consoleLog(message, type) {
};
try {
const response = await fetch(webhook, {
await fetch(webhook, {
method: 'POST',
headers: {
'Accept': 'application/json',
@@ -34,13 +33,6 @@ async function consoleLog(message, type) {
},
body: JSON.stringify(payload),
});
if (response.ok) {
console.log('Webhook message sent successfully.');
}
else {
console.log('Failed to send webhook message:', response.status, response.statusText);
}
}
catch (error) {
console.log('Error sending webhook message:', error.message);
@@ -79,7 +71,15 @@ async function vpnConnect(vpnName) {
await sleep(1000);
}
else {
const ip = await get('https://api.ipify.org');
const response = await fetch('https://api.ipify.org', {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
});
const ipResponse = await response.json();
const ip = ipResponse.data;
consoleLog(`[${host}] VPN connection successfully established to ${vpnName} (IP: ${ip.data}).`, 'info');
return 0;
}