diff --git a/package-lock.json b/package-lock.json index cbc4ac4..497ba14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "license": "AGPL-3.0-or-later", "dependencies": { "@azure/storage-blob": "^12.6.0", - "@the-bds-maneger/fetchsync": "github:The-Bds-Maneger/fetchSync", "adm-zip": "^0.5.1", "body-parser": "^1.19.0", "cli-color": "^2.0.0", @@ -451,17 +450,6 @@ "node": ">=10" } }, - "node_modules/@the-bds-maneger/fetchsync": { - "version": "1.0.0", - "resolved": "git+ssh://git@github.com/The-Bds-Maneger/fetchSync.git#c4af0cae45f434250dd7d2b0617395b5001371df", - "license": "AGPL-3.0-or-later", - "dependencies": { - "node-fetch": "^2.6.1" - }, - "engines": { - "node": ">=14" - } - }, "node_modules/@types/cacheable-request": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.2.tgz", @@ -7489,13 +7477,6 @@ "defer-to-connect": "^2.0.0" } }, - "@the-bds-maneger/fetchsync": { - "version": "git+ssh://git@github.com/The-Bds-Maneger/fetchSync.git#c4af0cae45f434250dd7d2b0617395b5001371df", - "from": "@the-bds-maneger/fetchsync@github:The-Bds-Maneger/fetchSync", - "requires": { - "node-fetch": "^2.6.1" - } - }, "@types/cacheable-request": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.2.tgz", diff --git a/package.json b/package.json index b7ab708..bfb4111 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,6 @@ }, "dependencies": { "@azure/storage-blob": "^12.6.0", - "@the-bds-maneger/fetchsync": "github:The-Bds-Maneger/fetchSync", "adm-zip": "^0.5.1", "body-parser": "^1.19.0", "cli-color": "^2.0.0", diff --git a/src/BdsNetwork.js b/src/BdsNetwork.js index f4aa12e..fe7ed70 100644 --- a/src/BdsNetwork.js +++ b/src/BdsNetwork.js @@ -1,12 +1,19 @@ // External User ip -const fetchSync = require("@the-bds-maneger/fetchsync"); +const Request = require("../lib/Requests"); const os = require("os"); const { GetTempHost } = require("../lib/BdsSettings"); -const externalIP = { - ipv4: fetchSync("https://api.ipify.org/").text().replace("\n", ""), - ipv6: fetchSync("https://api64.ipify.org/").text().replace("\n", "") -} +Request.TEXT("https://api.ipify.org").then(external_ipv4 => { + Request.TEXT("https://api64.ipify.org/").then(external_ipv6 => { + const externalIP = { + ipv4: external_ipv4.replace("\n", ""), + ipv6: external_ipv6.replace("\n", "") + } + + module.exports.externalIP = externalIP; + module.exports.ip = externalIP; + }); +}); // Internal ip user const interfaces = os.networkInterfaces(); @@ -48,7 +55,7 @@ var host = null, if (GetTempHost()){ // Get HOST - HostResponse = fetchSync("https://bds-core-back-end.vercel.app/Gethost", { + Request.JSON("https://bds-core-back-end.vercel.app/Gethost", { method: "POST", mode: "cors", body: JSON.stringify({ @@ -58,30 +65,28 @@ if (GetTempHost()){ headers: { "Content-Type": "application/json" } - }).json(); - global.BdsTempHost = HostResponse.user.host.host - host = HostResponse.user.host.host - - console.log(`Bds Maneger Core Temp Host ID: ${HostResponse.user.ID}`) - - // Delete Host - process.on("exit", function () { - const deleted_host = fetchSync("https://bds-core-back-end.vercel.app/DeleteHost", { - method: "post", - body: JSON.stringify({ - "ID": HostResponse.user.ID - }), - headers: { - "Content-Type": "application/json" - } - }).json() - if (deleted_host.error) console.log(deleted_host.error) - }) + }).then(HostResponse => { + global.BdsTempHost = HostResponse.user.host.host + host = HostResponse.user.host.host + console.log(`Bds Maneger Core Temp Host ID: ${HostResponse.user.ID}`) + // Delete Host + process.on("exit", function () { + Request.JSON("https://bds-core-back-end.vercel.app/DeleteHost", { + method: "post", + body: JSON.stringify({ + "ID": HostResponse.user.ID + }), + headers: { + "Content-Type": "application/json" + } + }).then(deleted_host => { + if (deleted_host.error) console.log(deleted_host.error) + }); + }); + }); } else module.exports.host = null module.exports = { - externalIP, - ip: externalIP, internal_ip, Interfaces, HostResponse,