mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-30 08:47:14 +09:00
1 file changed
+19
-3
@@ -794,11 +794,27 @@ app.post("/api/runCommand", (req,res) => {
|
||||
|
||||
// validate request.body
|
||||
let body = req.body;
|
||||
if(body.instanceID
|
||||
&& Object.keys(wsSlaves).includes(body.instanceID)
|
||||
|
||||
if (
|
||||
body.broadcast
|
||||
&& body.command
|
||||
&& typeof body.command == "string"
|
||||
&& body.command[0] == "/"){
|
||||
&& body.command[0] == "/")
|
||||
{
|
||||
let instanceResponses = [];
|
||||
for (let instanceID in wsSlaves) {
|
||||
// skip loop if the property is from prototype
|
||||
if (!wsSlaves.hasOwnProperty(instanceID)) continue;
|
||||
wsSlaves[instanceID].runCommand(body.command);
|
||||
}
|
||||
res.status(200).send({auth: true, message: "success", response: "Cluster wide messaging initiated"});
|
||||
} else if (
|
||||
body.instanceID
|
||||
&& wsSlaves[body.instanceID]
|
||||
&& body.command
|
||||
&& typeof body.command == "string"
|
||||
&& body.command[0] == "/")
|
||||
{
|
||||
// execute command
|
||||
wsSlaves[body.instanceID].runCommand(body.command, data => {
|
||||
res.status(200).send({auth: true, message: "success", data});
|
||||
|
||||
Reference in new issue
Block a user