Telegram bot #150

Merged
Sirherobrine23 merged 14 commits from Telegram_bot into main 2021-08-11 02:47:35 +00:00
23 changed files with 726 additions and 502 deletions

17
.vscode/launch.json vendored
View File

@ -1,6 +1,12 @@
{ {
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{
"type": "node",
"request": "launch",
"name": "Start Telegram bot dev",
"program": "${workspaceFolder}/bin/telegram_bot.js"
},
{ {
"type": "node", "type": "node",
"request": "launch", "request": "launch",
@ -11,17 +17,6 @@
"Docker" "Docker"
], ],
"port": 9229 "port": 9229
},
{
"type": "node",
"request": "launch",
"name": "Telegram BOT",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"dev:telegram"
],
"port": 9229
} }
] ]
} }

View File

@ -17,16 +17,17 @@
"stop": "stop", "stop": "stop",
"op": "op \"{{Player}}\"", "op": "op \"{{Player}}\"",
"deop": "op \"{{Player}}\"", "deop": "op \"{{Player}}\"",
"ban": "tp \"{{Player}}\" ~ ~99999 ~",
"kick": "kick \"{{Player}}\" \"{{Text}}\"", "kick": "kick \"{{Player}}\" \"{{Text}}\"",
"tp": "tp \"{{Player}}\" {{CCO}}" "tp": "tp \"{{Player}}\" {{X}} {{Y}} {{X}}"
}, },
"java": { "java": {
"stop": "stop", "stop": "stop",
"op": "op \"{{Player}}\"", "op": "op {{Player}}",
"deop": "op \"{{Player}}\"", "deop": "op {{Player}}",
"ban": "ban 0 0 0", "ban": "ban {{Player}}",
"kick": "kick \"{{Player}}\" {{Text}}", "kick": "kick {{Player}} {{Text}}",
"tp": "tp {{Player}} {{CCO}}" "tp": "tp {{Player}} {{X}} {{Y}} {{X}}"
}, },
"pocketmine": { "pocketmine": {
"stop": "stop", "stop": "stop",
@ -34,7 +35,7 @@
"deop": "op {{Player}}", "deop": "op {{Player}}",
"ban": "ban {{Player}}", "ban": "ban {{Player}}",
"kick": "kick {{Player}}", "kick": "kick {{Player}}",
"tp": "tp {{Player}} {{CCO}}" "tp": "tp \"{{Player}}\" {{X}} {{Y}} {{X}}"
} }
}, },
"contributors": [ "contributors": [

View File

@ -8,6 +8,10 @@ Any contribution is welcome, but before a look at [CONTRIBUTING.md](CONTRIBUTING
In Version 1.11.0 there was a big change in the way to get the new settings and that left a good part of the program broken, so for those who are going to upgrade to the latest versions of Bds maneger Core will have to change the settings manually. In Version 1.11.0 there was a big change in the way to get the new settings and that left a good part of the program broken, so for those who are going to upgrade to the latest versions of Bds maneger Core will have to change the settings manually.
## Documentation
We have a separate repository for all Bds Maneger Project documentation, <a href="https://docs.bdsmaneger.com/Bds Maneger core" target="_blank">link here from the main page</a>, <a href="https://github.com/The-Bds-Maneger/Bds-Manager-Project-Documentation" target="_blank">Repository link</a>
## Badges ## Badges
[![Github CodeQL and OSSAR](https://github.com/The-Bds-Maneger/Bds-Maneger-Core/actions/workflows/codeql%20and%20ossar%20analysis.yml/badge.svg)](https://github.com/The-Bds-Maneger/Bds-Maneger-Core/actions/workflows/codeql%20and%20ossar%20analysis.yml) [![Github CodeQL and OSSAR](https://github.com/The-Bds-Maneger/Bds-Maneger-Core/actions/workflows/codeql%20and%20ossar%20analysis.yml/badge.svg)](https://github.com/The-Bds-Maneger/Bds-Maneger-Core/actions/workflows/codeql%20and%20ossar%20analysis.yml)
@ -15,9 +19,10 @@ In Version 1.11.0 there was a big change in the way to get the new settings and
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/Bds-Maneger/bds_maneger_api.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Bds-Maneger/bds_maneger_api/context:javascript) [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/Bds-Maneger/bds_maneger_api.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Bds-Maneger/bds_maneger_api/context:javascript)
[![DeepScan grade](https://deepscan.io/api/teams/13683/projects/16691/branches/363172/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=13683&pid=16691&bid=363172) [![DeepScan grade](https://deepscan.io/api/teams/13683/projects/16691/branches/363172/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=13683&pid=16691&bid=363172)
## Start our Docker image, making everything easier. ## Start our Docker image, making everything easier
Windows: Windows:
```cmd ```cmd
$ docker run --rm -d --name BdsManegerCore -v BdsCore:/home/bds/bds_core ^ $ docker run --rm -d --name BdsManegerCore -v BdsCore:/home/bds/bds_core ^
-p 19132:19132/udp -p 19133:19133/udp -p 1932:1932/tcp ^ -p 19132:19132/udp -p 19133:19133/udp -p 1932:1932/tcp ^
@ -34,6 +39,7 @@ bdsmaneger/core:latest
``` ```
Linux/MacOS: Linux/MacOS:
```bash ```bash
$ docker run --rm -d --name BdsManegerCore -v BdsCore/:/home/bds/bds_core \ $ docker run --rm -d --name BdsManegerCore -v BdsCore/:/home/bds/bds_core \
-p 19132:19132/udp -p 19133:19133/udp -p 1932:1932/tcp \ -p 19132:19132/udp -p 19133:19133/udp -p 1932:1932/tcp \
@ -51,13 +57,7 @@ bdsmaneger/core:latest
## We also have some Implementation Models for Azure ## We also have some Implementation Models for Azure
#### Microsoft Azure Container ### Microsoft Azure Virtual machine
The Azure container is a special machine for Docker Within Azure, it is fully managed by Azure, it only depends on the Docker image, but it has its limitations.
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FBds-Maneger%2FThe-Bds-Maneger-Docker%2Fmain%2Fazure%2FBdsMangerCore_docker.json)
#### Microsoft Azure Virtual machine
Here we have a virtual machine totally dedicated to Bds Maneger Core, it still uses Docker to deploy Docker images. Here we have a virtual machine totally dedicated to Bds Maneger Core, it still uses Docker to deploy Docker images.

View File

@ -1,14 +1,14 @@
#!/usr/bin/env node #!/usr/bin/env node
if (process.platform === "win32") process.title = "Bds Maneger CLI"; else process.title = "Bds_Manger_CLI"; const readline = require("readline");
if (process.platform === "win32") process.title = "Bds Maneger CLI"; else process.title = "Bds-Manger-CLI";
process.env.IS_BDS_CLI = process.env.IS_BIN_BDS = true; process.env.IS_BDS_CLI = process.env.IS_BIN_BDS = true;
// Inports
const readline = require("readline");
const bds = require("../index"); const bds = require("../index");
const { valid_platform } = require("../lib/BdsSystemInfo"); const { valid_platform } = require("../lib/BdsSystemInfo");
const { bds_dir, GetServerVersion, GetPlatform, UpdatePlatform, GetServerPaths, GetPaths } = require("../lib/BdsSettings"); const { bds_dir, GetServerVersion, GetPlatform, UpdatePlatform, GetServerPaths, GetPaths } = require("../lib/BdsSettings");
const commandExits = require("../lib/commandExist"); const commandExits = require("../lib/commandExist");
const download = require("../src/download"); const download = require("../src/BdsServersDownload");
// Bds Maneger ArgV // Bds Maneger ArgV
const argv = require("minimist")(process.argv.slice(2)); const argv = require("minimist")(process.argv.slice(2));

342
bin/telegram_bot.js Normal file → Executable file
View File

@ -1,18 +1,13 @@
const { Telegraf } = require("telegraf");
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const { Telegraf, Markup } = require("telegraf");
const bds = require("../index"); const bds = require("../index");
const { GetPlatform, GetPaths } = require("../lib/BdsSettings"); const { GetPlatform, GetPaths, GetTelegramToken } = require("../lib/BdsSettings");
const { GetKernel, arch, system } = require("../lib/BdsSystemInfo"); const { GetKernel, arch, system } = require("../lib/BdsSystemInfo");
const { Detect } = require("../src/CheckKill"); const { Detect } = require("../src/CheckKill");
const TelegramOptions = require("minimist")(process.argv.slice(2)); const { Servers } = require("../lib/ServerURL");
const { CheckTelegramUser } = require("../src/UsersAndtokenChecks")
if (TelegramOptions.h || TelegramOptions.help) {
const Help = [];
console.log(Help.join("\n"));
process.exit(0)
}
// Bot Start And Help messages
const HelpAndStart = [ const HelpAndStart = [
"Hello, welcome to Bds Maneger Telegram Bot", "Hello, welcome to Bds Maneger Telegram Bot",
"", "",
@ -20,119 +15,282 @@ const HelpAndStart = [
"Options:", "Options:",
" /start or /help: This message!", " /start or /help: This message!",
" /basic", " /basic",
" start, stop", " start, stop, backup",
" /live_log",
" enabler, disabler",
" /live_log",
" /download",
" Version",
" ", " ",
] ]
// Set Telegram Bot // Set Telegram Bot
const bot = new Telegraf(bds.telegram_token); const bot = new Telegraf(GetTelegramToken());
// Start and Help Command // Start and Help Command
bot.start((ctx)=>ctx.reply(HelpAndStart.join("\n"))); bot.start((ctx)=>ctx.reply(HelpAndStart.join("\n")));
bot.help((ctx)=>ctx.reply(HelpAndStart.join("\n"))); bot.help((ctx)=>ctx.reply(HelpAndStart.join("\n")));
const ChatIDs = {} // User
function SaveID(id = "a"){return ChatIDs[id] = true} bot.command("player", ctx => {
function RemoveID(id = "a"){return delete ChatIDs[id]} // Check admin Username
function GetID(){return ChatIDs} if (!(CheckTelegramUser(ctx.from.username))) return ctx.reply("you are not an administrator");
const Server = global.ServerExec;
const CtxOption = ctx.message.text.replace("/player", "").trim();
const CtxContext = CtxOption.replace(/^kick|^deop|^ban|^op/, "").trim();
if (CtxOption) {
const Players = CtxContext.split(/, |,/gi).filter(a => a.trim());
console.log(Players);
if (/kick/.test(CtxOption)){
if (Players.length >= 1) {
Players.forEach(Player => {
Server.kick(Player);
ctx.reply(`${Player} was kicked`);
});
} else ctx.reply("and the Players?")
}
else if (/deop/.test(CtxOption)){
if (Players.length >= 1) {
Players.forEach(Player => {
Server.deop(Player);
ctx.reply(`${Player} was deopped`);
});
} else ctx.reply("and the Players?")
}
else if (/ban/.test(CtxOption)){
if (Players.length >= 1) {
Players.forEach(Player => {
Server.ban(Player);
ctx.reply(`${Player} was banned`);
});
} else ctx.reply("and the Players?")
}
else if (/op/.test(CtxOption)){
if (Players.length >= 1) {
Players.forEach(Player => {
Server.op(Player);
ctx.reply(`${Player} was opped`);
});
} else ctx.reply("and the Players?")
}
else if (/list/.test(CtxOption)){
const Player_Json_path = GetPaths("player");
let Players_Json = JSON.parse(fs.readFileSync(Player_Json_path, "utf8"))[GetPlatform()];
const new_players = {};
Players_Json.forEach(Player => {
console.log(Player);
if (new_players[Player.Player]) {
new_players[Player.Player].push([`Action: ${Player.Action}`, `Date: ${Player.Date}`].join("\n"));
} else {
new_players[Player.Player] = [
[`Player: ${Player.Player}`, `Action: ${Player.Action}`, `Date: ${Player.Date}`].join("\n")
]
}
});
console.log(new_players);
Object.getOwnPropertyNames(new_players).forEach(Player_Array => {
let Length = Math.abs(new_players[Player_Array].length - 5);
let Player = new_players[Player_Array].slice(0, Length).join("\n")
ctx.reply(Player);
});
}
else ctx.reply("Invalid option")
} else {
const ReplyOption = Markup.keyboard([
"/player kick",
"/player deop",
"/player ban",
"/player op",
"/player list",
]).oneTime().resize();
ctx.reply("Player Options:", ReplyOption);
}
});
// Basic server // Basic server
bot.command("basic", ctx => { bot.command("basic", async ctx => {
// Check admin Username
if (!(CheckTelegramUser(ctx.from.username))) return ctx.reply("you are not an administrator");
const text = ctx.message.text.replace("/basic", "").trim(); const text = ctx.message.text.replace("/basic", "").trim();
if (/start/.test(text)) { if (text) {
if (Detect()) ctx.reply("Stop Server"); // Start Server
else { if (/start/.test(text)) {
try { if (Detect()) ctx.reply("Stop Server");
const Server = bds.start(); else {
Server.log(function (data){ try {
Object.getOwnPropertyNames(GetID()).forEach(Id => { const Server = bds.start();
console.log(Id); Server.log(function (data){
if (ChatIDs[Id]) bot.telegram.sendMessage(Id, data) for (let stx of global.LiveLog) stx.reply(data);
}) });
}) global.ServerExec = Server;
return ctx.reply("Server Started") return ctx.reply("Server Started")
} catch (err) { } catch (err) {
console.log(err) console.log(err)
ctx.reply("We couldn't start the server") ctx.reply("We couldn't start the server")
ctx.reply(err.toString()); ctx.reply(err.toString());
}
} }
} }
} else if (/stop/.test(text)) { // Stop Server
if (Detect()) { else if (/stop/.test(text)) {
try { if (Detect()) {
bds.stop() try {
ctx.reply("Stopping your server") bds.stop()
} catch (err) { ctx.reply("Stopping your server")
ctx.reply("We had an error for your server"); } catch (err) {
ctx.reply(err.toString()); ctx.reply("We had an error for your server");
} ctx.reply(err.toString());
} else ctx.reply("Your server is stopped") }
} else return ctx.reply("Invalid option, they are just: start, stop") } else ctx.reply("Your server is stopped")
}
// Backup
else if (/backup/.test(text)) {
const Backup = bds.backup();
ctx.replyWithDocument({
source: Backup.Buffer,
filename: Backup.file_name,
})
}
// Invalid option
else return ctx.reply("Invalid option, they are just: start, stop")
} else {
await ctx.deleteMessage();
const Options = Markup.keyboard([
"/basic start",
"/basic stop",
"/basic backup",
]).oneTime().resize();
ctx.reply("Basic Options", Options);
}
}); });
// Select Platform // Select Platform
bot.command("platform", ctx => { bot.command("platform", async ctx => {
// Check admin Username
if (!(CheckTelegramUser(ctx.from.username))) return ctx.reply("you are not an administrator");
const text = ctx.message.text.replace("/platform", "").trim(); const text = ctx.message.text.replace("/platform", "").trim();
try { if (text) {
bds.BdsSettigs.UpdatePlatform(text); try {
return ctx.reply(`Platform update to ${text}`) bds.BdsSettigs.UpdatePlatform(text);
} catch (err) { return ctx.reply(`Platform update to ${text}`)
ctx.reply("We were unable to change the platform") } catch (err) {
return ctx.reply(err.toString()) ctx.reply("We were unable to change the platform")
return ctx.reply(err.toString())
}
} else {
await ctx.deleteMessage();
const Keyboard = Markup.keyboard([
"/platform bedrock",
"/platform java",
"/platform pocketmine",
"/platform jsprismarine"
]).oneTime().resize();
ctx.reply("Select Platform", Keyboard)
} }
}) });
// Download Server
bot.command("download", async ctx => {
// Check admin Username
if (!(CheckTelegramUser(ctx.from.username))) return ctx.reply("you are not an administrator");
const version = ctx.message.text.replace(/\/download|[a-zA-Z]/gi, "").trim();
if (version) {
await bds.download(version, true);
ctx.reply(`Sucess install ${GetPlatform()} with version ${version}`);
} else {
await ctx.deleteMessage();
const KeyboardVersion = Markup.keyboard(Object.getOwnPropertyNames(Servers[GetPlatform()]).map(version => {
return {
text: `/download ${version}`
}
})).oneTime().resize();
ctx.reply("Select Version to Install", KeyboardVersion);
}
});
// Command
bot.command("command", async ctx => {
// Check admin Username
if (!(CheckTelegramUser(ctx.from.username))) return ctx.reply("you are not an administrator");
const text = ctx.message.text.replace("/command", "").trim();
if (!(Detect())) return ctx.reply("Your server is stopped");
if (text) {
try {
global.ServerExec.command(text);
} catch (err) {
ctx.reply("We couldn't execute the command");
ctx.reply(`${err}`);
}
} else {
await ctx.deleteMessage();
return ctx.reply("/command <command>");
}
});
// Send Info // Send Info
bot.command("info", ctx => { bot.command("info", ctx => {
const config = bds.get_config(); const config = bds.get_config();
const InfoRes = [ const InfoRes = [
`Bds Maneger core version: ${bds.package_json.version}`, `Bds Maneger core version: ${bds.package_json.version}`,
"", `Kernel: ${GetKernel()}`,
"* System Info:", `Arch: ${arch}`,
` Kernel: ${GetKernel()}`, `System: ${system}`,
` Arch: ${arch}`, `Platform: ${GetPlatform()}`,
` System: ${system}`, `World_name: ${config.world}`,
"", `Running: ${bds.detect()}`,
"* Server:", `Port_V4: ${config.portv4}`,
` platform: ${GetPlatform()}`, `Port_V6: ${config.portv6}`,
` world_name: ${config.world}`, `Max_players: ${config.players}`,
` running: ${bds.detect()}`, `Whitelist: ${config.whitelist}`,
` port: ${config.portv4}`,
` port6: ${config.portv6}`,
` max_players: ${config.players}`,
` whitelist: ${config.whitelist}`,
] ]
return ctx.reply(InfoRes.join("\n")) ctx.reply(InfoRes.join("\n\n"));
});
// Log
bot.command("log", ctx => {
try {
// 4096
const Log = fs.readFileSync(path.resolve(GetPaths("log"), "latest.log"), "utf8")
if (Log.length >= 4096) ctx.reply(Log.substr(-4096));
else ctx.reply(Log)
} catch (err) {
ctx.reply(err.toString())
}
}); });
// Live Log User // Live Log User
bot.command("live_log", ctx => { global.LiveLog = [];
const option = ctx.message.text.replace("/platform", "").trim(); bot.command("live_log", async ctx => {
if (/enable/.test(option)) { // Check admin Username
SaveID(ctx.from.id) if (!(CheckTelegramUser(ctx.from.username))) return ctx.reply("you are not an administrator");
console.log(GetID())
} else if (/disable/.test(option)) { const option = ctx.message.text.replace("/live_log", "").trim();
RemoveID(ctx.from.id) if (option) {
console.log(GetID()) if (/enable/.test(option)) {
} else ctx.reply("Invalid option") global.LiveLog.push(ctx);
ctx.reply(ctx.chat.id) return ctx.reply("Sucess");
}) } else if (/disable/.test(option)) {
// ctx.from.id
for (let ctx_Logs in global.LiveLog) {
if (global.LiveLog[ctx_Logs].from.id === ctx.from.id) {
delete global.LiveLog[ctx_Logs];
global.LiveLog = global.LiveLog.filter(a=>a);
return ctx.reply("Ok");
}
}
return ctx.reply("You are not in the list");
}
}
await ctx.deleteMessage();
const ReplyOption = Markup.keyboard([
"/live_log enable",
"/live_log disable",
]).oneTime().resize();
ctx.reply("Enable/Disabled?", ReplyOption);
});
// text
bot.on("text", ctx => {
console.log(ctx.message.text);
if (!(/\/.*/gi.test(ctx.message.text))) global.ServerExec.command(`say ${ctx.message.text}`)
});
// catch // catch
bot.catch(console.log); bot.catch(console.log);
// End And Lauch // End And Lauch
process.on("exit", bot.stop) bot.launch();
bot.launch() console.log("Telegram was started");

View File

@ -2,7 +2,10 @@
const { resolve } = require("path"); const { resolve } = require("path");
const path = require("path") const path = require("path")
const fs = require("fs"); const fs = require("fs");
const { randomUUID } = require("crypto"); const randomUUID = require("uuid").v4;
const { bds_dir } = require("./lib/BdsSettings");
if (typeof fetch === "undefined") global.fetch = require("node-fetch");
function date(format) { function date(format) {
const today = new Date(), const today = new Date(),
@ -26,26 +29,42 @@ module.exports.package_path = bds_core_package
module.exports.package_json = require("./package.json"); module.exports.package_json = require("./package.json");
module.exports.extra_json = require("./BdsManegerInfo.json"); module.exports.extra_json = require("./BdsManegerInfo.json");
const { bds_dir } = require("./lib/BdsSettings");
// Inport and Export Arch // Inport and Export Arch
const { arch } = require("./lib/BdsSystemInfo"); const { arch } = require("./lib/BdsSystemInfo");
module.exports.arch = arch module.exports.arch = arch
const { GetJsonConfig, UpdatePlatform, UpdateTelegramToken, GetTelegramToken } = require("./lib/BdsSettings"); const { GetJsonConfig, UpdatePlatform, UpdateTelegramToken } = require("./lib/BdsSettings");
if (typeof fetch === "undefined") global.fetch = require("node-fetch");
const maneger_ips = require("./src/external_ip") // Bds Maneger Core Network
const maneger_ips = require("./src/BdsNetwork")
module.exports.internal_ip = maneger_ips.internal_ip module.exports.internal_ip = maneger_ips.internal_ip
module.exports.external_ip = maneger_ips.external_ip module.exports.external_ip = maneger_ips.external_ip
module.exports.save_google_id = require("./lib/BdsSettings").CloudConfig.Driver module.exports.tmphost = {
module.exports.getBdsConfig = GetJsonConfig host: maneger_ips.host,
module.exports.change_platform = module.exports.platform_update = UpdatePlatform Response: maneger_ips.HostResponse
module.exports.telegram_token_save = UpdateTelegramToken }
module.exports.api = require("./src/rest/api");
// Telegram // Get Old Method Config
module.exports.telegram_token = GetTelegramToken(); module.exports.getBdsConfig = GetJsonConfig;
/**
* Update Current Platform
*/
module.exports.change_platform = module.exports.platform_update = UpdatePlatform;
/**
* Save Telegram token in Settings File
*/
module.exports.telegram_token_save = UpdateTelegramToken
/**
* The Bds Maneger Core Internal API REST
*
* @param {number} port - The port number, default is 1932
*
* @param {function} callback - The callback function after start API
*/
module.exports.api = require("./src/rest/api");
function token_register() { function token_register() {
const bds_token_path = path.join(bds_dir, "bds_tokens.json"); const bds_token_path = path.join(bds_dir, "bds_tokens.json");
@ -67,17 +86,6 @@ function token_register() {
return bdsuid; return bdsuid;
} }
/**
* Update, Get and more to Modifications Bds Settings File
*/
module.exports.BdsSettigs = require("./lib/BdsSettings");
// Requires
const { World_BAckup } = require("./src/backups");
const { config, get_config, config_example } = require("./src/ServerSettings");
const download = require("./src/download");
const { start, stop, BdsCommand, CronBackups } = require("./src/basic_server")
/** /**
* Register tokens to use in Bds Maneger REST and other supported applications * Register tokens to use in Bds Maneger REST and other supported applications
* *
@ -85,6 +93,17 @@ const { start, stop, BdsCommand, CronBackups } = require("./src/basic_server")
*/ */
module.exports.token_register = token_register module.exports.token_register = token_register
/**
* Update, Get and more to Modifications Bds Settings File
*/
module.exports.BdsSettigs = require("./lib/BdsSettings");
// Requires
const { World_BAckup } = require("./src/BdsBackup");
const { config, get_config } = require("./src/ServerSettings");
const download = require("./src/BdsServersDownload");
const { start, stop, BdsCommand, CronBackups } = require("./src/BdsManegerServer")
/** /**
* Take the current date * Take the current date
*/ */
@ -98,6 +117,7 @@ module.exports.BdsDate = module.exports.date = date
module.exports.command = BdsCommand module.exports.command = BdsCommand
// New management method // New management method
// Start Server
/** /**
* to start the server here in the sera script with child_process, then you will have to use the return function for your log custumization or anything else * to start the server here in the sera script with child_process, then you will have to use the return function for your log custumization or anything else
* *
@ -105,10 +125,14 @@ module.exports.command = BdsCommand
* server.log(function (log){console.log(log)}) * server.log(function (log){console.log(log)})
*/ */
module.exports.start = start module.exports.start = start
// Stop Server
/** /**
* use this command for the server, that's all * use this command for the server, that's all
*/ */
module.exports.stop = stop module.exports.stop = stop
// Create Backup of Bds Maneger Core and Servers along with your maps and settings
/** /**
* backup your map locally * backup your map locally
*/ */
@ -137,14 +161,13 @@ module.exports.kill = Kill
* use download( version, boolean ) // the boolean is for if you want to force the installation of the server * use download( version, boolean ) // the boolean is for if you want to force the installation of the server
* *
* @example * @example
* bedrock: bds.download("1.16.201.02") * bedrock: download("1.16.201.02")
* *
* java: bds.download("1.16.5") * java: download("1.16.5")
* *
* any platform: bds.download("latest") // It will download the latest version available for download * any platform: download("latest") // It will download the latest version available for download
*/ */
module.exports.download = download module.exports.download = download
module.exports.config_example = config_example
/** /**
* use this command to modify server settings * use this command to modify server settings
@ -164,19 +187,12 @@ module.exports.config_example = config_example
}); });
*/ */
module.exports.set_config = config module.exports.set_config = config
/** /**
* takes the server settings in JSON format * takes the server settings in JSON format
*/ */
module.exports.get_config = get_config module.exports.get_config = get_config
/**
* Get temp domain to Server and API (The Domain is even temporary).
*/
module.exports.tmphost = require("./lib/tempHost")
// Core Applications
/** /**
* Load Crontab Backup * Load Crontab Backup
*/ */

View File

@ -1,13 +1,11 @@
const { join, resolve } = require("path"); const { join, resolve } = require("path");
const { existsSync, writeFileSync, mkdirSync, readFileSync } = require("fs"); const { existsSync, writeFileSync, mkdirSync, readFileSync } = require("fs");
const { homedir } = require("os"); const { homedir } = require("os");
const { valid_platform } = require("./BdsSystemInfo");
const yaml = { const yaml = {
parse: require("js-yaml").load, parse: require("js-yaml").load,
stringify: require("js-yaml").dump stringify: require("js-yaml").dump
} }
const FetchSync = require("@the-bds-maneger/fetchsync");
const { external_ip } = require("../src/external_ip");
const { valid_platform } = require("./BdsSystemInfo");
// PATHs // PATHs
const home = homedir(); const home = homedir();
@ -21,7 +19,7 @@ else if (valid_platform["java"]) default_platformConfig = "java";
else if (valid_platform["pocketmine"]) default_platformConfig = "pocketmine"; else if (valid_platform["pocketmine"]) default_platformConfig = "pocketmine";
else default_platformConfig = "jsprismarine" else default_platformConfig = "jsprismarine"
// Config Base to Bds Maneger Core and others Projects
var Config = { var Config = {
paths: { paths: {
servers: join(bds_dir, "Servers"), servers: join(bds_dir, "Servers"),
@ -30,11 +28,7 @@ var Config = {
player: join(bds_dir, "Players.json") player: join(bds_dir, "Players.json")
}, },
bds: { bds: {
enable_tmp_host: false, enable_tmp_host: false
temelemetry: {
id: null,
load: false
}
}, },
server: { server: {
platform: default_platformConfig, platform: default_platformConfig,
@ -122,14 +116,6 @@ if (existsSync(ConfigPath)) Config = {
}; else writeFileSync(ConfigPath, yaml.stringify(Config)) }; else writeFileSync(ConfigPath, yaml.stringify(Config))
process.on("exit", ()=>SaveConfig()) process.on("exit", ()=>SaveConfig())
// Telemetry
if (Config.bds.temelemetry.load) {
if (!(Config.bds.temelemetry.id)) {
Config.bds.temelemetry.id = FetchSync(`https://telemetry.the-bds-maneger.org/getid?external_ip=${JSON.stringify(external_ip)}`).text()
SaveConfig()
}
}
// Paths // Paths
if (!(existsSync(Config.paths["backups"]))) mkdirSync(Config.paths["backups"], {recursive: true}) if (!(existsSync(Config.paths["backups"]))) mkdirSync(Config.paths["backups"], {recursive: true})
if (!(existsSync(Config.paths["log"]))) mkdirSync(Config.paths["log"], {recursive: true}) if (!(existsSync(Config.paths["log"]))) mkdirSync(Config.paths["log"], {recursive: true})
@ -149,108 +135,173 @@ for (let Servers of Object.getOwnPropertyNames(ServersPaths)) {
} }
} }
// return settings by function
function GetJsonConfig(){
return Config
}
// get the path from the settings and return by function
function GetPaths(path = null){
if (!(path)) throw new Error("Set path to get");
if (!(path === "all" || Config.paths[path])) throw new Error("Put a valid path: " + Object.getOwnPropertyNames(Config.paths).join(", "));
if (path === "all") return Config.paths
return Config.paths[path]
}
// Get the server paths if you don't send a throw
function GetServerPaths(path = null){
if (!(path)) throw new Error("Set path to get");
if (!(ServersPaths[path])) throw new Error("Put a valid path: " + Object.getOwnPropertyNames(ServersPaths).join(", "));
return ServersPaths[path]
}
// Get the server settings for now it's only being used in Java
function GetServerSettings(platform = Config.server.platform){
return Config.server.Settings[platform]
}
// Update the settings and save at the same time so as not to lose any information from the Bds Maneger settings
function UpdateServerVersion(version = null, platform = Config.server.platform){
if (Config.server.versions[platform] || Config.server.versions[platform] === null) {
Config.server.versions[platform] = version;
SaveConfig()
return Config.server.versions[platform]
} else throw new Error("Platform invalid")
}
// Return an Object with all server versions installed
function GetServerVersion(){
return Config.server.versions
}
// Catch Players/People from Servers/Telegram to be banned or removed from Server/Minecraft
function GetServerBan(){
return Config.ban
}
// Cron for Backup
function GetCronBackup(){
return Config.server.BackupCron
}
// Update the entire Bds Manager Core platform
function UpdatePlatform(platform = Config.server.platform){
platform = platform.toLocaleLowerCase();
if (/bedrock/.test(platform)) {
Config.server.platform = "bedrock";
SaveConfig()
} else if (/java/.test(platform)) {
Config.server.platform = "java";
SaveConfig()
} else if (/pocketmine/.test(platform)) {
Config.server.platform = "pocketmine";
SaveConfig()
} else if (/jsprismarine/.test(platform)) {
Config.server.platform = "jsprismarine";
SaveConfig()
} else throw new Error("platform no Exists")
return platform
}
// Return to platform
function GetPlatform(){
return Config.server.platform
}
// Telegram
function UpdateTelegramToken(token = null){
if (!(token)) throw new Error("Telegram Token invalid")
Config.telegram.token = token
SaveConfig()
return token
}
function GetTelegramToken(){
return Config.telegram.token
}
function GetTelegramAdmins(){
return Config.telegram.admins
}
// Get a temporary host to connect to the server.
function GetTempHost(){
return Config.bds.enable_tmp_host
}
// Enable and/or disable pick up temporary host.
function UpdateTempHost(enable = false){
// Check Boolean
if (typeof enable !== "boolean") {console.log("Use Boolean, default false"); enable = false;}
// Save
Config.bds.enable_tmp_host = enable
return SaveConfig();
}
// Get the server settings
function GetCloudConfig(cloud = null){
if (!(cloud) || !(Config.cloud[cloud])) throw new Error("Cloud no exists");
return Config.cloud[cloud]
}
// Settings Cloud
// Azure
function Azure_Settings(account = null, key = null, container = null){
if (!(account)) throw new Error("Set Azure Blob Account")
if (!(key)) throw new Error("Set Azure Blob Key")
if (!(container)) throw new Error("Set Azure Container")
Config.cloud.Azure.Account = account
Config.cloud.Azure.AccountKey = key
Config.cloud.Azure.Container = container
SaveConfig()
return {
Account: Config.cloud.Azure.Account,
Key: Config.cloud.Azure.AccountKey,
Container: Config.cloud.Azure.Container
}
}
// Oracle
function Oracle_Settings(bucket = null){
if (!(bucket)) throw new Error("Set Oracle Bucket name")
Config.cloud.Oracle.Bucket = bucket
return {
Bucket: bucket
}
}
// Google Drive
function Google_Driver_Settings(rootid = null){
if (!(rootid)) {rootid = null; console.log("No Backup folder id added for Google Driver");}
Config.cloud.Driver.RootID = rootid
SaveConfig()
return {
RootID: rootid
}
}
module.exports = { module.exports = {
bds_dir: bds_dir, bds_dir: bds_dir,
GetJsonConfig: function(){return Config}, GetJsonConfig,
GetPaths: function(path = null){ GetPaths,
if (!(path)) throw new Error("Set path to get"); GetServerPaths,
if (!(path === "all" || Config.paths[path])) throw new Error("Put a valid path: " + Object.getOwnPropertyNames(Config.paths).join(", ")); GetServerSettings,
if (path === "all") return Config.paths UpdateServerVersion,
return Config.paths[path] GetServerVersion,
}, GetServerBan,
GetServerPaths: function(path = null){ GetCronBackup,
if (!(path)) throw new Error("Set path to get"); UpdatePlatform,
if (!(ServersPaths[path])) throw new Error("Put a valid path: " + Object.getOwnPropertyNames(ServersPaths).join(", ")); GetPlatform,
return ServersPaths[path] UpdateTelegramToken,
}, GetTelegramToken,
GetServerSettings: function(platform = Config.server.platform){ GetTelegramAdmins,
return Config.server.Settings[platform] GetTempHost,
}, UpdateTempHost,
UpdateServerVersion: function(version = null, platform = Config.server.platform){ GetCloudConfig,
if (Config.server.versions[platform] || Config.server.versions[platform] === null) { CloudConfig: {
Config.server.versions[platform] = version; Azure: Azure_Settings,
SaveConfig() Oracle: Oracle_Settings,
return Config.server.versions[platform] Driver: Google_Driver_Settings
} else throw new Error("Platform invalid")
},
GetServerVersion: function(){return Config.server.versions},
GetServerBan: function (){return Config.ban},
GetCronBackup: function(){return Config.server.BackupCron},
UpdatePlatform: function(platform = Config.server.platform){
platform = platform.toLocaleLowerCase();
if (platform === "bedrock") {
Config.server.platform = "bedrock";
SaveConfig()
} else if (platform === "java") {
Config.server.platform = "java";
SaveConfig()
} else if (platform === "pocketmine") {
Config.server.platform = "pocketmine";
SaveConfig()
} else if (platform === "jsprismarine") {
Config.server.platform = "jsprismarine";
SaveConfig()
} else throw new Error("platform no Exists")
return platform
},
GetPlatform: function(){return Config.server.platform},
UpdateTelegramToken: function (token = null){
if (!(token)) throw new Error("Telegram Token invalid")
Config.telegram.token = token
SaveConfig()
return token
},
GetTelegramToken: function(){
return Config.telegram.token
},
GetTelegramAdmins: function(){
return Config.telegram.admins
},
GetTempHost: function(){return Config.bds.enable_tmp_host},
UpdateTempHost: function(enable = false){
// Check Boolean
if (typeof enable !== "boolean") {console.log("Use Boolean, default false"); enable = false;}
// Save
Config.bds.enable_tmp_host = enable
return SaveConfig();
},
CloudConfig: {},
GetCloudConfig: function(cloud = null){
if (!(cloud) || !(Config.cloud[cloud])) throw new Error("Cloud no exists");
return Config.cloud[cloud]
}
}
module.exports.CloudConfig = {
Azure: function(account = null, key = null, container = null){
if (!(account)) throw new Error("Set Azure Blob Account")
if (!(key)) throw new Error("Set Azure Blob Key")
if (!(container)) throw new Error("Set Azure Container")
Config.cloud.Azure.Account = account
Config.cloud.Azure.AccountKey = key
Config.cloud.Azure.Container = container
SaveConfig()
return {
Account: Config.cloud.Azure.Account,
Key: Config.cloud.Azure.AccountKey,
Container: Config.cloud.Azure.Container
}
},
Oracle: function(bucket = null){
if (!(bucket)) throw new Error("Set Oracle Bucket name")
Config.cloud.Oracle.Bucket = bucket
return {
Bucket: bucket
}
},
Google: function(){throw new Error("doesn't work yet")},
Driver: function(rootid = null){
if (!(rootid)) {rootid = null; console.log("No Backup folder id added for Google Driver");}
Config.cloud.Driver.RootID = rootid
SaveConfig()
return {
RootID: rootid
}
} }
} }

View File

@ -1,6 +1,5 @@
const fetchSync = require("@the-bds-maneger/fetchsync"); const fetchSync = require("@the-bds-maneger/fetchsync");
module.exports = { module.exports = {
Servers: fetchSync("https://raw.githubusercontent.com/The-Bds-Maneger/external_files/main/Server.json").json(), Servers: fetchSync("https://raw.githubusercontent.com/The-Bds-Maneger/external_files/main/Server.json").json(),
PHPBin: fetchSync("https://raw.githubusercontent.com/The-Bds-Maneger/Php_Static_Binary/main/binarys.json").json(), PHPBin: fetchSync("https://raw.githubusercontent.com/The-Bds-Maneger/Php_Static_Binary/main/binarys.json").json()
GoogleDriver: fetchSync("https://raw.githubusercontent.com/The-Bds-Maneger/external_files/main/Credentials/Google.json").json()
} }

View File

@ -1,37 +0,0 @@
const fetchSync = require("@the-bds-maneger/fetchsync");
const { external_ip, Interfaces } = require("../src/external_ip");
const { GetTempHost } = require("./BdsSettings")
if (GetTempHost()){
// Get HOST
const HostResponse = fetchSync("https://bds-core-back-end.vercel.app/Gethost", {
method: "POST",
mode: "cors",
body: JSON.stringify({
mac: Interfaces[0].MAC,
ip: external_ip.ipv4,
}),
headers: {
"Content-Type": "application/json"
}
}).json();
global.BdsTempHost = HostResponse.user.host.host
module.exports.host = HostResponse.user.host.host
module.exports.Response = HostResponse
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)
})
} else module.exports.host = null

121
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@the-bds-maneger/core", "name": "@the-bds-maneger/core",
"version": "1.13.2", "version": "1.13.4",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@the-bds-maneger/core", "name": "@the-bds-maneger/core",
"version": "1.13.2", "version": "1.13.4",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"dependencies": { "dependencies": {
"@azure/storage-blob": "^12.6.0", "@azure/storage-blob": "^12.6.0",
@ -14,7 +14,6 @@
"adm-zip": "^0.5.1", "adm-zip": "^0.5.1",
"body-parser": "^1.19.0", "body-parser": "^1.19.0",
"cors": "^2.8.5", "cors": "^2.8.5",
"create-desktop-shortcuts": "^1.4.0",
"cron": "^1.8.2", "cron": "^1.8.2",
"express": "^4.17.1", "express": "^4.17.1",
"express-fileupload": "^1.2.1", "express-fileupload": "^1.2.1",
@ -25,17 +24,19 @@
"minimist": "^1.2.5", "minimist": "^1.2.5",
"node-cron": "^3.0.0", "node-cron": "^3.0.0",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",
"node-localstorage": "^2.1.6",
"oci-sdk": "^2.0.0", "oci-sdk": "^2.0.0",
"open": "^8.0.0", "open": "^8.0.0",
"properties-to-json": "^0.2.1", "properties-to-json": "^0.2.1",
"request-ip": "^2.1.3", "request-ip": "^2.1.3",
"telegraf": "^4.0.0" "telegraf": "^4.0.0",
"uuid": "^8.3.2"
}, },
"bin": { "bin": {
"bds_maneger": "bin/bds_maneger.js" "bds_maneger": "bin/bds_maneger.js",
"bds_telegram": "bin/telegram_bot.js"
}, },
"devDependencies": { "devDependencies": {
"docker-run_build": "github:Sirherobrine23/Docker-Run_Build",
"eslint": "^7.19.0", "eslint": "^7.19.0",
"husky": "^7.0.0", "husky": "^7.0.0",
"nexe": "*", "nexe": "*",
@ -1429,14 +1430,6 @@
"node": ">= 0.10" "node": ">= 0.10"
} }
}, },
"node_modules/create-desktop-shortcuts": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/create-desktop-shortcuts/-/create-desktop-shortcuts-1.5.0.tgz",
"integrity": "sha512-XYRHuBKCfZHbHYHnltfX3HrxIMPWEGNaark+QQmAxeiqAlfMEViTEcJsi+MVMDJy5QXRkXM6bUh9xIWtONoCEw==",
"dependencies": {
"which": "^2.0.2"
}
},
"node_modules/cron": { "node_modules/cron": {
"version": "1.8.2", "version": "1.8.2",
"resolved": "https://registry.npmjs.org/cron/-/cron-1.8.2.tgz", "resolved": "https://registry.npmjs.org/cron/-/cron-1.8.2.tgz",
@ -1801,6 +1794,19 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/docker-run_build": {
"version": "1.0.0",
"resolved": "git+ssh://git@github.com/Sirherobrine23/Docker-Run_Build.git#dca7037ac2175352485e61e7e565ec1d81caa062",
"dev": true,
"license": "GPL-3.0-or-later",
"dependencies": {
"js-yaml": "^4.1.0",
"minimist": "^1.2.5"
},
"bin": {
"docker-run_build": "bin/cli.js"
}
},
"node_modules/doctrine": { "node_modules/doctrine": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
@ -2993,7 +2999,8 @@
"node_modules/graceful-fs": { "node_modules/graceful-fs": {
"version": "4.2.6", "version": "4.2.6",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz",
"integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==" "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==",
"dev": true
}, },
"node_modules/gtoken": { "node_modules/gtoken": {
"version": "5.3.0", "version": "5.3.0",
@ -3217,6 +3224,7 @@
"version": "0.1.4", "version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=",
"dev": true,
"engines": { "engines": {
"node": ">=0.8.19" "node": ">=0.8.19"
} }
@ -3461,7 +3469,8 @@
"node_modules/isexe": { "node_modules/isexe": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
"dev": true
}, },
"node_modules/isomorphic-fetch": { "node_modules/isomorphic-fetch": {
"version": "3.0.0", "version": "3.0.0",
@ -4177,17 +4186,6 @@
"node": ">= 6.0.0" "node": ">= 6.0.0"
} }
}, },
"node_modules/node-localstorage": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/node-localstorage/-/node-localstorage-2.2.1.tgz",
"integrity": "sha512-vv8fJuOUCCvSPjDjBLlMqYMHob4aGjkmrkaE42/mZr0VT+ZAU10jRF8oTnX9+pgU9/vYJ8P7YT3Vd6ajkmzSCw==",
"dependencies": {
"write-file-atomic": "^1.1.4"
},
"engines": {
"node": ">=0.12"
}
},
"node_modules/nodemon": { "node_modules/nodemon": {
"version": "2.0.12", "version": "2.0.12",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.12.tgz", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.12.tgz",
@ -6220,14 +6218,6 @@
"url": "https://github.com/chalk/slice-ansi?sponsor=1" "url": "https://github.com/chalk/slice-ansi?sponsor=1"
} }
}, },
"node_modules/slide": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz",
"integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=",
"engines": {
"node": "*"
}
},
"node_modules/sort-keys": { "node_modules/sort-keys": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz", "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz",
@ -6940,6 +6930,7 @@
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"dependencies": { "dependencies": {
"isexe": "^2.0.0" "isexe": "^2.0.0"
}, },
@ -6977,16 +6968,6 @@
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true "dev": true
}, },
"node_modules/write-file-atomic": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.4.tgz",
"integrity": "sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8=",
"dependencies": {
"graceful-fs": "^4.1.11",
"imurmurhash": "^0.1.4",
"slide": "^1.1.5"
}
},
"node_modules/xdg-basedir": { "node_modules/xdg-basedir": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz", "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz",
@ -8132,14 +8113,6 @@
"vary": "^1" "vary": "^1"
} }
}, },
"create-desktop-shortcuts": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/create-desktop-shortcuts/-/create-desktop-shortcuts-1.5.0.tgz",
"integrity": "sha512-XYRHuBKCfZHbHYHnltfX3HrxIMPWEGNaark+QQmAxeiqAlfMEViTEcJsi+MVMDJy5QXRkXM6bUh9xIWtONoCEw==",
"requires": {
"which": "^2.0.2"
}
},
"cron": { "cron": {
"version": "1.8.2", "version": "1.8.2",
"resolved": "https://registry.npmjs.org/cron/-/cron-1.8.2.tgz", "resolved": "https://registry.npmjs.org/cron/-/cron-1.8.2.tgz",
@ -8422,6 +8395,15 @@
"path-type": "^4.0.0" "path-type": "^4.0.0"
} }
}, },
"docker-run_build": {
"version": "git+ssh://git@github.com/Sirherobrine23/Docker-Run_Build.git#dca7037ac2175352485e61e7e565ec1d81caa062",
"dev": true,
"from": "docker-run_build@github:Sirherobrine23/Docker-Run_Build",
"requires": {
"js-yaml": "^4.1.0",
"minimist": "^1.2.5"
}
},
"doctrine": { "doctrine": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
@ -9380,7 +9362,8 @@
"graceful-fs": { "graceful-fs": {
"version": "4.2.6", "version": "4.2.6",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz",
"integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==" "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==",
"dev": true
}, },
"gtoken": { "gtoken": {
"version": "5.3.0", "version": "5.3.0",
@ -9532,7 +9515,8 @@
"imurmurhash": { "imurmurhash": {
"version": "0.1.4", "version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=" "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=",
"dev": true
}, },
"inflight": { "inflight": {
"version": "1.0.6", "version": "1.0.6",
@ -9711,7 +9695,8 @@
"isexe": { "isexe": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
"dev": true
}, },
"isomorphic-fetch": { "isomorphic-fetch": {
"version": "3.0.0", "version": "3.0.0",
@ -10281,14 +10266,6 @@
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz",
"integrity": "sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==" "integrity": "sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA=="
}, },
"node-localstorage": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/node-localstorage/-/node-localstorage-2.2.1.tgz",
"integrity": "sha512-vv8fJuOUCCvSPjDjBLlMqYMHob4aGjkmrkaE42/mZr0VT+ZAU10jRF8oTnX9+pgU9/vYJ8P7YT3Vd6ajkmzSCw==",
"requires": {
"write-file-atomic": "^1.1.4"
}
},
"nodemon": { "nodemon": {
"version": "2.0.12", "version": "2.0.12",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.12.tgz", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.12.tgz",
@ -12016,11 +11993,6 @@
"is-fullwidth-code-point": "^3.0.0" "is-fullwidth-code-point": "^3.0.0"
} }
}, },
"slide": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz",
"integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc="
},
"sort-keys": { "sort-keys": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz", "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz",
@ -12575,6 +12547,7 @@
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"requires": { "requires": {
"isexe": "^2.0.0" "isexe": "^2.0.0"
} }
@ -12600,16 +12573,6 @@
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true "dev": true
}, },
"write-file-atomic": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.4.tgz",
"integrity": "sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8=",
"requires": {
"graceful-fs": "^4.1.11",
"imurmurhash": "^0.1.4",
"slide": "^1.1.5"
}
},
"xdg-basedir": { "xdg-basedir": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz", "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz",

View File

@ -3,24 +3,24 @@
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
"version": "1.13.2", "version": "1.13.4",
"description": "Scripts to manage minecraft server's", "description": "Scripts to manage minecraft server's",
"private": false, "private": false,
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "node bin/bds_maneger.js -s", "start": "node bin/bds_maneger.js -s",
"start:telegram": "node bin/telegram_bot.js -e js",
"stop": "node -p 'console.log(require(\"./\").kill());'", "stop": "node -p 'console.log(require(\"./\").kill());'",
"test": "node .Build/test/ci.js", "test": "node .Build/test/ci.js",
"ci": "node .Build/test/ci.js", "ci": "node .Build/test/ci.js",
"eslint": "eslint --debug .", "eslint": "eslint --debug .",
"eslint:debug": "eslint --debug .", "eslint:fix": "eslint --debug --fix .",
"eslint:fix": "eslint --fix .",
"nexe": "node .Build/nexe_build.js", "nexe": "node .Build/nexe_build.js",
"Docker": "node .Build/DockerImage.js", "Docker": "node .Build/DockerImage.js"
"dev:telegram": "node bin/telegram_bot.js -e js"
}, },
"bin": { "bin": {
"bds_maneger": "./bin/bds_maneger.js" "bds_maneger": "./bin/bds_maneger.js",
"bds_telegram": "./bin/telegram_bot.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -39,18 +39,16 @@
"author": "Sirherobrine23", "author": "Sirherobrine23",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"bugs": { "bugs": {
"url": "https://github.com/The-Bds-Maneger/Bds-Maneger-Core/issues", "url": "https://github.com/The-Bds-Maneger/Bds-Maneger-Core/issues/new"
"email": "support@the-bds-maneger.org"
}, },
"homepage": "https://github.com/The-Bds-Maneger/Bds-Maneger-Core/", "homepage": "https://docs.bdsmaneger.com/Bds Maneger core",
"docs_base": "https://docs.the-bds-maneger.org/Bds Maneger core/",
"engines": { "engines": {
"node": ">=14", "node": ">=14",
"npm": ">=7" "npm": ">=7"
}, },
"husky": { "husky": {
"hooks": { "hooks": {
"post-merge": "npm update && npm install" "post-merge": "npm install --node-save -d"
} }
}, },
"dependencies": { "dependencies": {
@ -59,7 +57,6 @@
"adm-zip": "^0.5.1", "adm-zip": "^0.5.1",
"body-parser": "^1.19.0", "body-parser": "^1.19.0",
"cors": "^2.8.5", "cors": "^2.8.5",
"create-desktop-shortcuts": "^1.4.0",
"cron": "^1.8.2", "cron": "^1.8.2",
"express": "^4.17.1", "express": "^4.17.1",
"express-fileupload": "^1.2.1", "express-fileupload": "^1.2.1",
@ -70,14 +67,15 @@
"minimist": "^1.2.5", "minimist": "^1.2.5",
"node-cron": "^3.0.0", "node-cron": "^3.0.0",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",
"node-localstorage": "^2.1.6",
"oci-sdk": "^2.0.0", "oci-sdk": "^2.0.0",
"open": "^8.0.0", "open": "^8.0.0",
"properties-to-json": "^0.2.1", "properties-to-json": "^0.2.1",
"request-ip": "^2.1.3", "request-ip": "^2.1.3",
"telegraf": "^4.0.0" "telegraf": "^4.0.0",
"uuid": "^8.3.2"
}, },
"devDependencies": { "devDependencies": {
"docker-run_build": "github:Sirherobrine23/Docker-Run_Build",
"eslint": "^7.19.0", "eslint": "^7.19.0",
"husky": "^7.0.0", "husky": "^7.0.0",
"nexe": "*", "nexe": "*",

View File

@ -44,7 +44,7 @@ function Backup() {
for (let index of Object.getOwnPropertyNames(GetPaths("all")).filter(path => !/servers|backups/.test(path)).map(name => GetPaths(name))) { for (let index of Object.getOwnPropertyNames(GetPaths("all")).filter(path => !/servers|backups/.test(path)).map(name => GetPaths(name))) {
if (existsSync(index)) { if (existsSync(index)) {
const _S = statSync(resolve(index)); const _S = statSync(resolve(index));
if (_S.isFile() || _S.isSymbolicLink()) zip.addLocalFile(index); else zip.addLocalFolder(index) if (_S.isFile() || _S.isSymbolicLink()) zip.addLocalFile(index, "/BdsManegerCore"); else zip.addLocalFolder(index, join("/BdsManegerCore", index.replace(bds_dir, "")));
} }
} }

View File

@ -2,10 +2,10 @@ const child_process = require("child_process");
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
const { resolve, join } = require("path"); const { resolve, join } = require("path");
const { randomUUID } = require("crypto"); const randomUUID = require("uuid").v4;
const { CronJob } = require("cron"); const { CronJob } = require("cron");
const { GetCronBackup } = require("../lib/BdsSettings"); const { GetCronBackup } = require("../lib/BdsSettings");
const { Backup } = require("./backups"); const { Backup } = require("./BdsBackup");
// Bds Maneger Inports // Bds Maneger Inports
const commandExists = require("../lib/commandExist"); const commandExists = require("../lib/commandExist");
@ -167,6 +167,34 @@ function start() {
}); });
ServerExec.stdout.on("data", data); ServerExec.stdout.on("data", data);
ServerExec.stderr.on("data", data); ServerExec.stderr.on("data", data);
},
op: function (player = "Steve") {
let command = BdsInfo.Servers[GetPlatform()].op.replace("{{Player}}", player);
ServerExec.stdin.write(command+"\n");
return command;
},
deop: function (player = "Steve") {
let command = BdsInfo.Servers[GetPlatform()].deop.replace("{{Player}}", player);
ServerExec.stdin.write(command+"\n");
return command;
},
ban: function (player = "Steve") {
let command = BdsInfo.Servers[GetPlatform()].ban.replace("{{Player}}", player);
ServerExec.stdin.write(command+"\n");
return command;
},
kick: function (player = "Steve", text = "you got kicked") {
let command = BdsInfo.Servers[GetPlatform()].kick.replace("{{Player}}", player).replace("{{Text}}", text);
ServerExec.stdin.write(command+"\n");
return command;
},
tp: function (player = "Steve", cord = {x: 0, y: 128, z: 0}) {
let command = BdsInfo.Servers[GetPlatform()].tp.replace("{{Player}}", player);
if (cord.x) command = command.replace("{{X}}", cord.x); else command = command.replace("{{X}}", 0);
if (cord.y) command = command.replace("{{Y}}", cord.y); else command = command.replace("{{Y}}", 128);
if (cord.y) command = command.replace("{{Z}}", cord.y); else command = command.replace("{{Z}}", 0);
ServerExec.stdin.write(command+"\n");
return command;
} }
} }
ServerExec.on("exit", ()=>{delete global.BdsExecs[returnFuntion.uuid]}); ServerExec.on("exit", ()=>{delete global.BdsExecs[returnFuntion.uuid]});

