From 912e501025c21f23e192a306fda400ba3f0dd0c7 Mon Sep 17 00:00:00 2001 From: Lightemerald Date: Sun, 25 Jun 2023 16:01:28 +0200 Subject: [PATCH] Roll back --- index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index b13a49a..1ac9d75 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,6 @@ const { execSync } = require('child_process'); const fs = require('node:fs'); const os = require('os'); -const { publicIpv4 } = (...args) => import('public-ip').then(({ default: fth }) => fth(...args)); const host = os.hostname(); const args = process.argv.slice(2); @@ -71,7 +70,16 @@ async function vpnConnect(vpnName) { await sleep(1000); } else { - await consoleLog(`[${host}] VPN connection successfully established to ${vpnName} (IP: ${await publicIpv4()}).`, 'info'); + const response = await fetch('https://api.ipify.org/?format=json', { + method: 'GET', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + }); + const res = await response.json(); + const ip = res.ip; + await consoleLog(`[${host}] VPN connection successfully established to ${vpnName} (IP: ${ip}).`, 'info'); return 0; } }