1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

add runCommands to server peering #6404

Signed-off-by: Simon Smith <simonsmith5521@gmail.com>
This commit is contained in:
Simon Smith 2024-09-26 22:56:13 +01:00
parent b90b2ac0bf
commit df64c750cc
2 changed files with 62 additions and 32 deletions

View file

@ -586,6 +586,20 @@ module.exports.CreateMultiServer = function (parent, args) {
}
break;
}
case 'agentCommand': {
if (msg.nodeid != null) {
// Route this message to a connected agent
var agent = obj.parent.webserver.wsagents[msg.nodeid];
if (agent != null) { agent.send(JSON.stringify(msg.command)); }
} else if (msg.meshid != null) {
// Route this message to all connected agents of this mesh
for (var nodeid in obj.parent.webserver.wsagents) {
var agent = obj.parent.webserver.wsagents[nodeid];
if (agent.dbMeshKey == msg.meshid) { try { agent.send(JSON.stringify(msg.command)); } catch (ex) { } }
}
}
break;
}
default: {
// Unknown peer server command
console.log('Unknown action from peer server ' + peerServerId + ': ' + msg.action + '.');