89
src/BdsNetwork.js Normal file
View File

@ -0,0 +1,89 @@
// External User ip
const fetchSync = require("@the-bds-maneger/fetchsync");
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", "")
}
// Internal ip user
const interfaces = os.networkInterfaces();
const internal_ip = [];
for (let inter of Object.getOwnPropertyNames(interfaces).map(index => interfaces[index])){
for (let ind in inter){
if (inter[ind].address.includes("::")) internal_ip.push(`[${inter[ind].address}]`)
else internal_ip.push(inter[ind].address)
}
}
// Network Interfaces
const Interfaces = Object.getOwnPropertyNames(interfaces).map(inter => {
inter = interfaces[inter]
if (inter[0].mac !== "00:00:00:00:00:00") {
try {
return {
MAC: inter[0].mac,
Interna_IP: {
ipv4: inter[0].address,
ipv6: inter[1].address,
}
}
} catch (err) {
return {
MAC: inter[0].mac,
Interna_IP: {
ipv4: inter[0].address,
ipv6: null,
}
}
}
}
}).filter(a=>a);
// Temp Host
var host = null,
HostResponse = null;
if (GetTempHost()){
// Get HOST
HostResponse = fetchSync("https://bds-core-back-end.vercel.app/Gethost", {
method: "POST",
mode: "cors",
body: JSON.stringify({
mac: Interfaces[0].MAC,
ip: external_ip.ipv4,
}),
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)
})
} else module.exports.host = null
module.exports = {
externalIP,
ip: externalIP,
internal_ip,
Interfaces,
HostResponse,
host,
}

