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