From 4daf4fe859097e6761cb9d0d516048fe94465b7a Mon Sep 17 00:00:00 2001 From: Suwings Date: Sat, 24 Oct 2020 20:18:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E9=AB=98=E7=BA=A7?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=9C=8D=E5=8A=A1=E5=99=A8API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Process/Mcserver.js | 4 ++++ route/api.js | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/core/Process/Mcserver.js b/core/Process/Mcserver.js index eb4e974..8aaa523 100644 --- a/core/Process/Mcserver.js +++ b/core/Process/Mcserver.js @@ -75,6 +75,10 @@ class MinecraftServer extends ServerProcess { //关服命令 this.dataModel.stopCommand = args.stopCommand || ""; + this.dataModel.dockerConfig = args.dockerConfig || this.dataModel.dockerConfig; + + this.dataModel.mcpingConfig = args.mcpingConfig || this.dataModel.mcpingConfig; + this.propertiesLoad(); } diff --git a/route/api.js b/route/api.js index e62c825..a7ea5b1 100644 --- a/route/api.js +++ b/route/api.js @@ -279,5 +279,26 @@ router.post("/execute/", function (req, res) { } }); + +// 创建服务器实例(JSON) | API +router.post("/advanced_create_server", function (req, res) { + // 仅仅准许管理员使用 + if (!keyManager.isMaster(apiResponse.key(req))) { + apiResponse.forbidden(res); + return; + } + // 解析请求参数 + try { + const params = req.body; + const config = JSON.parse(params.config); + // 创建 + const result = serverModel.createServer(params.serverName, config); + // 返回状态码 + result ? apiResponse.ok(res) : apiResponse.error(res); + } catch (err) { + apiResponse.error(res, err); + } +}); + //模块导出 module.exports = router;