View File

@ -1,43 +1,47 @@
const { execSync } = require("child_process"); const { execSync } = require("child_process");
function getProcess(){ function getProcess(){
const MountProcess = []; let MountProcess = [];
var getList = ""
if (process.platform === "win32") { if (process.platform === "win32") {
console.info("Getting the process list in Windows is too slow"); MountProcess = execSync("wmic path win32_process get Processid,Commandline,WorkingSetSize").toString().split(/\n/gi).filter(a => a.trim()).map(Line => {
getList = execSync("tasklist").toString("utf8").split("\r").join("\n").split("\n").filter(d => {return !(d === "" || d.includes("====="))}) try {
delete getList[0]; Line = Line.split(/\r/gi).filter(a => a).join("").trim();
getList = getList.filter(d=>{return (d !== undefined)}) const line_split = Line.split(/\s+/gi);
for (let _line of getList) {
_line = _line.split(/\s+/)
// Get argument: wmic process where "ProcessID=4152" get commandline
const pidNumber = (_line.length - 5)
MountProcess.push({
command: (function(){
try {
return execSync(`wmic process where "ProcessID=${_line[pidNumber]}" get commandline`).toString("utf8").split("\r").join("\n").split("\n").filter(d=>{return !(d.trim() === "" || d.trim() === "CommandLine")}).join(" ").trim().split("\"").join("").trim()
} catch (err) {
return null
}
})(),
pid: parseInt(_line[pidNumber]),
cpu: _line[(_line.length - 3)],
mem: (_line[(_line.length - 2)].split(".").join("")),
})
}
} else {
getList = execSync("ps -aux").toString("utf8").split("\n").filter(d=>{return !(/USER\s+/.test(d) || d === "")})
for (let _line of getList) {
_line = _line.split(/\s+/)
MountProcess.push({
command: (function(){var command = _line[10];const argvLenght = (_line.length - 11);for (let index = 0; index < argvLenght; index++) {command += ` ${_line[11 + index]}`;} return command})(),
pid: parseInt(_line[1]),
cpu: _line[2],
mem: _line[3],
})
}
}
// Ignore empty lines
if (line_split.length <= 2) return false
let pid = line_split[Math.abs(line_split.length - 2)].toString();
let mem = line_split[Math.abs(line_split.length - 1)].toString();
let command = Line.slice(0, - Math.abs(pid.length)).trim().slice(0, - Math.abs(mem.length)).trim();
pid = parseInt(pid);
mem = parseInt(mem);
if (command && pid && mem) return {
command,
pid,
mem,
}; else return false
} catch (err) {
console.log(err);
return false
}
}).filter(a => a);
} else {
MountProcess = execSync("ps -aux").toString("utf8").split("\n").filter(d=>{return !(/USER\s+/.test(d) || d === "")}).map(_line => _line.split(/\s+/)).map(_line =>{
return {
command: (function(){
var command = _line[10];
const argvLenght = (_line.length - 11);
for (let index = 0; index < argvLenght; index++) {
command += ` ${_line[11 + index]}`;
}
return command;
})(),
pid: parseInt(_line[1]),
mem: _line[3],
}
})
}
return MountProcess; return MountProcess;
} }

