Pocketmine init #79
@ -1,3 +1,5 @@
|
||||
node_modules/
|
||||
# node_modules/
|
||||
Docker/
|
||||
!Docker/root_path
|
||||
!Docker/root_path
|
||||
.git/
|
||||
Docker.sh
|
@ -1,10 +1,9 @@
|
||||
#!/bin/bash
|
||||
docker_image_name='thebdsmaneger/maneger'
|
||||
docker build -f Docker/Dockerfile --tag ${docker_image_name} . && {
|
||||
docker build -f Docker/Dockerfile ${1} --tag ${docker_image_name} . && {
|
||||
echo "----------------------------------------------"
|
||||
read -rp "Run Image? (Y/n) " -e -i "y" DockerRun
|
||||
if [ "${DockerRun}" == "y" ];then docker run -ti --rm -P -v /tmp/bds:/home/bds ${1} ${docker_image_name};
|
||||
elif [ "${DockerRun}" == "Y" ];then docker run -ti --rm -P -v /tmp/bds:/home/bds ${1} ${docker_image_name};
|
||||
else echo "Run: \"docker run -ti --rm -P -v /tmp/bds:/home/bds ${1} ${docker_image_name}\"";
|
||||
if [ -e "/tmp/start_image" ];then DockerRun="y"; else read -rp "Run Image? (Y/n) " -e -i "y" DockerRun;fi
|
||||
if [ -e "/tmp/start_image" ] || [ "${DockerRun}" == "y" ] || [ "${DockerRun}" == "Y" ];then [ -e "/tmp/start_image" ]|| touch /tmp/start_image ; docker run -ti --rm -p 8887:80/tcp -p 19132/udp -p 19133/udp -v /tmp/bds:/home/bds ${2} ${docker_image_name};
|
||||
else echo "Run: \"docker run -ti --rm -p 8887:80 -p 19132/udp -p 19133/udp -v /tmp/bds:/home/bds ${2} ${docker_image_name}\"";
|
||||
fi
|
||||
}
|
@ -10,20 +10,29 @@ case $(uname -m) in "x86_64") echo "";; \
|
||||
*) wget https://raw.githubusercontent.com/The-Bds-Maneger/Raw_files/main/linux_libries.zip -O /tmp/libries.zip && unzip /tmp/libries.zip -d / && rm -rfv /tmp/libries.zip ;; \
|
||||
esac ;\
|
||||
rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* /tmp/* && \
|
||||
mkdir -p /home/bds/ && rm -rfv /etc/nginx/sites-available/default
|
||||
mkdir -p /home/bds/ && rm -rfv /etc/nginx/sites-*/default
|
||||
|
||||
ENV \
|
||||
TELEGRAM_TOKEN="null" \
|
||||
DESCRIPTION="running Minecraft Bedrock Server on the docker by Bds Manager" \
|
||||
WORLD_NAME="Bds Maneger Docker" \
|
||||
GAMEMODE="survival" \
|
||||
DIFFICULTY="normal" \
|
||||
XBOX_ACCOUNT="false" \
|
||||
PLAYERS="13" \
|
||||
BDS_VERSION="latest" \
|
||||
SERVER="bedrock" \
|
||||
BDS_REINSTALL="true" \
|
||||
Docker_Debug_Script="false"
|
||||
EXPOSE 80/tcp 19132/udp 19133/udp
|
||||
ENV BDS_DOCKER_IMAGE="true" HOME="/home/bds/"
|
||||
|
||||
# Copy Files
|
||||
COPY ./Docker/root_path/ /
|
||||
COPY ./ /opt/bdsCore/
|
||||
RUN cd /opt/bdsCore/ && npm install --no-save
|
||||
ENV TELEGRAM_TOKEN="null" DESCRIPTION="running Minecraft Bedrock Server on the docker by Bds Manager" \
|
||||
WORLD_NAME="Bds Maneger Docker" GAMEMODE="survival" DIFFICULTY="normal" XBOX_ACCOUNT="false" PLAYERS="13" \
|
||||
BDS_VERSION="latest" SERVER="bedrock" BDS_REINSTALL="true" Docker_Debug_Script="false" \
|
||||
ngrok_token=""
|
||||
|
||||
RUN mkdir -p /home/bds/.config/bds_core
|
||||
EXPOSE 80/tcp 19132/udp 19133/udp
|
||||
ENV BDS_DOCKER_IMAGE="true" HOME="/home/bds/"
|
||||
|
||||
# Entrypint
|
||||
WORKDIR /home/bds/
|
||||
|
@ -1,10 +1,9 @@
|
||||
const bds = require("/opt/bdsCore/index");
|
||||
// const {bds_dir} = require("/opt/bdsCore/index");
|
||||
const { existsSync, readFileSync } = require("fs")
|
||||
const { resolve, join } = require("path")
|
||||
|
||||
// Enable APIs
|
||||
bds.api();
|
||||
bds.rest();
|
||||
|
||||
// Log function
|
||||
function output(dados){var out = dados; if (out.slice(-1) == "\n") out = out.slice(0, -1); console.log(out)}
|
||||
|
1
Docker/root_path/etc/nginx/conf.d/largerequest.conf
Normal file
1
Docker/root_path/etc/nginx/conf.d/largerequest.conf
Normal file
@ -0,0 +1 @@
|
||||
client_max_body_size 512M;
|
@ -2,20 +2,19 @@ server {
|
||||
listen [::]:80 ipv6only=on;
|
||||
listen 80;
|
||||
server_name _;
|
||||
root /html;
|
||||
index index.html;
|
||||
location /api/log {
|
||||
proxy_pass http://localhost:6565/;
|
||||
}
|
||||
location /api {
|
||||
proxy_pass http://localhost:1932;
|
||||
proxy_pass http://localhost:1932/;
|
||||
}
|
||||
#
|
||||
location /api/log/ {
|
||||
proxy_pass http://localhost:6565/;
|
||||
}
|
||||
location /api/ {
|
||||
proxy_pass http://localhost:1932;
|
||||
}
|
||||
location / {
|
||||
root /html/
|
||||
proxy_pass http://localhost:1932/;
|
||||
}
|
||||
}
|
1
Docker/root_path/etc/nginx/sites-enabled/default
Symbolic link
1
Docker/root_path/etc/nginx/sites-enabled/default
Symbolic link
@ -0,0 +1 @@
|
||||
/etc/nginx/sites-available/default
|
@ -71,21 +71,11 @@
|
||||
}
|
||||
</script>
|
||||
<fieldset>
|
||||
<span>Bds Maneger REST port:</span><input class="bds_aiptoken" value="1932" disabled id="rest_port" type="number">
|
||||
<p><span>Bds Maneger Log port:</span><input class="bds_aiptoken" value="6565" disabled id="log_port" type="number"></p>
|
||||
<div class="config_space"></div>
|
||||
<p>
|
||||
<span>Bds Maneger address:</span>
|
||||
<input class="bds_aiptoken" type="text" placeholder="mcpe.sh23.org" id="bds_addr" oninput="saveAddress();" onchange="saveAddress();">
|
||||
<div class="config_space"></div>
|
||||
<span>Bds Maneger Token:</span><input class="bds_aiptoken" type="text" id="bds_token" oninput="changeToken();" onchange="changeToken();">
|
||||
<span>Bds Maneger Token:</span><input class="bds_aiptoken" type="text" id="bds_token" oninput="changeToken();" onchange="changeToken();">
|
||||
<p><a style="display: none;" id="ReloadPage" onclick="location.reload()">Reload Page</a></p>
|
||||
</p>
|
||||
<!------------------------------------------------------------------------------------------------------------>
|
||||
<div class="config_space">
|
||||
<input type="file" accept="image/*" disabled id="qrcodeinput">
|
||||
<script>
|
||||
|
||||
</script>
|
||||
<input type="file" accept="application/zip" id="WorldUpload" onchange="UploadWorld(this)">
|
||||
</div>
|
||||
</fieldset>
|
||||
<!-- -->
|
||||
|
@ -1,79 +1,89 @@
|
||||
console.info("Welcome to Bds Maneger Web 2.0")
|
||||
const token = (localStorage.getItem("the_token") || undefined),
|
||||
andress = (localStorage.getItem("the_addr") || undefined),
|
||||
port_log = (localStorage.getItem("the_log_port") || 6565),
|
||||
port_REST = (localStorage.getItem("the_log_port") || 1932)
|
||||
|
||||
if (andress){
|
||||
document.getElementById("bds_token").value = token
|
||||
document.getElementById("bds_addr").value = andress
|
||||
function basic_service (service){
|
||||
const post_men = {
|
||||
const token = (localStorage.getItem("the_token") || undefined)
|
||||
document.getElementById("bds_token").value = token
|
||||
function basic_service (service){
|
||||
fetch("/api/service",{
|
||||
method: "POST",
|
||||
mode: "cors",
|
||||
body: JSON.stringify({
|
||||
"token": token,
|
||||
"command": service
|
||||
}),
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
fetch(`http://${andress}:${port_REST}/service`,{
|
||||
method: "POST",
|
||||
mode: "cors",
|
||||
body: JSON.stringify(post_men),
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then(response => response.json()).then(lan => {
|
||||
console.log(lan)
|
||||
})
|
||||
}
|
||||
function bds_start(){
|
||||
basic_service("start")
|
||||
}
|
||||
}).then(response => response.json()).then(lan => {
|
||||
console.log(lan)
|
||||
})
|
||||
}
|
||||
function bds_start(){return basic_service("start")}
|
||||
|
||||
function bds_stop (){
|
||||
basic_service("stop")
|
||||
}
|
||||
function bds_stop (){basic_service("stop")}
|
||||
|
||||
function bds_restart(){
|
||||
let log = document.getElementById("bds_log").innerHTML
|
||||
console.log("restart request")
|
||||
if (!(log.includes("Quit correctly"))) bds_stop()
|
||||
bds_start
|
||||
}
|
||||
function bds_command(){
|
||||
var post_men = {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function bds_restart(){
|
||||
let log = document.getElementById("bds_log").innerHTML
|
||||
console.log("restart request")
|
||||
if (!(log.includes("Quit correctly"))) bds_stop()
|
||||
bds_start()
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function bds_command(){
|
||||
fetch("/api/bds_command", {
|
||||
method: "POST",
|
||||
mode: "cors",
|
||||
body: JSON.stringify({
|
||||
"token": token,
|
||||
"command": document.getElementById("command").value
|
||||
};
|
||||
fetch(`http://${andress}:${port_REST}/bds_command`, {
|
||||
method: "POST",
|
||||
mode: "cors",
|
||||
body: JSON.stringify(post_men),
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}),
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
).then(response => response.json()).then(lan => {
|
||||
if (lan.status !== 200) {console.log(lan)}
|
||||
else {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
setInterval(() => {
|
||||
fetch(`http://${andress}:${port_log}/?format=html`).then(response => response.text()).then(lan => {
|
||||
document.getElementById("bds_log").innerHTML = lan
|
||||
}).catch (function (err){null});
|
||||
}, 2 * 1000);
|
||||
} else {
|
||||
/* alert("Please set the Bds Maneger's ip or address, and the authorization token for some advanced features")
|
||||
document.getElementById("config").style.display = "block" */
|
||||
).then(response => response.json()).then(lan => {
|
||||
console.log(lan);
|
||||
})
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function UploadWorld(){
|
||||
const input = document.getElementById("WorldUpload").files
|
||||
const formData = new FormData();
|
||||
console.log(input);
|
||||
formData.append(input[0].name, input[0]);
|
||||
for(var pair of formData.entries()) {
|
||||
console.log(pair[0]+ ", "+ JSON.stringify(pair[1]));
|
||||
}
|
||||
fetch("/api/upload_world", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
"token": token
|
||||
},
|
||||
body: input[0]
|
||||
}).catch(
|
||||
err => {
|
||||
throw Error(err)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const logInterval = setInterval(() => {
|
||||
fetch("/api/log?format=html").then(response => response.text()).then(lan => {
|
||||
document.getElementById("bds_log").innerHTML = lan
|
||||
}).catch (function (err){
|
||||
if (confirm("The server crashed or had an error, wants to reload the page")) location.reload(true)
|
||||
else clearInterval(logInterval)
|
||||
throw Error(err)
|
||||
});
|
||||
}, 2 * 1000);
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function settings_display(){
|
||||
const se_display = document.getElementById("config").style.display
|
||||
if (se_display === "block"){
|
||||
document.getElementById("config").style.display = "none"
|
||||
} else {
|
||||
document.getElementById("config").style.display = "block"
|
||||
}
|
||||
if (se_display === "block") document.getElementById("config").style.display = "none"
|
||||
else document.getElementById("config").style.display = "block"
|
||||
}
|
||||
|
54
index.js
54
index.js
@ -58,6 +58,7 @@ if (process.platform == "win32") {
|
||||
"pocketmine": true,
|
||||
"java": true
|
||||
}
|
||||
if (process.arch === "aarch64") valid_platform.pocketmine = false;
|
||||
} else if (process.platform == "darwin") {
|
||||
if (arch === "arm64") require("open")("https://github.com/The-Bds-Maneger/core/wiki/system_support#information-for-users-of-macbooks-and-imacs-with-m1-processor")
|
||||
else require("open")("https://github.com/The-Bds-Maneger/core/wiki/system_support#macos-with-intel-processors");
|
||||
@ -241,10 +242,7 @@ if (fs.existsSync(bds_config_file)){
|
||||
},
|
||||
"bds_ban": (bds_config.bds_ban||["Steve", "Alex", "steve", "alex"]),
|
||||
"telegram_token": (bds_config.telegram_token||undefined),
|
||||
"Google_Drive_root_backup_id": (bds_config.Google_Drive_root_backup_id||undefined),
|
||||
"java_config": {
|
||||
"max": ram_total
|
||||
}
|
||||
"Google_Drive_root_backup_id": (bds_config.Google_Drive_root_backup_id||undefined)
|
||||
}
|
||||
fs.writeFileSync(bds_config_file, JSON.stringify(bds_config, null, 4))
|
||||
bds_config_export()
|
||||
@ -265,15 +263,7 @@ if (fs.existsSync(bds_config_file)){
|
||||
"Google_Drive_root_backup_id": undefined,
|
||||
"telegram_admin": [
|
||||
"all_users"
|
||||
],
|
||||
"java_config": {
|
||||
"max": ram_total
|
||||
},
|
||||
// bedrock_config is not yet in use
|
||||
"bedrock_config": {
|
||||
"from": "oficial", // Bedrock Server software, such as the one provided by Mojang, lifeboat, pocketmine-mp. more information: https://github.com/The-Bds-Maneger/core/wiki/bedrock_software#minecraft-bedrock-servers
|
||||
"url": undefined // JSON Array file with versions and download url
|
||||
}
|
||||
]
|
||||
}
|
||||
fs.writeFileSync(bds_config_file, JSON.stringify(bds_config, null, 4))
|
||||
}
|
||||
@ -284,6 +274,11 @@ module.exports.platform_version_update = function (version){
|
||||
fs.writeFileSync(bds_config_file, JSON.stringify(bds_config, null, 4))
|
||||
bds_config_export()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save ID Google Drive folder to Backups
|
||||
*/
|
||||
module.exports.save_google_id = function (id){
|
||||
let bds_config = JSON.parse(fs.readFileSync(bds_config_file, "utf8"))
|
||||
bds_config.Google_Drive_root_backup_id = id
|
||||
@ -292,39 +287,12 @@ module.exports.save_google_id = function (id){
|
||||
return true
|
||||
}
|
||||
module.exports.platform = bds_config.bds_platform
|
||||
function update_java_memory(total){
|
||||
if (total.includes("GB")) total = (total = Math.trunc(total / 1024))
|
||||
else if (total.includes("GIB")) total = (total = Math.trunc(total / 1000))
|
||||
else if (total.includes("gb")) total = (total = Math.trunc(total / 1024))
|
||||
else if (total.includes("gib")) total = (total = Math.trunc(total / 1000))
|
||||
else if (total.includes("MB")) total = (total = Math.trunc(total))
|
||||
else if (total.includes("mb")) total = (total = Math.trunc(total))
|
||||
else if (total.includes("mib")) total = (total = Math.trunc(total))
|
||||
else if (total.includes("MIB")) total = (total = Math.trunc(total))
|
||||
else throw new Error("Please enter a valid value such as: 1GB, 1gb, 1024mb ,1024MB, 1000MIB, 10000mib ,1GIB ,1gib")
|
||||
if (bds_config.bds_platform === "java"){
|
||||
bds_config.java_config.max =
|
||||
fs.writeFileSync(bds_config_file, JSON.stringify(bds_config, null, 4))
|
||||
}
|
||||
}
|
||||
|
||||
const log_file = path.join(log_dir, `${date()}_${bds_config.bds_platform}_Bds_log.log`);
|
||||
module.exports.log_file = log_file
|
||||
|
||||
/**
|
||||
* Update the value of how much java will use ram when the java platform is selected
|
||||
*
|
||||
* the following values are: 1024mb, 1024MB, 1000MIB, 1000mib, 1GB, 1gb, 1GIB, 1gib
|
||||
* Bds Maneger Latest log file.
|
||||
*/
|
||||
module.exports.memory_for_the_java = update_java_memory
|
||||
|
||||
if (process.env.AUTOUPDATE_JAVA_RAM !== undefined||undefined){
|
||||
setInterval(() => {
|
||||
let ram_total = Math.trunc((require("os").freemem() / 1000 / 1000) - 212)
|
||||
if (ram_total >= 1000) ram_total = ram_total - 1000
|
||||
update_java_memory(ram_total+"mb")
|
||||
}, 2500);
|
||||
}
|
||||
const log_file = path.join(log_dir, `${date()}_${bds_config.bds_platform}_Bds_log.log`);
|
||||
module.exports.log_file = log_file
|
||||
|
||||
function bds_config_export (){
|
||||
/**
|
||||
|
75
package-lock.json
generated
75
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@the-bds-maneger/core",
|
||||
"version": "1.8.6.5",
|
||||
"version": "1.8.6.6",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@the-bds-maneger/core",
|
||||
"version": "1.8.6.5",
|
||||
"version": "1.8.6.6",
|
||||
"hasInstallScript": true,
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
@ -16,6 +16,7 @@
|
||||
"cors": "^2.8.5",
|
||||
"crypto": "^1.0.1",
|
||||
"express": "^4.17.1",
|
||||
"express-fileupload": "^1.2.1",
|
||||
"express-rate-limit": "^5.2.3",
|
||||
"get-folder-size": "^2.0.1",
|
||||
"googleapis": "^71.0.0",
|
||||
@ -483,6 +484,17 @@
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
|
||||
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
|
||||
},
|
||||
"node_modules/busboy": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz",
|
||||
"integrity": "sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==",
|
||||
"dependencies": {
|
||||
"dicer": "0.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bytes": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
|
||||
@ -727,6 +739,17 @@
|
||||
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
|
||||
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
|
||||
},
|
||||
"node_modules/dicer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/dicer/-/dicer-0.3.0.tgz",
|
||||
"integrity": "sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA==",
|
||||
"dependencies": {
|
||||
"streamsearch": "0.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dijkstrajs": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.1.tgz",
|
||||
@ -1072,6 +1095,17 @@
|
||||
"node": ">= 0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/express-fileupload": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/express-fileupload/-/express-fileupload-1.2.1.tgz",
|
||||
"integrity": "sha512-fWPNAkBj+Azt9Itmcz/Reqdg3LeBfaXptDEev2JM8bCC0yDptglCnlizhf0YZauyU5X/g6v7v4Xxqhg8tmEfEA==",
|
||||
"dependencies": {
|
||||
"busboy": "^0.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/express-rate-limit": {
|
||||
"version": "5.2.6",
|
||||
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.2.6.tgz",
|
||||
@ -2493,6 +2527,14 @@
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/streamsearch": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz",
|
||||
"integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=",
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/string-width": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz",
|
||||
@ -3303,6 +3345,14 @@
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
|
||||
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
|
||||
},
|
||||
"busboy": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz",
|
||||
"integrity": "sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==",
|
||||
"requires": {
|
||||
"dicer": "0.3.0"
|
||||
}
|
||||
},
|
||||
"bytes": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
|
||||
@ -3491,6 +3541,14 @@
|
||||
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
|
||||
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
|
||||
},
|
||||
"dicer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/dicer/-/dicer-0.3.0.tgz",
|
||||
"integrity": "sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA==",
|
||||
"requires": {
|
||||
"streamsearch": "0.1.2"
|
||||
}
|
||||
},
|
||||
"dijkstrajs": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.1.tgz",
|
||||
@ -3762,6 +3820,14 @@
|
||||
"vary": "~1.1.2"
|
||||
}
|
||||
},
|
||||
"express-fileupload": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/express-fileupload/-/express-fileupload-1.2.1.tgz",
|
||||
"integrity": "sha512-fWPNAkBj+Azt9Itmcz/Reqdg3LeBfaXptDEev2JM8bCC0yDptglCnlizhf0YZauyU5X/g6v7v4Xxqhg8tmEfEA==",
|
||||
"requires": {
|
||||
"busboy": "^0.3.1"
|
||||
}
|
||||
},
|
||||
"express-rate-limit": {
|
||||
"version": "5.2.6",
|
||||
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.2.6.tgz",
|
||||
@ -4816,6 +4882,11 @@
|
||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
|
||||
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
|
||||
},
|
||||
"streamsearch": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz",
|
||||
"integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo="
|
||||
},
|
||||
"string-width": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz",
|
||||
|
@ -3,7 +3,7 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"version": "1.8.6.5",
|
||||
"version": "1.8.6.6",
|
||||
"description": "scripts to manage minecraft bedrock server",
|
||||
"private": false,
|
||||
"main": "index.js",
|
||||
@ -50,6 +50,7 @@
|
||||
"cors": "^2.8.5",
|
||||
"crypto": "^1.0.1",
|
||||
"express": "^4.17.1",
|
||||
"express-fileupload": "^1.2.1",
|
||||
"express-rate-limit": "^5.2.3",
|
||||
"get-folder-size": "^2.0.1",
|
||||
"googleapis": "^71.0.0",
|
||||
|
43
rest/api.js
43
rest/api.js
@ -6,17 +6,21 @@ var cors = require("cors");
|
||||
const rateLimit = require("express-rate-limit");
|
||||
const token_verify = require("./token_api_check")
|
||||
const bodyParser = require("body-parser");
|
||||
const fileUpload = require("express-fileupload");
|
||||
|
||||
function api(port_api){
|
||||
const app = express();
|
||||
// Enable if you're behind a reverse proxy (Heroku, Bluemix, AWS ELB, Nginx, etc)
|
||||
// Enable if you"re behind a reverse proxy (Heroku, Bluemix, AWS ELB, Nginx, etc)
|
||||
// see https://expressjs.com/en/guide/behind-proxies.html
|
||||
// app.set('trust proxy', 1);
|
||||
// app.set("trust proxy", 1);
|
||||
|
||||
const limiter = rateLimit({
|
||||
windowMs: 15 * 60 * 1000, // 15 minutes
|
||||
max: 100 // limit each IP to 100 requests per windowMs
|
||||
});
|
||||
app.use(fileUpload({
|
||||
limits: { fileSize: 512 * 1024 }
|
||||
}));
|
||||
app.use(cors());
|
||||
app.use(bodyParser.json()); /* https://github.com/github/fetch/issues/323#issuecomment-331477498 */
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
@ -24,13 +28,6 @@ function api(port_api){
|
||||
// app.get("/configs", (req, res) => {return res.send(bds.get_config());});
|
||||
app.get("/info", (req, res) => {
|
||||
const config = bds.get_config()
|
||||
var java;
|
||||
if (bds.platform === "bedrock") java = {}
|
||||
else java = {
|
||||
java: {
|
||||
"max_ram_memory": bds.bds_config.java_config.max
|
||||
}
|
||||
}
|
||||
var json_http = {
|
||||
"server": {
|
||||
"bds_config_version": bds.bds_config.version,
|
||||
@ -40,7 +37,6 @@ function api(port_api){
|
||||
"whitelist": config.white_list,
|
||||
"xbox": config.online_mode,
|
||||
"max_players": config.max_players,
|
||||
...java
|
||||
},
|
||||
"running": bds.detect(),
|
||||
"bds_platform": bds.bds_plataform,
|
||||
@ -136,23 +132,20 @@ function api(port_api){
|
||||
"message": EMN
|
||||
})
|
||||
});
|
||||
app.post("/bds_command", (req, res) => {
|
||||
const body = req.body
|
||||
var pass = token_verify(body.token)
|
||||
app.post("/upload_world", (req, res) => {
|
||||
var pass = token_verify(req.headers.token)
|
||||
if (pass){
|
||||
const command = body.command
|
||||
const teste = bds.command(command)
|
||||
res.send({
|
||||
"status": 200,
|
||||
"command": body.command,
|
||||
"log": teste,
|
||||
"message": `authorized to ${body.token}`
|
||||
})
|
||||
var fileWorld;
|
||||
console.log(req.files);
|
||||
if (!req.files || Object.keys(req.files).length === 0) return res.status(400).send("No files were uploaded.");
|
||||
let files = Object.getOwnPropertyNames(req.files)
|
||||
for (let file in files){
|
||||
fileWorld = req.files[files[file]];
|
||||
// Use the mv() method to place the file somewhere on your server
|
||||
console.log(fileWorld.data);
|
||||
}
|
||||
} else {
|
||||
res.send({
|
||||
"status": 401,
|
||||
"message": "not authorized"
|
||||
})
|
||||
return res.status(400).send("Token is not valid!");
|
||||
}
|
||||
});
|
||||
const port = (port_api||1932)
|
||||
|
Reference in New Issue
Block a user