remoteCommands added plugin and master API endpoint for executing things

This commit is contained in:
Danielv123 committed 2018-04-09 11:25:57 +02:00
1 parent be49deb170
commit 43c1f2ae93
7 files changed
+108 -8

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
/*
Config for clusterio remote command plugin.
Allows you to execute commands on slaves with a web API.
Careful, may allow for RCE vulnerabilities.
*/
var modInfo = require("./info.json");
module.exports = {
// Name of package. For display somewhere I guess.
name: "remoteCommands",
version: "1.0.0",
binary: "nodePackage",
description: "Config for clusterio remote command plugin. Allows you to execute commands on slaves with a web API.",
}
+23
View File
@@ -0,0 +1,23 @@
module.exports.main = class remoteCommands {
constructor(mergedConfig, messageInterface, extras){
console.log = messageInterface;
this.messageInterface = messageInterface;
this.config = mergedConfig;
this.socket = extras.socket;
if(this.config.allowRemoteCommandExecution){
this.socket.on("runCommand", data => {
let {commandID} = data;
this.messageInterface(data.command);
if(commandID){
this.socket.emit("runCommandReturnValue", {
commandID,
body: {
info: "Command was sent to factorio",
},
});
}
});
}
}
}