View File

@ -1,5 +1,5 @@
const bds = require("../index") const bds = require("../index")
const { CheckBan } = require("./check"); const { CheckBan } = require("./UsersAndtokenChecks");
const { GetPlatform, GetPaths } = require("../lib/BdsSettings"); const { GetPlatform, GetPaths } = require("../lib/BdsSettings");
const fs = require("fs"); const fs = require("fs");

View File

@ -2,21 +2,19 @@ const { bds_dir, GetServerBan, GetTelegramAdmins, GetPlatform, GetPaths } = requ
const { existsSync, readFileSync } = require("fs") const { existsSync, readFileSync } = require("fs")
const { join } = require("path") const { join } = require("path")
module.exports.checkUser = function (admin_name){ function CheckTelegramUser(admin_name){
var adm = GetTelegramAdmins(); for(let admin_check of GetTelegramAdmins()){
for(let check_ in adm){
const admin_check = adm[check_]
if (admin_name === admin_check || admin_check === "all_users") return true; if (admin_name === admin_check || admin_check === "all_users") return true;
} }
return false return false
} }
module.exports.CheckPlayer = function (player = "null"){ function CheckPlayer(player = "null"){
const json = require(GetPaths("player"))[GetPlatform()]; const json = require(GetPaths("player"))[GetPlatform()];
if (json[player]) return true; else return false if (json[player]) return true; else return false
} }
module.exports.token_verify = function (token){ function token_verify(token){
const path_tokens = join(bds_dir, "bds_tokens.json") const path_tokens = join(bds_dir, "bds_tokens.json")
if (existsSync(path_tokens)) var tokens = JSON.parse(readFileSync(path_tokens, "utf8")); else return false if (existsSync(path_tokens)) var tokens = JSON.parse(readFileSync(path_tokens, "utf8")); else return false
for (let token_verify of tokens) { for (let token_verify of tokens) {
@ -26,7 +24,7 @@ module.exports.token_verify = function (token){
return false return false
} }
module.exports.CheckBan = function (player){ function CheckBan(player){
var players = GetServerBan(); var players = GetServerBan();
for(let check_ in players){ for(let check_ in players){
const admin_check = players[check_] const admin_check = players[check_]
@ -36,3 +34,10 @@ module.exports.CheckBan = function (player){
} }
return false return false
} }
module.exports = {
CheckTelegramUser,
CheckPlayer,
CheckBan,
token_verify
}

View File

@ -4,7 +4,7 @@ const { randomUUID } = require("crypto");
const express = require("express"); const express = require("express");
const { google } = require("googleapis"); const { google } = require("googleapis");
const ip_andress = require("../../external_ip"); const ip_andress = require("../../BdsNetwork");
const { bds_dir } = require("../../../lib/BdsSettings"); const { bds_dir } = require("../../../lib/BdsSettings");
const PathToToken = join(bds_dir, "google_user_token.json"); const PathToToken = join(bds_dir, "google_user_token.json");

View File

@ -1,46 +0,0 @@
// External User ip
const fetchSync = require("@the-bds-maneger/fetchsync");
const os = require("os")
const externalIP = {
ipv4: fetchSync("https://api.ipify.org/").text().replace("\n", ""),
ipv6: fetchSync("https://api64.ipify.org/").text().replace("\n", "")
}
module.exports.external_ip = externalIP
module.exports.ip = externalIP
// Internal ip user
const interfaces = os.networkInterfaces();
const internal_ip = []
for (let index of Object.getOwnPropertyNames(require("os").networkInterfaces())){
const inter = interfaces[index]
for (let ind in inter){
if (inter[ind].address.includes("::")) internal_ip.push(`[${inter[ind].address}]`)
else internal_ip.push(inter[ind].address)
}
}
module.exports.internal_ip = internal_ip
// Network Interfaces
const a = os.networkInterfaces();
module.exports.Interfaces = Object.getOwnPropertyNames(a).map(inter => {
inter = a[inter]
if (inter[0].mac !== "00:00:00:00:00:00") {
try {
return {
MAC: inter[0].mac,
Interna_IP: {
ipv4: inter[0].address,
ipv6: inter[1].address,
}
}
} catch (err) {
return {
MAC: inter[0].mac,
Interna_IP: {
ipv4: inter[0].address,
ipv6: null,
}
}
}
}
}).filter(a=>a)

View File

@ -62,7 +62,7 @@ function api(port_api = 1932, callback = function (port){console.log("Bds Manege
} }
module.exports = function (apiConfig = {api_port: 1932}, callback = function (port){console.log("Bds Maneger Core REST API, http port", port)}){ module.exports = function (apiConfig = {api_port: 1932}, callback = function (port){console.log("Bds Maneger Core REST API, http port", port)}){
var port_rest = 1932; var port_rest = 1932;
if (typeof apiConfig == "object" && apiConfig.api_port !== undefined) port_rest = apiConfig.api_port; if (typeof apiConfig === "object" && apiConfig.api_port !== undefined) port_rest = apiConfig.api_port;
else if (typeof apiConfig === "number") port_rest = apiConfig; else if (typeof apiConfig === "number") port_rest = apiConfig;
return api(port_rest, callback); return api(port_rest, callback);
} }

View File

@ -5,7 +5,7 @@ const commandExist = require("../../../lib/commandExist");
const { GetPlatform, GetServerVersion, UpdatePlatform, bds_dir } = require("../../../lib/BdsSettings"); const { GetPlatform, GetServerVersion, UpdatePlatform, bds_dir } = require("../../../lib/BdsSettings");
const admzip = require("adm-zip"); const admzip = require("adm-zip");
const bds = require("../../../index"); const bds = require("../../../index");
const { token_verify } = require("../../check"); const { token_verify } = require("../../UsersAndtokenChecks");
// Backup // Backup
app.get("/backup", (req, res) => { app.get("/backup", (req, res) => {

View File

@ -2,7 +2,7 @@ const express = require("express");
const app = express.Router(); const app = express.Router();
const { GetPlatform } = require("../../../lib/BdsSettings") const { GetPlatform } = require("../../../lib/BdsSettings")
const bds = require("../../../index"); const bds = require("../../../index");
const { token_verify, CheckPlayer } = require("../../check"); const { token_verify, CheckPlayer } = require("../../UsersAndtokenChecks");
const { readFileSync } = require("fs"); const { readFileSync } = require("fs");
const docs = require("../../../BdsManegerInfo.json").docs; const docs = require("../../../BdsManegerInfo.json").docs;