Docker image fix #158
@@ -19,7 +19,13 @@
|
|||||||
"smcpeak.default-keys-windows",
|
"smcpeak.default-keys-windows",
|
||||||
"vscode-icons-team.vscode-icons",
|
"vscode-icons-team.vscode-icons",
|
||||||
"me-dutour-mathieu.vscode-github-actions",
|
"me-dutour-mathieu.vscode-github-actions",
|
||||||
"cschleiden.vscode-github-actions"
|
"cschleiden.vscode-github-actions",
|
||||||
|
"github.copilot",
|
||||||
|
"eamodio.gitlens",
|
||||||
|
"github.vscode-pull-request-github",
|
||||||
|
"oderwat.indent-rainbow",
|
||||||
|
"visualstudioexptteam.vscodeintellicode",
|
||||||
|
"redhat.vscode-yaml"
|
||||||
],
|
],
|
||||||
|
|
||||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
"browser": true,
|
"browser": true,
|
||||||
"commonjs": true,
|
"commonjs": true,
|
||||||
"es2021": true,
|
"es2021": true,
|
||||||
"node": true,
|
"node": true
|
||||||
"shelljs": true
|
|
||||||
},
|
},
|
||||||
"globals": {
|
"globals": {
|
||||||
"bds_log_string": "writable",
|
"bds_log_string": "writable",
|
||||||
@@ -24,6 +23,7 @@
|
|||||||
"error",
|
"error",
|
||||||
"double"
|
"double"
|
||||||
],
|
],
|
||||||
"eqeqeq": 0
|
"eqeqeq": 0,
|
||||||
|
"no-async-promise-executor": "off"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
5
.gitattributes
vendored
5
.gitattributes
vendored
@@ -1 +1,4 @@
|
|||||||
*.sh text=lf eol=lf
|
*.sh text=LF eol=LF
|
||||||
|
.devcontainer/* eol=LF text=LF
|
||||||
|
*.js text=LF eol=LF
|
||||||
|
* text=CRLF eol=CRLF
|
||||||
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@master
|
||||||
- name: Npm and Node Setup
|
- name: Npm and Node Setup
|
||||||
uses: actions/setup-node@v2.3.0
|
uses: actions/setup-node@v2.4.0
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 16.x
|
||||||
registry-url: https://registry.npmjs.org/
|
registry-url: https://registry.npmjs.org/
|
||||||
|
|||||||
2
.github/workflows/package_test.yml
vendored
2
.github/workflows/package_test.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v2.3.0
|
uses: actions/setup-node@v2.4.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
|
|||||||
2
.github/workflows/rc.yml
vendored
2
.github/workflows/rc.yml
vendored
@@ -9,7 +9,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
- uses: actions/setup-node@v2.3.0
|
- uses: actions/setup-node@v2.4.0
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 16.x
|
||||||
registry-url: https://registry.npmjs.org/
|
registry-url: https://registry.npmjs.org/
|
||||||
|
|||||||
2
.github/workflows/tag_version.yml
vendored
2
.github/workflows/tag_version.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
- uses: actions/setup-node@v2.3.0
|
- uses: actions/setup-node@v2.4.0
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 16.x
|
||||||
registry-url: https://registry.npmjs.org/
|
registry-url: https://registry.npmjs.org/
|
||||||
|
|||||||
13
.vscode/launch.json
vendored
13
.vscode/launch.json
vendored
@@ -4,19 +4,14 @@
|
|||||||
{
|
{
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Docker Build and Run",
|
"name": "Start Telegram bot dev",
|
||||||
"program": "${workspaceFolder}/.Build/DockerImage.js"
|
"program": "${workspaceFolder}/bin/telegram_bot.js"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Telegram BOT",
|
"name": "Docker Build and Run",
|
||||||
"runtimeExecutable": "npm",
|
"program": "${workspaceFolder}/.Build/DockerImage.js",
|
||||||
"runtimeArgs": [
|
|
||||||
"run",
|
|
||||||
"dev:telegram"
|
|
||||||
],
|
|
||||||
"port": 9229
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -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": [
|
||||||
|
|||||||
23
README.md
23
README.md
@@ -8,19 +8,21 @@ 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.
|
||||||
|
|
||||||
## CI/CD tests
|
## 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
|
||||||
|
|
||||||
[](https://github.com/The-Bds-Maneger/Bds-Maneger-Core/actions/workflows/codeql%20and%20ossar%20analysis.yml)
|
[](https://github.com/The-Bds-Maneger/Bds-Maneger-Core/actions/workflows/codeql%20and%20ossar%20analysis.yml)
|
||||||
[](https://the-bds-maneger.org/The-Bds-Maneger/Bds-Maneger-Core/-/pipelines/latest)
|
|
||||||
|
|
||||||
[](https://lgtm.com/projects/g/Bds-Maneger/bds_maneger_api/alerts/)
|
[](https://lgtm.com/projects/g/Bds-Maneger/bds_maneger_api/alerts/)
|
||||||
[](https://lgtm.com/projects/g/Bds-Maneger/bds_maneger_api/context:javascript)
|
[](https://lgtm.com/projects/g/Bds-Maneger/bds_maneger_api/context:javascript)
|
||||||
[](https://www.codacy.com/gh/The-Bds-Maneger/Bds-Maneger-Core/dashboard?utm_source=github.com&utm_medium=referral&utm_content=The-Bds-Maneger/Bds-Maneger-Core&utm_campaign=Badge_Grade)
|
[](https://deepscan.io/dashboard#view=project&tid=13683&pid=16691&bid=363172)
|
||||||
[](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 ^
|
||||||
@@ -37,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 \
|
||||||
@@ -54,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.
|
|
||||||
|
|
||||||
[](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.
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
#!/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");
|
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;
|
||||||
|
|
||||||
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/Scripts/download");
|
const download = require("../src/BdsServersDownload");
|
||||||
process.env.IS_BDS_CLI = process.env.IS_BIN_BDS = true;
|
|
||||||
// Bds Maneger ArgV
|
// Bds Maneger ArgV
|
||||||
const argv = require("minimist")(process.argv.slice(2));
|
const argv = require("minimist")(process.argv.slice(2));
|
||||||
if (Object.getOwnPropertyNames(argv).length <= 1) argv.help = true
|
if (Object.getOwnPropertyNames(argv).length <= 1) argv.help = true
|
||||||
@@ -32,7 +35,7 @@ if (kill) bds.kill();
|
|||||||
if (server) UpdatePlatform(server);
|
if (server) UpdatePlatform(server);
|
||||||
|
|
||||||
function StartServer(){
|
function StartServer(){
|
||||||
const { Servers } = require("../../lib/ServerURL");
|
const { Servers } = require("../lib/ServerURL");
|
||||||
// Check Server Update
|
// Check Server Update
|
||||||
if (Versions[GetPlatform()] !== null) {
|
if (Versions[GetPlatform()] !== null) {
|
||||||
if (Versions[GetPlatform()] !== Servers.latest[GetPlatform()]) {
|
if (Versions[GetPlatform()] !== Servers.latest[GetPlatform()]) {
|
||||||
@@ -56,9 +59,22 @@ function StartServer(){
|
|||||||
|
|
||||||
// CLI Commands
|
// CLI Commands
|
||||||
const rl = readline.createInterface({input: process.stdin,output: process.stdout});
|
const rl = readline.createInterface({input: process.stdin,output: process.stdout});
|
||||||
rl.on("line", (input) => {if (input === "@stop") {rl.close(); bds_server.stop()} else bds_server.command(input)});
|
rl.on("line", (input) => {
|
||||||
rl.on("close", ()=>{console.log("CTRL + C closed readline, stopping server");bds_server.stop()})
|
// Stop
|
||||||
bds_server.exit(function(c){if (c !== 0) rl.close()})
|
if (input.trim() === "@stop") {
|
||||||
|
rl.close();
|
||||||
|
bds_server.stop()
|
||||||
|
}
|
||||||
|
// Server input
|
||||||
|
else bds_server.command(input);
|
||||||
|
});
|
||||||
|
rl.on("close", ()=>{
|
||||||
|
console.log("CTRL + C closed readline, stopping server");
|
||||||
|
bds_server.stop();
|
||||||
|
})
|
||||||
|
bds_server.exit(function(c){
|
||||||
|
if (c !== 0) rl.close();
|
||||||
|
})
|
||||||
bds.api();
|
bds.api();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`Bds Maneger Start Server Error: \n******\n${err}`);
|
console.log(`Bds Maneger Start Server Error: \n******\n${err}`);
|
||||||
|
|||||||
344
bin/telegram_bot.js
Normal file → Executable file
344
bin/telegram_bot.js
Normal file → Executable 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/Scripts/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");
|
||||||
120
index.js
120
index.js
@@ -2,7 +2,11 @@
|
|||||||
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(),
|
||||||
yaer = today.getFullYear(),
|
yaer = today.getFullYear(),
|
||||||
@@ -25,44 +29,43 @@ 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
|
||||||
const { arch } = require("./lib/BdsSystemInfo");
|
const { arch } = require("./lib/BdsSystemInfo");
|
||||||
|
|
||||||
const { GetPaths, GetJsonConfig, UpdatePlatform, UpdateTelegramToken, GetTelegramToken } = require("./lib/BdsSettings")
|
|
||||||
module.exports.arch = arch
|
module.exports.arch = arch
|
||||||
if (typeof fetch === "undefined") global.fetch = require("node-fetch");
|
|
||||||
|
|
||||||
const maneger_ips = require("./src/Scripts/external_ip")
|
const { GetJsonConfig, UpdatePlatform, UpdateTelegramToken } = require("./lib/BdsSettings");
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Old Method Config
|
||||||
|
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
|
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");
|
module.exports.api = require("./src/rest/api");
|
||||||
|
|
||||||
// ------------
|
|
||||||
const user_file_connected = GetPaths("player");
|
|
||||||
module.exports.players_files = user_file_connected
|
|
||||||
if (!(fs.existsSync(user_file_connected))) {
|
|
||||||
let config = {};
|
|
||||||
config["bedrock"] = {};
|
|
||||||
config["java"] = {};
|
|
||||||
config["pocketmine"] = {};
|
|
||||||
config["jsprismarine"] = {};
|
|
||||||
let NewJson = JSON.stringify(config, null, 4);
|
|
||||||
fs.writeFileSync(user_file_connected, NewJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
const file_user_check = fs.readFileSync(user_file_connected, "utf8");
|
|
||||||
try {
|
|
||||||
JSON.parse(file_user_check)
|
|
||||||
} catch (error) {
|
|
||||||
fs.renameSync(user_file_connected, `${user_file_connected}_old_${Math.random()}_${new Date().getDate()}_${new Date().getMonth()}_${new Date().getFullYear()}.json`)
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.telegram_token = GetTelegramToken();
|
|
||||||
|
|
||||||
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");
|
||||||
if (!(fs.existsSync(bds_token_path))) fs.writeFileSync(bds_token_path, "[]");
|
if (!(fs.existsSync(bds_token_path))) fs.writeFileSync(bds_token_path, "[]");
|
||||||
@@ -83,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/Scripts/backups");
|
|
||||||
const { config, get_config, config_example } = require("./src/Scripts/ServerSettings");
|
|
||||||
const download = require("./src/Scripts/download");
|
|
||||||
const { start, stop, BdsCommand } = require("./src/Scripts/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
|
||||||
*
|
*
|
||||||
@@ -101,6 +93,17 @@ const { start, stop, BdsCommand } = require("./src/Scripts/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
|
||||||
*/
|
*/
|
||||||
@@ -114,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
|
||||||
*
|
*
|
||||||
@@ -121,23 +125,27 @@ 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
|
||||||
*/
|
*/
|
||||||
module.exports.backup = World_BAckup
|
module.exports.backup = World_BAckup
|
||||||
|
|
||||||
const { Kill, Detect } = require("./src/Scripts/CheckKill")
|
const { Kill, Detect } = require("./src/CheckKill")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* identify if there are any servers running in the background
|
* identify if there are any servers running in the background
|
||||||
*
|
*
|
||||||
* @example bds.detect()
|
* @example bds.detect()
|
||||||
* // true: if the server is running
|
* true: if the server is running
|
||||||
* // false: if not already
|
* false: if not already
|
||||||
*/
|
*/
|
||||||
module.exports.detect = Detect
|
module.exports.detect = Detect
|
||||||
module.exports.bds_detect = Detect
|
module.exports.bds_detect = Detect
|
||||||
@@ -153,19 +161,18 @@ 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
|
||||||
*
|
*
|
||||||
* @example bds.set_config({
|
* @example set_config({
|
||||||
name: "Bedrock our Java",
|
name: "Bedrock our Java",
|
||||||
description: "BDS Maneger",
|
description: "BDS Maneger",
|
||||||
gamemode: "survival",
|
gamemode: "survival",
|
||||||
@@ -177,23 +184,16 @@ module.exports.config_example = config_example
|
|||||||
players: 100,
|
players: 100,
|
||||||
port: 19132,
|
port: 19132,
|
||||||
port6: 19133
|
port6: 19133
|
||||||
})
|
});
|
||||||
*/
|
*/
|
||||||
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
|
||||||
*/
|
*/
|
||||||
module.exports.Cron_Loaded = require("./src/Scripts/LoadCronBackup")
|
module.exports.Cron_Loaded = CronBackups;
|
||||||
|
|||||||
@@ -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/Scripts/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)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
// return settings by function
|
||||||
bds_dir: bds_dir,
|
function GetJsonConfig(){
|
||||||
GetJsonConfig: function(){return Config},
|
return Config
|
||||||
GetPaths: function(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(", "));
|
// get the path from the settings and return by function
|
||||||
if (path === "all") return Config.paths
|
function GetPaths(path = null){
|
||||||
return Config.paths[path]
|
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(", "));
|
||||||
GetServerPaths: function(path = null){
|
if (path === "all") return Config.paths
|
||||||
if (!(path)) throw new Error("Set path to get");
|
return Config.paths[path]
|
||||||
if (!(ServersPaths[path])) throw new Error("Put a valid path: " + Object.getOwnPropertyNames(ServersPaths).join(", "));
|
}
|
||||||
return ServersPaths[path]
|
|
||||||
},
|
// Get the server paths if you don't send a throw
|
||||||
GetServerSettings: function(platform = Config.server.platform){
|
function GetServerPaths(path = null){
|
||||||
return Config.server.Settings[platform]
|
if (!(path)) throw new Error("Set path to get");
|
||||||
},
|
if (!(ServersPaths[path])) throw new Error("Put a valid path: " + Object.getOwnPropertyNames(ServersPaths).join(", "));
|
||||||
UpdateServerVersion: function(version = null, platform = Config.server.platform){
|
return ServersPaths[path]
|
||||||
if (Config.server.versions[platform] || Config.server.versions[platform] === null) {
|
}
|
||||||
Config.server.versions[platform] = version;
|
|
||||||
SaveConfig()
|
// Get the server settings for now it's only being used in Java
|
||||||
return Config.server.versions[platform]
|
function GetServerSettings(platform = Config.server.platform){
|
||||||
} else throw new Error("Platform invalid")
|
return Config.server.Settings[platform]
|
||||||
},
|
}
|
||||||
GetServerVersion: function(){return Config.server.versions},
|
|
||||||
GetServerBan: function (){return Config.ban},
|
// Update the settings and save at the same time so as not to lose any information from the Bds Maneger settings
|
||||||
GetCronBackup: function(){return Config.server.BackupCron},
|
function UpdateServerVersion(version = null, platform = Config.server.platform){
|
||||||
UpdatePlatform: function(platform = Config.server.platform){
|
if (Config.server.versions[platform] || Config.server.versions[platform] === null) {
|
||||||
platform = platform.toLocaleLowerCase();
|
Config.server.versions[platform] = version;
|
||||||
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()
|
SaveConfig()
|
||||||
return token
|
return Config.server.versions[platform]
|
||||||
},
|
} else throw new Error("Platform invalid")
|
||||||
GetTelegramToken: function(){
|
}
|
||||||
return Config.telegram.token
|
|
||||||
},
|
// Return an Object with all server versions installed
|
||||||
GetTelegramAdmins: function(){
|
function GetServerVersion(){
|
||||||
return Config.telegram.admins
|
return Config.server.versions
|
||||||
},
|
}
|
||||||
GetTempHost: function(){return Config.bds.enable_tmp_host},
|
|
||||||
UpdateTempHost: function(enable = false){
|
// Catch Players/People from Servers/Telegram to be banned or removed from Server/Minecraft
|
||||||
// Check Boolean
|
function GetServerBan(){
|
||||||
if (typeof enable !== "boolean") {console.log("Use Boolean, default false"); enable = false;}
|
return Config.ban
|
||||||
|
}
|
||||||
// Save
|
|
||||||
Config.bds.enable_tmp_host = enable
|
// Cron for Backup
|
||||||
return SaveConfig();
|
function GetCronBackup(){
|
||||||
},
|
return Config.server.BackupCron
|
||||||
CloudConfig: {},
|
}
|
||||||
GetCloudConfig: function(cloud = null){
|
|
||||||
if (!(cloud) || !(Config.cloud[cloud])) throw new Error("Cloud no exists");
|
// Update the entire Bds Manager Core platform
|
||||||
return Config.cloud[cloud]
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.CloudConfig = {
|
// Oracle
|
||||||
Azure: function(account = null, key = null, container = null){
|
function Oracle_Settings(bucket = null){
|
||||||
if (!(account)) throw new Error("Set Azure Blob Account")
|
if (!(bucket)) throw new Error("Set Oracle Bucket name")
|
||||||
if (!(key)) throw new Error("Set Azure Blob Key")
|
Config.cloud.Oracle.Bucket = bucket
|
||||||
if (!(container)) throw new Error("Set Azure Container")
|
return {
|
||||||
Config.cloud.Azure.Account = account
|
Bucket: bucket
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 = {
|
||||||
|
bds_dir: bds_dir,
|
||||||
|
GetJsonConfig,
|
||||||
|
GetPaths,
|
||||||
|
GetServerPaths,
|
||||||
|
GetServerSettings,
|
||||||
|
UpdateServerVersion,
|
||||||
|
GetServerVersion,
|
||||||
|
GetServerBan,
|
||||||
|
GetCronBackup,
|
||||||
|
UpdatePlatform,
|
||||||
|
GetPlatform,
|
||||||
|
UpdateTelegramToken,
|
||||||
|
GetTelegramToken,
|
||||||
|
GetTelegramAdmins,
|
||||||
|
GetTempHost,
|
||||||
|
UpdateTempHost,
|
||||||
|
GetCloudConfig,
|
||||||
|
CloudConfig: {
|
||||||
|
Azure: Azure_Settings,
|
||||||
|
Oracle: Oracle_Settings,
|
||||||
|
Driver: Google_Driver_Settings
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -77,11 +77,11 @@ function GetKernel() {
|
|||||||
else return `Amazon AWS Cloud ${process.arch}: ${require("os").cpus()[0].model}`;
|
else return `Amazon AWS Cloud ${process.arch}: ${require("os").cpus()[0].model}`;
|
||||||
|
|
||||||
// Windows WSL 1
|
// Windows WSL 1
|
||||||
|
case /WSL2|microsft/.test(str):
|
||||||
|
return "Microsoft WSL 2";
|
||||||
|
// Windows WSL 2
|
||||||
case /microsoft/.test(str):
|
case /microsoft/.test(str):
|
||||||
return "Microsoft WSL 1";
|
return "Microsoft WSL 1";
|
||||||
// Windows WSL 2
|
|
||||||
case /Microsoft/.test(str):
|
|
||||||
return "Microsoft WSL 2";
|
|
||||||
|
|
||||||
// Azure Virtual Machinime (VM)
|
// Azure Virtual Machinime (VM)
|
||||||
case /[aA]zure/.test(str):
|
case /[aA]zure/.test(str):
|
||||||
|
|||||||
@@ -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()
|
|
||||||
}
|
}
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
const fetchSync = require("@the-bds-maneger/fetchsync");
|
|
||||||
const { external_ip, Interfaces } = require("../src/Scripts/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
|
|
||||||
2155
package-lock.json
generated
2155
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
27
package.json
27
package.json
@@ -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,23 +57,22 @@
|
|||||||
"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",
|
||||||
"express-prettify": "^0.1.1",
|
"express-prettify": "^0.1.1",
|
||||||
"express-rate-limit": "^5.2.3",
|
"express-rate-limit": "^5.2.3",
|
||||||
"googleapis": "^82.0.0",
|
"googleapis": "^84.0.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"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#main",
|
"docker-run_build": "github:Sirherobrine23/Docker-Run_Build#main",
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
const bds = require("../../index")
|
const bds = require("../index")
|
||||||
const { join, resolve } = require("path");
|
const { join, resolve } = require("path");
|
||||||
const { readdirSync, existsSync, readFileSync, statSync } = require("fs")
|
const { readdirSync, existsSync, readFileSync, statSync } = require("fs")
|
||||||
const AdmZip = require("adm-zip");
|
const AdmZip = require("adm-zip");
|
||||||
const { GetServerPaths, GetPaths, bds_dir } = require("../../lib/BdsSettings")
|
const { GetServerPaths, GetPaths, bds_dir } = require("../lib/BdsSettings")
|
||||||
|
|
||||||
function Backup() {
|
function Backup() {
|
||||||
const zip = new AdmZip();
|
const zip = new AdmZip();
|
||||||
@@ -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, "")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
352
src/BdsManegerServer.js
Normal file
352
src/BdsManegerServer.js
Normal file
@@ -0,0 +1,352 @@
|
|||||||
|
const child_process = require("child_process");
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
const { resolve, join } = require("path");
|
||||||
|
const randomUUID = require("uuid").v4;
|
||||||
|
const { CronJob } = require("cron");
|
||||||
|
const { GetCronBackup } = require("../lib/BdsSettings");
|
||||||
|
const { Backup } = require("./BdsBackup");
|
||||||
|
|
||||||
|
// Bds Maneger Inports
|
||||||
|
const commandExists = require("../lib/commandExist");
|
||||||
|
const BdsDetect = require("./CheckKill").Detect;
|
||||||
|
const bds = require("../index");
|
||||||
|
const { GetServerPaths, GetPaths, GetServerSettings, GetPlatform } = require("../lib/BdsSettings");
|
||||||
|
const BdsInfo = require("../BdsManegerInfo.json");
|
||||||
|
|
||||||
|
// Set bdsexec functions
|
||||||
|
global.BdsExecs = {};
|
||||||
|
|
||||||
|
function start() {
|
||||||
|
if (BdsDetect()){let ErrorReturn = "You already have a server running"; console.warn(ErrorReturn); throw new Error(ErrorReturn);}
|
||||||
|
|
||||||
|
const SetupCommands = {
|
||||||
|
command: String,
|
||||||
|
args: [],
|
||||||
|
cwd: String,
|
||||||
|
env: process.env,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minecraft Bedrock Oficial
|
||||||
|
if (GetPlatform() === "bedrock"){
|
||||||
|
// Check Darwin Platform
|
||||||
|
if (process.platform === "darwin") throw new Error("Use a imagem Docker");
|
||||||
|
|
||||||
|
// Windows Platform
|
||||||
|
else if (process.platform === "win32") {
|
||||||
|
SetupCommands.command = "bedrock_server.exe";
|
||||||
|
SetupCommands.cwd = GetServerPaths("bedrock")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Linux Platform
|
||||||
|
else if (process.platform === "linux"){
|
||||||
|
// Set Executable file
|
||||||
|
try {child_process.execSync("chmod 777 bedrock_server", {cwd: GetServerPaths("bedrock")});} catch (error) {console.log(error);}
|
||||||
|
|
||||||
|
// Set Env and Cwd
|
||||||
|
SetupCommands.cwd = GetServerPaths("bedrock");
|
||||||
|
SetupCommands.env.LD_LIBRARY_PATH = GetServerPaths("bedrock");
|
||||||
|
|
||||||
|
// In case the cpu is different from x64, the command will use qemu static to run the server
|
||||||
|
if (process.arch !== "x64") {
|
||||||
|
if (!(commandExists("qemu-x86_64-static"))) throw new Error("Install qemu static")
|
||||||
|
SetupCommands.command = "qemu-x86_64-static"
|
||||||
|
SetupCommands.args.push("./bedrock_server");
|
||||||
|
} else SetupCommands.command = "./bedrock_server";
|
||||||
|
} else throw new Error("your system does not support Minecraft Bedrock (yet)")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minecraft Java Oficial
|
||||||
|
else if (GetPlatform() === "java") {
|
||||||
|
const JavaConfig = GetServerSettings("java")
|
||||||
|
|
||||||
|
// Checking if java is installed on the device
|
||||||
|
if (commandExists("java")) {
|
||||||
|
SetupCommands.cwd = GetServerPaths("java");
|
||||||
|
SetupCommands.command = "java";
|
||||||
|
SetupCommands.args.push("-jar", `-Xms${JavaConfig.ram_mb}M`, `-Xmx${JavaConfig.ram_mb}M`, "MinecraftServerJava.jar", "nogui");
|
||||||
|
} else {require("open")(bds.package_json.docs_base + "Java-Download#windows"); throw new Error(`Open: ${bds.package_json.docs_base + "Java-Download#windows"}`)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minecraft Bedrock (Pocketmine-MP)
|
||||||
|
else if (GetPlatform() === "pocketmine") {
|
||||||
|
// Start PocketMine-MP
|
||||||
|
SetupCommands.command = join(resolve(GetServerPaths("pocketmine"), "bin", "php7", "bin"), "php");
|
||||||
|
SetupCommands.args.push("./PocketMine-MP.phar");
|
||||||
|
SetupCommands.cwd = GetServerPaths("pocketmine");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minecraft Bedrock (JSPrismarine)
|
||||||
|
else if (GetPlatform() === "jsprismarine") {
|
||||||
|
// Start JSPrismarine
|
||||||
|
SetupCommands.command = "node";
|
||||||
|
SetupCommands.args.push("./packages/server/dist/Server.js");
|
||||||
|
SetupCommands.cwd = GetServerPaths("jsprismarine");
|
||||||
|
} else throw Error("Bds Config Error")
|
||||||
|
|
||||||
|
// Setup commands
|
||||||
|
const ServerExec = child_process.execFile(SetupCommands.command, SetupCommands.args, {
|
||||||
|
cwd: SetupCommands.cwd,
|
||||||
|
env: SetupCommands.env
|
||||||
|
});
|
||||||
|
|
||||||
|
// Post Start
|
||||||
|
if (GetPlatform() === "java") {
|
||||||
|
const eula_file = path.join(GetServerPaths("java"), "eula.txt");
|
||||||
|
console.log(fs.readFileSync(eula_file, "utf8"));
|
||||||
|
if (fs.readFileSync(eula_file, "utf8").includes("eula=false")) {
|
||||||
|
fs.writeFileSync(eula_file, fs.readFileSync(eula_file, "utf8").replaceAll("eula=false", "eula=true"));
|
||||||
|
throw new Error("Restart application/CLI")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log file
|
||||||
|
|
||||||
|
const LogFile = join(GetPaths("log"), `${bds.date()}_${GetPlatform()}_Bds_log.log`);
|
||||||
|
const LatestLog_Path = path.join(GetPaths("log"), "latest.log");
|
||||||
|
const LogSaveFunction = data => {
|
||||||
|
fs.appendFileSync(LogFile, data);
|
||||||
|
fs.appendFileSync(LatestLog_Path, data);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
fs.writeFileSync(LatestLog_Path, "");
|
||||||
|
|
||||||
|
// Player JSON File
|
||||||
|
ServerExec.stdout.on("data", data => Player_Json(data, UpdateUserJSON));
|
||||||
|
ServerExec.stderr.on("data", data => Player_Json(data, UpdateUserJSON));
|
||||||
|
|
||||||
|
// Log File
|
||||||
|
ServerExec.stdout.on("data", LogSaveFunction);
|
||||||
|
ServerExec.stderr.on("data", LogSaveFunction);
|
||||||
|
|
||||||
|
// Global and Run
|
||||||
|
global.bds_log_string = ""
|
||||||
|
ServerExec.stdout.on("data", data => {if (global.bds_log_string) global.bds_log_string = data; else global.bds_log_string += data});
|
||||||
|
|
||||||
|
const returnFuntion = {
|
||||||
|
uuid: randomUUID(),
|
||||||
|
stop: function (){
|
||||||
|
ServerExec.stdin.write(BdsInfo.Servers[GetPlatform()].stop+"\n");
|
||||||
|
return BdsInfo.Servers[GetPlatform()].stop;
|
||||||
|
},
|
||||||
|
command: async function (command = "list", callback = data => console.log(data)){
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
ServerExec.stdin.write(`${command}\n`);
|
||||||
|
if (typeof callback === "function") {
|
||||||
|
const TempLog = []
|
||||||
|
const ControlTempHost = data => {TempLog.push(data); return data;}
|
||||||
|
ServerExec.stdout.on("data", data => ControlTempHost(data));
|
||||||
|
ServerExec.stderr.on("data", data => ControlTempHost(data));
|
||||||
|
setTimeout(() => {
|
||||||
|
callback(TempLog.join("\n"));
|
||||||
|
resolve(TempLog.join("\n"));
|
||||||
|
}, 2500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
log: function (logCallback = function(data = ""){data.split("\n").filter(d=>{return (d !== "")}).forEach(l=>console.log(l))}){
|
||||||
|
if (typeof logCallback !== "function") {
|
||||||
|
console.warn("The log callback is not a function using console.log");
|
||||||
|
logCallback = function(data = ""){data.split("\n").filter(d=>{return (d !== "")}).forEach(l=>console.log(l))}
|
||||||
|
}
|
||||||
|
ServerExec.stdout.on("data", data => logCallback(data));
|
||||||
|
ServerExec.stderr.on("data", data => logCallback(data));
|
||||||
|
},
|
||||||
|
exit: function (exitCallback = process.exit){if (
|
||||||
|
typeof exitCallback === "function") ServerExec.on("exit", code => exitCallback(code));
|
||||||
|
},
|
||||||
|
on: function(action = String(), callback = Function) {
|
||||||
|
if (!(action === "all" || action === "connect" || action === "disconnect")) throw new Error("Use some valid action: all, connect, disconnect");
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
const data = data => Player_Json(data, function (array_status){
|
||||||
|
for (let _player of array_status) {
|
||||||
|
if (action === "all") callback(_player);
|
||||||
|
else if (_player.Action === action) callback(_player)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ServerExec.stdout.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]});
|
||||||
|
global.BdsExecs[returnFuntion.uuid] = returnFuntion;
|
||||||
|
return returnFuntion;
|
||||||
|
}
|
||||||
|
|
||||||
|
function Player_Json(data = "aaaaaa\n\n\naa", callback = () => {}){
|
||||||
|
const Current_platorm = GetPlatform();
|
||||||
|
// Bedrock
|
||||||
|
if (Current_platorm === "bedrock") {
|
||||||
|
// "[INFO] Player connected: Sirherobrine, xuid: 2535413418839840",
|
||||||
|
// "[INFO] Player disconnected: Sirherobrine, xuid: 2535413418839840",
|
||||||
|
const BedrockMap = data.split(/\n|\r/gi).map(line => {
|
||||||
|
if (line.includes("connected") || line.includes("disconnected")) {
|
||||||
|
let SplitLine = line.replace(/\[.+\]\s+Player/gi, "").trim().split(/\s+/gi);
|
||||||
|
|
||||||
|
// player
|
||||||
|
let Player = line.trim().replace(/\[.+\]\s+Player/gi, "").trim().replace(/disconnected:|connected:/, "").trim().split(/,\s+xuid:/).filter(a=>a).map(a=>a.trim()).filter(a=>a);
|
||||||
|
|
||||||
|
//
|
||||||
|
let Actions = null;
|
||||||
|
if (/^disconnected/.test(SplitLine[0].trim())) Actions = "disconnect";
|
||||||
|
else if (/^connected/.test(SplitLine[0].trim())) Actions = "connect";
|
||||||
|
|
||||||
|
// Object Map
|
||||||
|
const ObjectReturn = {
|
||||||
|
Player: Player[0],
|
||||||
|
Action: Actions,
|
||||||
|
xuid: Player[1] || null,
|
||||||
|
Date: new Date(),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return
|
||||||
|
return ObjectReturn
|
||||||
|
} else return false;
|
||||||
|
}).filter(a=>a);
|
||||||
|
callback(BedrockMap);
|
||||||
|
}
|
||||||
|
// Java and Pocketmine-MP
|
||||||
|
else if (Current_platorm === "java" || Current_platorm === "pocketmine") {
|
||||||
|
const JavaMap = data.split(/\n|\r/gi).map(line => {
|
||||||
|
if (line.trim().includes("joined the game") || line.includes("left the game")) {
|
||||||
|
line = line.replace(/^\[.+\] \[.+\/.+\]:/, "").trim();
|
||||||
|
let Actions = null;
|
||||||
|
if (/joined/.test(line)) Actions = "connect";
|
||||||
|
else if (/left/.test(line)) Actions = "disconnect";
|
||||||
|
|
||||||
|
// Player Object
|
||||||
|
const JavaObject = {
|
||||||
|
Player: line.replace(/joined the game|left the game/gi, "").trim(),
|
||||||
|
Action: Actions,
|
||||||
|
Date: new Date(),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return JSON
|
||||||
|
return JavaObject
|
||||||
|
} else return false;
|
||||||
|
}).filter(a=>a);
|
||||||
|
callback(JavaMap);
|
||||||
|
}
|
||||||
|
// JSPrismarine
|
||||||
|
// else if (Current_platorm === "jsprismarine") console.log("It's still not working");
|
||||||
|
}
|
||||||
|
|
||||||
|
const UpdateUserJSON = function (New_Object = new Array()){
|
||||||
|
const Player_Json_path = GetPaths("player");
|
||||||
|
const Current_platorm = GetPlatform();
|
||||||
|
let Players_Json = {
|
||||||
|
bedrock: [],
|
||||||
|
java: [],
|
||||||
|
pocketmine: [],
|
||||||
|
jsprismarine: [],
|
||||||
|
}
|
||||||
|
if (fs.existsSync(Player_Json_path)) Players_Json = JSON.parse(fs.readFileSync(Player_Json_path, "utf8"));
|
||||||
|
|
||||||
|
// Array
|
||||||
|
Players_Json[Current_platorm] = Players_Json[Current_platorm].concat(New_Object)
|
||||||
|
|
||||||
|
fs.writeFileSync(Player_Json_path, JSON.stringify(Players_Json, null, 2));
|
||||||
|
return Players_Json
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search player in JSON
|
||||||
|
function Player_Search(player = "dontSteve") {
|
||||||
|
const Player_Json_path = GetPaths("player"), Current_platorm = GetPlatform();
|
||||||
|
const Players_Json = JSON.parse(fs.readFileSync(Player_Json_path, "utf8"))[Current_platorm]
|
||||||
|
for (let Player of Players_Json) {
|
||||||
|
if (Player.Player === player.trim()) return Player;
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetSessions(){
|
||||||
|
const ArraySessions = Object.getOwnPropertyNames(global.BdsExecs)
|
||||||
|
if (ArraySessions.length === 0) throw "Start Server";
|
||||||
|
if (ArraySessions.length >= 2) throw "Select a session manually:" + ArraySessions.join(", ")
|
||||||
|
return global.BdsExecs[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
function BdsCommand(command = "list", SessionID = null) {
|
||||||
|
if (!(command)) return false;
|
||||||
|
try {
|
||||||
|
var Session = {}
|
||||||
|
if (!(SessionID)) Session = GetSessions(); else Session = global.BdsExecs[SessionID]
|
||||||
|
Session.command(command);
|
||||||
|
return true
|
||||||
|
} catch (error) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop(SessionID = null) {
|
||||||
|
try {
|
||||||
|
var Session = {}
|
||||||
|
if (!(SessionID)) Session = GetSessions(); else Session = global.BdsExecs[SessionID]
|
||||||
|
Session.stop()
|
||||||
|
return true
|
||||||
|
} catch (error) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const Cloud_Backup = {
|
||||||
|
Azure: require("./clouds/Azure").Uploadbackups,
|
||||||
|
Driver: require("./clouds/GoogleDriver").Uploadbackups,
|
||||||
|
Oracle: require("./clouds/OracleCI").Uploadbackups,
|
||||||
|
}
|
||||||
|
const CurrentBackups = GetCronBackup().map(Crron => {
|
||||||
|
return {
|
||||||
|
CronFunction: new CronJob(Crron.cron, async () => {
|
||||||
|
console.log("Starting Server and World Backup");
|
||||||
|
const CurrentBackup = Backup();
|
||||||
|
// Azure
|
||||||
|
if (Crron.Azure) Cloud_Backup.Azure(CurrentBackup.file_name, CurrentBackup.file_path);
|
||||||
|
else console.info("Azure Backup Disabled");
|
||||||
|
|
||||||
|
// Google Driver
|
||||||
|
if (Crron.Driver) Cloud_Backup.Driver(CurrentBackup.file_name, CurrentBackup.file_path);
|
||||||
|
else console.info("Google Driver Backup Disabled");
|
||||||
|
|
||||||
|
// Oracle Bucket
|
||||||
|
if (Crron.Oracle) Cloud_Backup.Oracle(CurrentBackup.file_name, CurrentBackup.file_path);
|
||||||
|
else console.info("Oracle Bucket Backup Disabled");
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
start,
|
||||||
|
BdsCommand,
|
||||||
|
stop,
|
||||||
|
CronBackups: CurrentBackups,
|
||||||
|
Player_Search,
|
||||||
|
}
|
||||||
89
src/BdsNetwork.js
Normal file
89
src/BdsNetwork.js
Normal 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,
|
||||||
|
}
|
||||||
@@ -1,21 +1,61 @@
|
|||||||
var AdmZip = require("adm-zip");
|
var AdmZip = require("adm-zip");
|
||||||
const { writeFileSync, existsSync, readFileSync, readdirSync } = require("fs");
|
const { writeFileSync, existsSync, readFileSync, readdirSync, rmSync } = require("fs");
|
||||||
const { join, resolve } = require("path");
|
const { join, resolve, basename } = require("path");
|
||||||
const bds = require("../../index")
|
const bds = require("../index")
|
||||||
const { valid_platform } = require("../../lib/BdsSystemInfo");
|
const { valid_platform } = require("../lib/BdsSystemInfo");
|
||||||
const { GetServerPaths, GetServerVersion, UpdateServerVersion, GetPlatform } = require("../../lib/BdsSettings");
|
const { GetServerPaths, GetServerVersion, UpdateServerVersion, GetPlatform } = require("../lib/BdsSettings");
|
||||||
const { GitClone } = require("../../lib/git_simples");
|
const { GitClone } = require("../lib/git_simples");
|
||||||
const { execSync } = require("child_process");
|
const { execSync } = require("child_process");
|
||||||
const Extra = require("../../BdsManegerInfo.json");
|
const Extra = require("../BdsManegerInfo.json");
|
||||||
|
|
||||||
const
|
async function php_download() {
|
||||||
bds_dir_bedrock = GetServerPaths("bedrock"),
|
const bds_dir_pocketmine = GetServerPaths("pocketmine"),
|
||||||
bds_dir_java = GetServerPaths("java"),
|
PHPBin = (await (await fetch(Extra.download.php)).json());
|
||||||
bds_dir_pocketmine = GetServerPaths("pocketmine"),
|
const phpFolder = resolve(bds_dir_pocketmine, "bin");
|
||||||
bds_dir_jsprismarine = GetServerPaths("jsprismarine");
|
const phpExtensiosnsDir = resolve(bds_dir_pocketmine, "bin/php7/lib/php/extensions");
|
||||||
|
|
||||||
|
// Check Php Binary
|
||||||
|
let urlPHPBin = PHPBin[process.platform]
|
||||||
|
if (!(urlPHPBin)) throw new Error("unsupported system")
|
||||||
|
urlPHPBin = urlPHPBin[bds.arch]
|
||||||
|
|
||||||
|
|
||||||
|
// Remove Old php Binary if it exists
|
||||||
|
if (existsSync(phpFolder)) {
|
||||||
|
console.log("Removing old PHP files.");
|
||||||
|
rmSync(phpFolder, { recursive: true });
|
||||||
|
}
|
||||||
|
console.log(`Downloading ${urlPHPBin}`);
|
||||||
|
const ZipBuffer = Buffer.from((await (await fetch(urlPHPBin)).arrayBuffer()));
|
||||||
|
console.log(`${basename(urlPHPBin)} downloaded`);
|
||||||
|
|
||||||
|
console.log(`Extracting ${basename(urlPHPBin)}`);
|
||||||
|
const zipExtractBin = new AdmZip(ZipBuffer);
|
||||||
|
zipExtractBin.extractAllTo(bds_dir_pocketmine, false)
|
||||||
|
console.log("Successfully extracting the binaries")
|
||||||
|
|
||||||
|
let phpConfigInit = readFileSync(join(phpFolder, "php7", "bin", "php.ini"), "utf-8");
|
||||||
|
if (!(existsSync(phpExtensiosnsDir))) return true;
|
||||||
|
|
||||||
|
const phpExtensiosns = readdirSync(phpExtensiosnsDir).map(FileFolder => {
|
||||||
|
if (!(FileFolder.includes("debug-zts"))) return false;
|
||||||
|
return resolve(phpExtensiosnsDir, FileFolder);
|
||||||
|
}).filter(a=>a);
|
||||||
|
|
||||||
|
if (phpConfigInit.includes("extension_dir")) console.log("Skipping php.ini configuration");
|
||||||
|
else {
|
||||||
|
phpConfigInit = (`extension_dir="${phpExtensiosns.join()}"\n${phpConfigInit}`);
|
||||||
|
writeFileSync(join(phpFolder, "php7", "bin", "php.ini"), phpConfigInit);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = async function (version, force_install, callback) {
|
module.exports = async function (version, force_install, callback) {
|
||||||
const Servers = (await (await fetch(Extra.download.servers)).json()), PHPBin = (await (await fetch(Extra.download.php)).json());
|
const bds_dir_bedrock = GetServerPaths("bedrock"),
|
||||||
|
bds_dir_java = GetServerPaths("java"),
|
||||||
|
bds_dir_pocketmine = GetServerPaths("pocketmine"),
|
||||||
|
bds_dir_jsprismarine = GetServerPaths("jsprismarine");
|
||||||
|
const Servers = (await (await fetch(Extra.download.servers)).json());
|
||||||
const ServerVersion = GetServerVersion()
|
const ServerVersion = GetServerVersion()
|
||||||
const CurrentPlatform = GetPlatform()
|
const CurrentPlatform = GetPlatform()
|
||||||
if (force_install === true) {
|
if (force_install === true) {
|
||||||
@@ -92,28 +132,9 @@ module.exports = async function (version, force_install, callback) {
|
|||||||
|
|
||||||
writeFileSync(join(bds_dir_pocketmine, "PocketMine-MP.phar"), Buffer.from((await (await fetch(PocketMineJson.url)).arrayBuffer())), "binary")
|
writeFileSync(join(bds_dir_pocketmine, "PocketMine-MP.phar"), Buffer.from((await (await fetch(PocketMineJson.url)).arrayBuffer())), "binary")
|
||||||
console.log("Success downloading and saving PocketMine-MP php");
|
console.log("Success downloading and saving PocketMine-MP php");
|
||||||
|
|
||||||
// Check PHP binary
|
|
||||||
var urlPHPBin; /* Check System php */try {urlPHPBin = PHPBin[process.platform][bds.arch]} catch (error) {throw new Error("unsupported system")}
|
|
||||||
console.log("Downloading PHP Binaries");
|
|
||||||
// Get PHP bin File and extract
|
|
||||||
const zipExtractBin = new AdmZip(Buffer.from((await (await fetch(urlPHPBin)).arrayBuffer())));
|
|
||||||
|
|
||||||
zipExtractBin.extractAllTo(bds_dir_pocketmine, true)
|
await php_download();
|
||||||
console.log("Successfully extracting the binaries")
|
|
||||||
|
|
||||||
// Check Configs and others
|
|
||||||
const phpFolder = resolve(bds_dir_pocketmine, "bin")
|
|
||||||
const phpConfigInit = readFileSync(join(phpFolder, "php7", "bin", "php.ini"), "utf-8").split(/\n/g).filter(a=>a.trim());
|
|
||||||
// Post check extension_dir
|
|
||||||
const phpExtensiosnsDir = resolve(bds_dir_pocketmine, "bin/php7/lib/php/extensions");const phpExtensiosns = readdirSync(phpExtensiosnsDir);var exetensionZen;for (let index of phpExtensiosns) if (index.includes("debug-zts")) exetensionZen = index
|
|
||||||
// Check Php bin folder and bins
|
|
||||||
var check_extension_dir = false;for (let index of phpConfigInit) if (index.includes("extension_dir")) check_extension_dir = true;
|
|
||||||
if (check_extension_dir) console.log("Skipping php.ini configuration");
|
|
||||||
else {
|
|
||||||
phpConfigInit.push(`extension_dir="${resolve(phpExtensiosnsDir, exetensionZen)}"`);
|
|
||||||
writeFileSync(join(phpFolder, "php7", "bin", "php.ini"), phpConfigInit.join("\n"));
|
|
||||||
}
|
|
||||||
// Update server Version
|
// Update server Version
|
||||||
UpdateServerVersion(version)
|
UpdateServerVersion(version)
|
||||||
// Callback
|
// Callback
|
||||||
@@ -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+/)
|
// Ignore empty lines
|
||||||
// Get argument: wmic process where "ProcessID=4152" get commandline
|
if (line_split.length <= 2) return false
|
||||||
const pidNumber = (_line.length - 5)
|
|
||||||
MountProcess.push({
|
let pid = line_split[Math.abs(line_split.length - 2)].toString();
|
||||||
command: (function(){
|
let mem = line_split[Math.abs(line_split.length - 1)].toString();
|
||||||
try {
|
let command = Line.slice(0, - Math.abs(pid.length)).trim().slice(0, - Math.abs(mem.length)).trim();
|
||||||
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()
|
pid = parseInt(pid);
|
||||||
} catch (err) {
|
mem = parseInt(mem);
|
||||||
return null
|
if (command && pid && mem) return {
|
||||||
}
|
command,
|
||||||
})(),
|
pid,
|
||||||
pid: parseInt(_line[pidNumber]),
|
mem,
|
||||||
cpu: _line[(_line.length - 3)],
|
}; else return false
|
||||||
mem: (_line[(_line.length - 2)].split(".").join("")),
|
} catch (err) {
|
||||||
})
|
console.log(err);
|
||||||
}
|
return false
|
||||||
|
}
|
||||||
|
}).filter(a => a);
|
||||||
} else {
|
} else {
|
||||||
getList = execSync("ps -aux").toString("utf8").split("\n").filter(d=>{return !(/USER\s+/.test(d) || d === "")})
|
MountProcess = execSync("ps -aux").toString("utf8").split("\n").filter(d=>{return !(/USER\s+/.test(d) || d === "")}).map(_line => _line.split(/\s+/)).map(_line =>{
|
||||||
for (let _line of getList) {
|
return {
|
||||||
_line = _line.split(/\s+/)
|
command: (function(){
|
||||||
MountProcess.push({
|
var command = _line[10];
|
||||||
command: (function(){var command = _line[10];const argvLenght = (_line.length - 11);for (let index = 0; index < argvLenght; index++) {command += ` ${_line[11 + index]}`;} return command})(),
|
const argvLenght = (_line.length - 11);
|
||||||
|
for (let index = 0; index < argvLenght; index++) {
|
||||||
|
command += ` ${_line[11 + index]}`;
|
||||||
|
}
|
||||||
|
return command;
|
||||||
|
})(),
|
||||||
pid: parseInt(_line[1]),
|
pid: parseInt(_line[1]),
|
||||||
cpu: _line[2],
|
|
||||||
mem: _line[3],
|
mem: _line[3],
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return MountProcess;
|
return MountProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
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");
|
||||||
|
|
||||||
function MytypeKill(player) {
|
function MytypeKill(player) {
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
const { CronJob } = require("cron");
|
|
||||||
const { GetCronBackup } = require("../../lib/BdsSettings");
|
|
||||||
const { Backup } = require("./backups")
|
|
||||||
const Cloud = {
|
|
||||||
Azure: require("../clouds/Azure").Uploadbackups,
|
|
||||||
Driver: require("../clouds/GoogleDriver").Uploadbackups,
|
|
||||||
Oracle: require("../clouds/OracleCI").Uploadbackups,
|
|
||||||
}
|
|
||||||
|
|
||||||
const CurrentBackups = GetCronBackup();
|
|
||||||
module.exports = CurrentBackups.map(Crron => {
|
|
||||||
return {
|
|
||||||
CronFunction: new CronJob(Crron.cron, function(){
|
|
||||||
console.log("Starting Server and World Backup");
|
|
||||||
const CurrentBackup = Backup();
|
|
||||||
if (Crron.Azure) Cloud.Azure(CurrentBackup.file_name, CurrentBackup.file_path); else console.info("Azure Backup Disabled");
|
|
||||||
if (Crron.Driver) Cloud.Driver(CurrentBackup.file_name, CurrentBackup.file_path); else console.info("Google Driver Backup Disabled");
|
|
||||||
if (Crron.Oracle) Cloud.Oracle(CurrentBackup.file_name, CurrentBackup.file_path); else console.info("Oracle Bucket Backup Disabled");
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
const { exec, execFile } = require("child_process");
|
|
||||||
const fs = require("fs");
|
|
||||||
const path = require("path");
|
|
||||||
const { resolve, join } = require("path");
|
|
||||||
const commandExists = require("../../lib/commandExist");
|
|
||||||
const saveUser = require("./PlayersSave");
|
|
||||||
const bds = require("../../index");
|
|
||||||
const { GetServerPaths, GetPaths, GetServerSettings, GetPlatform } = require("../../lib/BdsSettings");
|
|
||||||
const BdsDetect = require("./CheckKill").Detect;
|
|
||||||
const { randomUUID } = require("crypto");
|
|
||||||
const { warn } = console;
|
|
||||||
|
|
||||||
// Set bdsexec functions
|
|
||||||
global.BdsExecs = {};
|
|
||||||
|
|
||||||
function saveLog(data = "", LogFile = ""){
|
|
||||||
fs.appendFileSync(path.join(GetPaths("log"), "latest.log"), data)
|
|
||||||
fs.appendFileSync(LogFile, data)
|
|
||||||
}
|
|
||||||
function start() {
|
|
||||||
if (BdsDetect()){
|
|
||||||
console.warn("You already have a server running");
|
|
||||||
throw "You already have a server running";
|
|
||||||
} else {
|
|
||||||
var start_server;
|
|
||||||
|
|
||||||
// Minecraft Bedrock Oficial
|
|
||||||
if (GetPlatform() === "bedrock"){
|
|
||||||
if (process.platform === "darwin") throw Error("Use a imagem Docker");
|
|
||||||
else if (process.platform == "win32") start_server = exec("bedrock_server.exe", {
|
|
||||||
cwd: GetServerPaths("bedrock"),
|
|
||||||
});
|
|
||||||
else if (process.platform == "linux"){
|
|
||||||
// Set Executable file
|
|
||||||
execFile("chmod 777 bedrock_server", {cwd: GetServerPaths("bedrock")});
|
|
||||||
var BedrockCommand = "./bedrock_server";
|
|
||||||
|
|
||||||
// Emulation of the x86_64 architecture
|
|
||||||
if (commandExists("qemu-x86_64-static") && process.arch !== "x64") BedrockCommand = "qemu-x86_64-static "+BedrockCommand;
|
|
||||||
|
|
||||||
// Start Bedrock Server
|
|
||||||
start_server = exec(BedrockCommand, {cwd: GetServerPaths("bedrock"), env: {...process.env, LD_LIBRARY_PATH: GetServerPaths("bedrock")}})
|
|
||||||
} else throw new Error("your system does not support Minecraft Bedrock (yet)")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Minecraft Java Oficial
|
|
||||||
else if (GetPlatform() === "java") {
|
|
||||||
const JavaConfig = GetServerSettings("java")
|
|
||||||
|
|
||||||
// Checking if java is installed on the device
|
|
||||||
if (commandExists("java")) {
|
|
||||||
start_server = execFile("java", [
|
|
||||||
"-jar",
|
|
||||||
`-Xms${JavaConfig.ram_mb}M`,
|
|
||||||
`-Xmx${JavaConfig.ram_mb}M`,
|
|
||||||
"MinecraftServerJava.jar",
|
|
||||||
"nogui"
|
|
||||||
], {cwd: GetServerPaths("java")})
|
|
||||||
} else {
|
|
||||||
var url = bds.package_json.docs_base; if (bds.system == "windows") url += "Java-Download#windows"; else if (bds.system === "linux") url = "Java-Download#linux"; else if (process.platform === "darwin") url = "Java-Download#macos"; else url = "Java-Download";
|
|
||||||
require("open")(url);
|
|
||||||
throw new Error(`Open: ${url}`)
|
|
||||||
}
|
|
||||||
} else if (GetPlatform() === "pocketmine") {
|
|
||||||
// Start PocketMine-MP
|
|
||||||
const php_bin_path = join(resolve(GetServerPaths("pocketmine"), "bin", "php7", "bin"), "php");
|
|
||||||
start_server = execFile(php_bin_path, [
|
|
||||||
"./PocketMine-MP.phar"
|
|
||||||
], {
|
|
||||||
cwd: GetServerPaths("pocketmine")
|
|
||||||
})
|
|
||||||
} else if (GetPlatform() === "jsprismarine") {
|
|
||||||
// Start JSPrismarine
|
|
||||||
start_server = execFile("node", [
|
|
||||||
"./packages/server/dist/Server.js"
|
|
||||||
], {
|
|
||||||
cwd: GetServerPaths("jsprismarine")
|
|
||||||
});
|
|
||||||
} else throw Error("Bds Config Error")
|
|
||||||
|
|
||||||
// Post Start
|
|
||||||
if (GetPlatform() === "java") {
|
|
||||||
start_server.stdout.on("data", function(data){
|
|
||||||
if (data.includes("agree"))
|
|
||||||
if (data.includes("EULA")){
|
|
||||||
const eula_file = path.join(GetServerPaths("java"), "eula.txt");
|
|
||||||
fs.writeFileSync(eula_file, fs.readFileSync(eula_file, "utf8").split("eula=false").join("eula=true"));
|
|
||||||
throw new Error("Restart application/CLI")
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Log file
|
|
||||||
const LogFile = join(GetPaths("log"), `${bds.date()}_${GetPlatform()}_Bds_log.log`);
|
|
||||||
// save User in Json
|
|
||||||
start_server.stdout.on("data", data => saveUser(data))
|
|
||||||
start_server.stderr.on("data", data => saveUser(data))
|
|
||||||
// ---------------------------------------------------
|
|
||||||
// Clear latest.log
|
|
||||||
fs.writeFileSync(path.join(GetPaths("log"), "latest.log"), "")
|
|
||||||
|
|
||||||
// ---------------------------------------------------
|
|
||||||
// stdout
|
|
||||||
start_server.stdout.on("data", a=>saveLog(a, LogFile));
|
|
||||||
start_server.stderr.on("data", a=>saveLog(a, LogFile));
|
|
||||||
// ---------------------------------------------------
|
|
||||||
// Global and Run
|
|
||||||
global.bds_log_string = ""
|
|
||||||
start_server.stdout.on("data", function(data){
|
|
||||||
if (global.bds_log_string === undefined || global.bds_log_string === "") global.bds_log_string = data; else global.bds_log_string += data
|
|
||||||
});
|
|
||||||
global.bds_server_string = start_server;
|
|
||||||
|
|
||||||
// Functions return
|
|
||||||
const returnFuntion = {
|
|
||||||
uuid: randomUUID(),
|
|
||||||
exec: start_server,
|
|
||||||
stop: function (){start_server.stdin.write("stop\n")},
|
|
||||||
command: function (command = "list", callback){
|
|
||||||
const oldLog = global.bds_log_string;
|
|
||||||
start_server.stdin.write(`${command}\n`);
|
|
||||||
if (typeof callback === "function") {
|
|
||||||
setTimeout(() => {
|
|
||||||
// Run commands from command run in server;
|
|
||||||
const log = global.bds_log_string.replace(oldLog, "").split(/\r/).filter(data => {if (data === "") return false; else return true;}).join("\n")
|
|
||||||
if (log.length >= 1) callback(log); else callback("no log")
|
|
||||||
}, 1555);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
log: function (logCallback = function(data = ""){data.split("\n").filter(d=>{return (d !== "")}).forEach(l=>console.log(l))}){
|
|
||||||
if (typeof logCallback !== "function") {
|
|
||||||
warn("The log callback is not a function using console.log");
|
|
||||||
logCallback = function(data = ""){data.split("\n").filter(d=>{return (d !== "")}).forEach(l=>console.log(l))}
|
|
||||||
}
|
|
||||||
start_server.stdout.on("data", data => logCallback(data));
|
|
||||||
start_server.stderr.on("data", data => logCallback(data));
|
|
||||||
},
|
|
||||||
exit: function (exitCallback = process.exit){if (
|
|
||||||
typeof exitCallback === "function") start_server.on("exit", code => exitCallback(code));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
start_server.on("exit", ()=>{delete global.BdsExecs[returnFuntion.uuid]})
|
|
||||||
global.BdsExecs[returnFuntion.uuid] = returnFuntion
|
|
||||||
return returnFuntion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function GetSessions(){
|
|
||||||
const ArraySessions = Object.getOwnPropertyNames(global.BdsExecs)
|
|
||||||
if (ArraySessions.length === 0) throw "Start Server";
|
|
||||||
if (ArraySessions.length >= 2) throw "Select a session manually:" + ArraySessions.join(", ")
|
|
||||||
return global.BdsExecs[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
function BdsCommand(command = "list", SessionID = null) {
|
|
||||||
if (!(command)) return false;
|
|
||||||
try {
|
|
||||||
var Session = {}
|
|
||||||
if (!(SessionID)) Session = GetSessions(); else Session = global.BdsExecs[SessionID]
|
|
||||||
Session.command(command);
|
|
||||||
return true
|
|
||||||
} catch (error) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function stop(SessionID = null) {
|
|
||||||
try {
|
|
||||||
var Session = {}
|
|
||||||
if (!(SessionID)) Session = GetSessions(); else Session = global.BdsExecs[SessionID]
|
|
||||||
Session.stop()
|
|
||||||
return true
|
|
||||||
} catch (error) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
start,
|
|
||||||
BdsCommand,
|
|
||||||
stop
|
|
||||||
}
|
|
||||||
@@ -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)
|
|
||||||
@@ -2,7 +2,7 @@ var fs = require("fs");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const propertiesToJSON = require("properties-to-json");
|
const propertiesToJSON = require("properties-to-json");
|
||||||
const { join } = require("path");
|
const { join } = require("path");
|
||||||
const { GetServerPaths, GetPlatform } = require("../../lib/BdsSettings");
|
const { GetServerPaths, GetPlatform } = require("../lib/BdsSettings");
|
||||||
const bds_dir_bedrock = GetServerPaths("bedrock"), bds_dir_java = GetServerPaths("java"), bds_dir_pocketmine = GetServerPaths("pocketmine");
|
const bds_dir_bedrock = GetServerPaths("bedrock"), bds_dir_java = GetServerPaths("java"), bds_dir_pocketmine = GetServerPaths("pocketmine");
|
||||||
const bedrockCPUThread = require("os").cpus().length;
|
const bedrockCPUThread = require("os").cpus().length;
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ function bds_get_config(){
|
|||||||
JsonConfig.commands = false;
|
JsonConfig.commands = false;
|
||||||
// JsonConfig.worldtype = config["level-type"];
|
// JsonConfig.worldtype = config["level-type"];
|
||||||
} else if (GetPlatform() === "jsprismarine") throw "Platform not fully supported";
|
} else if (GetPlatform() === "jsprismarine") throw "Platform not fully supported";
|
||||||
else throw new Error("Platform no exists, check config file")
|
else throw new Error("Platform no exists, check config file");
|
||||||
return JsonConfig;
|
return JsonConfig;
|
||||||
}
|
}
|
||||||
function config_example(){
|
function config_example(){
|
||||||
@@ -1,22 +1,20 @@
|
|||||||
const { bds_dir, GetServerBan, GetTelegramAdmins, GetPlatform, GetPaths } = require("../../lib/BdsSettings");
|
const { bds_dir, GetServerBan, GetTelegramAdmins, GetPlatform, GetPaths } = require("../lib/BdsSettings");
|
||||||
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_]
|
||||||
@@ -35,4 +33,11 @@ module.exports.CheckBan = function (player){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
CheckTelegramUser,
|
||||||
|
CheckPlayer,
|
||||||
|
CheckBan,
|
||||||
|
token_verify
|
||||||
}
|
}
|
||||||
@@ -1,44 +1,39 @@
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const { join } = require("path")
|
const { join } = require("path")
|
||||||
const { google } = require("googleapis");
|
const { randomUUID } = require("crypto");
|
||||||
const { bds_dir } = require("../../../lib/BdsSettings")
|
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const app = express();
|
const { google } = require("googleapis");
|
||||||
var cors = require("cors");
|
|
||||||
const rateLimit = require("express-rate-limit");
|
const ip_andress = require("../../BdsNetwork");
|
||||||
const bodyParser = require("body-parser");
|
const { bds_dir } = require("../../../lib/BdsSettings");
|
||||||
const fetchSync = require("@the-bds-maneger/fetchsync");
|
|
||||||
const Ips = require("../../Scripts/external_ip");
|
|
||||||
const DefaultLoginDrive = {
|
|
||||||
access_type: "offline",
|
|
||||||
scope: [
|
|
||||||
"https://www.googleapis.com/auth/drive"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
const GoogleDriveCredentials = fetchSync("https://raw.githubusercontent.com/The-Bds-Maneger/external_files/main/Credentials/Google.json").json()
|
|
||||||
// -------------------------------------------------------------
|
|
||||||
const PathToToken = join(bds_dir, "google_user_token.json");
|
const PathToToken = join(bds_dir, "google_user_token.json");
|
||||||
|
|
||||||
function expressGetGoogleDriveToken(callback){
|
// Urls
|
||||||
// Settings
|
global.GoogleAuth = {}
|
||||||
const limiter = rateLimit({
|
|
||||||
windowMs: 1 * 60 * 1000, // minutes
|
async function LoadExpress(GoogleDriveCredentials, app = express(), closer = express().listen(1221)){
|
||||||
max: 100 // limit each IP to 100 requests per windowMs
|
return new Promise((resolve => {
|
||||||
});
|
app.get("/request", (req, res) => {
|
||||||
app.use(bodyParser.json()); /* https://github.com/github/fetch/issues/323#issuecomment-331477498 */
|
const SessionUUID = randomUUID();
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
const secret = GoogleDriveCredentials.installed.client_secret;
|
||||||
app.use(limiter);
|
const client = GoogleDriveCredentials.installed.client_id;
|
||||||
app.use(cors());
|
const redirect = `${req.protocol}://${req.headers.host}/${SessionUUID}/save`;
|
||||||
// Urls
|
const oAuth2Client = new google.auth.OAuth2(client, secret, redirect);
|
||||||
app.get("/request", (req, res) => {
|
global.GoogleAuth[SessionUUID] = oAuth2Client;
|
||||||
const secret = GoogleDriveCredentials.installed.client_secret;
|
res.redirect(oAuth2Client.generateAuthUrl({
|
||||||
const client = GoogleDriveCredentials.installed.client_id;
|
access_type: "offline",
|
||||||
const redirect = `${req.protocol}://${req.headers.host}/save`;
|
scope: [
|
||||||
const oAuth2Client = new google.auth.OAuth2(client, secret, redirect);
|
"https://www.googleapis.com/auth/drive"
|
||||||
res.redirect(oAuth2Client.generateAuthUrl(DefaultLoginDrive))
|
]
|
||||||
app.get("/save", (req, res) => {
|
}));
|
||||||
|
});
|
||||||
|
app.get("/:SessionUUID/save", (req, res) => {
|
||||||
|
const { code } = req.query;
|
||||||
|
const { SessionUUID } = req.params;
|
||||||
// http://localhost:6899/save?code=********************************************************************&scope=https://www.googleapis.com/auth/drive
|
// http://localhost:6899/save?code=********************************************************************&scope=https://www.googleapis.com/auth/drive
|
||||||
const code = req.query.code
|
|
||||||
|
const oAuth2Client = global.GoogleAuth[SessionUUID];
|
||||||
oAuth2Client.getToken(code, (err, save_token) => {
|
oAuth2Client.getToken(code, (err, save_token) => {
|
||||||
if (err) return console.error("Error accessing keys and saving, Error:", err);
|
if (err) return console.error("Error accessing keys and saving, Error:", err);
|
||||||
oAuth2Client.setCredentials(save_token);
|
oAuth2Client.setCredentials(save_token);
|
||||||
@@ -46,40 +41,58 @@ function expressGetGoogleDriveToken(callback){
|
|||||||
fs.writeFile(PathToToken, JSON.stringify(save_token, null, 4), function (err){
|
fs.writeFile(PathToToken, JSON.stringify(save_token, null, 4), function (err){
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error("We were unable to save json, please try again later");
|
console.error("We were unable to save json, please try again later");
|
||||||
return close_server();
|
return closer();
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(oAuth2Client);
|
|
||||||
res.json({
|
res.json({
|
||||||
"token": save_token,
|
"token": save_token,
|
||||||
status: "success"
|
status: "success"
|
||||||
})
|
})
|
||||||
close_server();
|
closer.close()
|
||||||
|
resolve(oAuth2Client);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
app.get("*", (req, res)=>{res.redirect("/request")});
|
app.all("*", ({res}) => res.redirect("/request"));
|
||||||
})
|
}));
|
||||||
const saver = app.listen(6658)
|
|
||||||
function close_server() {saver.close()}
|
|
||||||
return 6658
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.authorize = function (callback) {
|
function RandomPort(){
|
||||||
const client_secret = GoogleDriveCredentials.installed.client_secret;
|
let Port = parseInt(Math.random().toString().replace(/[01]\./, "").slice(0, 4));
|
||||||
const client_id = GoogleDriveCredentials.installed.client_id;
|
if (Port > 1024 && Port < 2542) return Port; else return RandomPort();
|
||||||
const redirect_uris = GoogleDriveCredentials.installed.redirect_uris[0].split("@PORT_REDIRECT").join(6658).split("@URLREDIRECT").join("localhost");
|
}
|
||||||
const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris);
|
|
||||||
fs.readFile(PathToToken, (err, user_cred) => {
|
async function authorize() {
|
||||||
if (err) {
|
return new Promise(async resolve => {
|
||||||
var GetReturn = expressGetGoogleDriveToken(callback);
|
const GoogleDriveCredentials = (await (await fetch("https://raw.githubusercontent.com/The-Bds-Maneger/external_files/main/Credentials/Google.json")).json())
|
||||||
if (process.argv0 === "electron") open("http://localhost:6658/request")
|
const client_secret = GoogleDriveCredentials.installed.client_secret;
|
||||||
console.log("Open one of these links in your browser:");
|
const client_id = GoogleDriveCredentials.installed.client_id;
|
||||||
console.log("http://localhost:6658/request");
|
const redirect_uris = "http://localhost:1932/SaveToken"
|
||||||
for (let index of Ips.internal_ip) console.log(`http://${index}:6658/request`)
|
const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris);
|
||||||
return GetReturn
|
fs.readFile(PathToToken, async (err, user_cred) => {
|
||||||
}
|
if (err) {
|
||||||
oAuth2Client.setCredentials(JSON.parse(user_cred));
|
const app = express();
|
||||||
callback(oAuth2Client);
|
app.use(require("body-parser").json());
|
||||||
|
app.use(require("body-parser").urlencoded({ extended: true }));
|
||||||
|
app.use(require("express-rate-limit")({windowMs: 1 * 60 * 1000, max: 100}));
|
||||||
|
app.use(require("cors")());
|
||||||
|
const port = RandomPort();
|
||||||
|
ip_andress.internal_ip.forEach(ips => {
|
||||||
|
let { ipv4, ipv6 } = ips.Interna_IP;
|
||||||
|
console.log(`Open: http://${ipv4}:${port}/request`);
|
||||||
|
if (ipv6) console.log(`Open: http://[${ipv6}]:${port}/request`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Return auth
|
||||||
|
const AuthToken = await LoadExpress(GoogleDriveCredentials, app, app.listen(port));
|
||||||
|
resolve(AuthToken);
|
||||||
|
} else {
|
||||||
|
oAuth2Client.setCredentials(JSON.parse(user_cred));
|
||||||
|
resolve(oAuth2Client);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
authorize,
|
||||||
}
|
}
|
||||||
@@ -1,23 +1,28 @@
|
|||||||
const { resolve } = require("path");
|
const path = require("path");
|
||||||
const { BlobServiceClient, StorageSharedKeyCredential } = require("@azure/storage-blob");
|
const { BlobServiceClient, StorageSharedKeyCredential } = require("@azure/storage-blob");
|
||||||
const NewBdsSettings = require("../../lib/BdsSettings");
|
const NewBdsSettings = require("../../lib/BdsSettings");
|
||||||
const Uploadbackups = async function (object = "Backup.zip", fileLocation = "Backup.zip", callback = function (){}) {
|
|
||||||
const { Account, AccountKey, Container } = NewBdsSettings.GetCloudConfig("Azure");
|
// Upload Function
|
||||||
const sharedKeyCredential = new StorageSharedKeyCredential(Account, AccountKey);
|
async function Uploadbackups(object = "Backup.zip", fileLocation = "Backup.zip", callback = function (){}) {
|
||||||
const blobClient = new BlobServiceClient(`https://${Account}.blob.core.windows.net`, sharedKeyCredential).getContainerClient(Container)
|
return new Promise(async function(resolve, reject){
|
||||||
if (!(blobClient.exists())) await blobClient.create();
|
try {
|
||||||
const containerClient = blobClient.getBlockBlobClient(resolve(object))
|
const { Account, AccountKey, Container } = NewBdsSettings.GetCloudConfig("Azure");
|
||||||
try {
|
const sharedKeyCredential = new StorageSharedKeyCredential(Account, AccountKey);
|
||||||
await containerClient.uploadFile(fileLocation, {
|
const blobClient = new BlobServiceClient(`https://${Account}.blob.core.windows.net`, sharedKeyCredential).getContainerClient(Container)
|
||||||
blockSize: 4 * 1024 * 1024,
|
if (!(blobClient.exists())) await blobClient.create();
|
||||||
concurrency: 20,
|
const containerClient = blobClient.getBlockBlobClient(path.resolve(object));
|
||||||
onProgress: (env) => console.log(env)
|
const Reponse = await containerClient.uploadFile(fileLocation, {
|
||||||
})
|
blockSize: 4 * 1024 * 1024,
|
||||||
console.log("Upload Sucess")
|
concurrency: 20,
|
||||||
if (typeof callback === "function") callback()
|
onProgress: (env) => console.log(env)
|
||||||
} catch (err) {
|
})
|
||||||
console.log(`uploadFile failed, requestId - ${err.details.requestId}, statusCode - ${err.statusCode}, errorCode - ${err.details.errorCode}`);
|
if (typeof callback === "function") callback(Reponse);
|
||||||
}
|
resolve(Reponse);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(`uploadFile failed, requestId - ${err.details.requestId}, statusCode - ${err.statusCode}, errorCode - ${err.details.errorCode}`);
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -3,10 +3,9 @@ const { google } = require("googleapis");
|
|||||||
const { authorize } = require("./Auth/Google");
|
const { authorize } = require("./Auth/Google");
|
||||||
const { GetCloudConfig } = require("../../lib/BdsSettings");
|
const { GetCloudConfig } = require("../../lib/BdsSettings");
|
||||||
|
|
||||||
module.exports.Uploadbackups = function (file_name = "Backup.zip", fileLocation = "Backup.zip", BackupCallback){
|
module.exports.Uploadbackups = async function (file_name = "Backup.zip", fileLocation = "Backup.zip", BackupCallback){
|
||||||
const parent_id = GetCloudConfig("Driver").RootID
|
return new Promise(async function (resolve, reject){
|
||||||
return authorize(function (auth) {
|
const parent_id = GetCloudConfig("Driver").RootID
|
||||||
const drive = google.drive({version: "v3", auth});
|
|
||||||
const UploadFile = {
|
const UploadFile = {
|
||||||
resource: {
|
resource: {
|
||||||
name: file_name
|
name: file_name
|
||||||
@@ -20,14 +19,16 @@ module.exports.Uploadbackups = function (file_name = "Backup.zip", fileLocation
|
|||||||
// Driver Root ID Backups
|
// Driver Root ID Backups
|
||||||
if (parent_id) UploadFile.resource.parents = [parent_id];
|
if (parent_id) UploadFile.resource.parents = [parent_id];
|
||||||
|
|
||||||
// Request
|
const auth = await authorize();
|
||||||
|
const drive = google.drive({version: "v3", auth});
|
||||||
drive.files.create(UploadFile, (err, file) => {
|
drive.files.create(UploadFile, (err, file) => {
|
||||||
if (err) throw Error(err)
|
if (err) reject(err)
|
||||||
else {
|
else {
|
||||||
console.log(`File URL: https://drive.google.com/file/d/${file.data.id}/`);
|
console.log(`File URL: https://drive.google.com/file/d/${file.data.id}/`);
|
||||||
if (typeof BackupCallback === "function") BackupCallback(file);
|
if (typeof BackupCallback === "function") BackupCallback(file);
|
||||||
|
resolve(`https://drive.google.com/file/d/${file.data.id}/`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
// End Upload Backup
|
|
||||||
};
|
};
|
||||||
@@ -4,38 +4,36 @@ const fs = require("fs");
|
|||||||
const { resolve } = require("path");
|
const { resolve } = require("path");
|
||||||
const { CloudConfig } = require("../../lib/BdsSettings");
|
const { CloudConfig } = require("../../lib/BdsSettings");
|
||||||
|
|
||||||
const Uploadbackups = async function (
|
async function Uploadbackups(object = "Backup.zip", fileLocation = resolve(__dirname, "../Backup.zip"), callback = function (data){console.log(data)}){
|
||||||
object = "Backup.zip",
|
return new Promise(async function (resolve, reject){
|
||||||
fileLocation = resolve(__dirname, "../Backup.zip"),
|
try {
|
||||||
callback = function (data){console.log(data)}
|
const bucket = CloudConfig.Oracle().Bucket;
|
||||||
){
|
const provider = new oci_common.ConfigFileAuthenticationDetailsProvider();
|
||||||
const bucket = CloudConfig.Oracle().Bucket;
|
const client = new oci_storage.ObjectStorageClient({
|
||||||
const provider = new oci_common.ConfigFileAuthenticationDetailsProvider();
|
authenticationDetailsProvider: provider
|
||||||
const client = new oci_storage.ObjectStorageClient({
|
});
|
||||||
authenticationDetailsProvider: provider
|
const request = {};
|
||||||
|
const response = await client.getNamespace(request);
|
||||||
|
const namespace = response.value;
|
||||||
|
const stats = fs.statSync(fileLocation);
|
||||||
|
const nodeFsBlob = new oci_storage.NodeFSBlob(fileLocation, stats.size);
|
||||||
|
const objectData = await nodeFsBlob.getData();
|
||||||
|
const putObjectRequest = {
|
||||||
|
namespaceName: namespace,
|
||||||
|
bucketName: bucket,
|
||||||
|
putObjectBody: objectData,
|
||||||
|
objectName: object,
|
||||||
|
contentLength: stats.size
|
||||||
|
};
|
||||||
|
const putObjectResponse = await client.putObject(putObjectRequest);
|
||||||
|
console.log("File upload successful");
|
||||||
|
if (typeof callback === "function") return callback(putObjectResponse);
|
||||||
|
resolve(putObjectResponse);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error ", error);
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
|
||||||
const request = {};
|
|
||||||
const response = await client.getNamespace(request);
|
|
||||||
const namespace = response.value;
|
|
||||||
const stats = fs.statSync(fileLocation);
|
|
||||||
const nodeFsBlob = new oci_storage.NodeFSBlob(fileLocation, stats.size);
|
|
||||||
const objectData = await nodeFsBlob.getData();
|
|
||||||
const putObjectRequest = {
|
|
||||||
namespaceName: namespace,
|
|
||||||
bucketName: bucket,
|
|
||||||
putObjectBody: objectData,
|
|
||||||
objectName: object,
|
|
||||||
contentLength: stats.size
|
|
||||||
};
|
|
||||||
const putObjectResponse = await client.putObject(putObjectRequest);
|
|
||||||
console.log("File upload successful");
|
|
||||||
if (typeof callback === "function") return callback(putObjectResponse);
|
|
||||||
return putObjectResponse;
|
|
||||||
} catch (error) {
|
|
||||||
console.log("Error ", error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ const express = require("express");
|
|||||||
const app = express.Router();
|
const app = express.Router();
|
||||||
const { GetKernel } = require("../../../lib/BdsSystemInfo");
|
const { GetKernel } = require("../../../lib/BdsSystemInfo");
|
||||||
const commandExist = require("../../../lib/commandExist");
|
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("../../Scripts/check");
|
const { token_verify } = require("../../UsersAndtokenChecks");
|
||||||
|
|
||||||
// Backup
|
// Backup
|
||||||
app.get("/backup", (req, res) => {
|
app.get("/backup", (req, res) => {
|
||||||
|
|||||||
@@ -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("../../Scripts/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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user