mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-22 12:52:50 +03:00
Server peering improvements.
This commit is contained in:
parent
ad5777e4b8
commit
cd6d5b12ac
10
meshuser.js
10
meshuser.js
@ -282,8 +282,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
|
||||
// Route a command to all targets in a mesh
|
||||
function routeCommandToMesh(meshid, command) {
|
||||
// Send the request to all peer servers
|
||||
// TODO !!!!
|
||||
// If we have peer servers, inform them of this command to send to all agents of this device group
|
||||
if (parent.parent.multiServer != null) { parent.parent.multiServer.DispatchMessage({ action: 'agentMsgByMeshId', meshid: meshid, command: command }); }
|
||||
|
||||
// See if the node is connected
|
||||
for (var nodeid in parent.wsagents) {
|
||||
@ -3347,10 +3347,10 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
|
||||
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(mesh, [user._id]), obj, event);
|
||||
|
||||
// Send new policy to all computers on this mesh
|
||||
//routeCommandToMesh(command.meshid, { action: 'amtPolicy', amtPolicy: amtpolicy });
|
||||
// If we have peer servers, inform them of the new Intel AMT policy for this device group
|
||||
if (parent.parent.multiServer != null) { parent.parent.multiServer.DispatchMessage({ action: 'newIntelAmtPolicy', meshid: command.meshid, amtpolicy: amtpolicy }); }
|
||||
|
||||
// See if the node is connected
|
||||
// See if any agents for the affected device group is connected, if so, update the Intel AMT policy
|
||||
for (var nodeid in parent.wsagents) {
|
||||
const agent = parent.wsagents[nodeid];
|
||||
if (agent.dbMeshKey == command.meshid) { agent.sendUpdatedIntelAmtPolicy(amtpolicy); }
|
||||
|
@ -570,6 +570,23 @@ module.exports.CreateMultiServer = function (parent, args) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'newIntelAmtPolicy': {
|
||||
// See if any agents for the affected device group is connected, if so, update the Intel AMT policy
|
||||
for (var nodeid in obj.parent.webserver.wsagents) {
|
||||
const agent = obj.parent.webserver.wsagents[nodeid];
|
||||
if (agent.dbMeshKey == msg.meshid) { agent.sendUpdatedIntelAmtPolicy(msg.amtpolicy); }
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'agentMsgByMeshId': {
|
||||
// See if any agents for the target device group is connected, if so, send the message
|
||||
const jsonCmd = JSON.stringify(msg.command);
|
||||
for (var nodeid in obj.parent.webserver.wsagents) {
|
||||
var agent = obj.parent.webserver.wsagents[nodeid];
|
||||
if (agent.dbMeshKey == msg.meshid) { try { agent.send(jsonCmd); } catch (ex) { } }
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// Unknown peer server command
|
||||
console.log('Unknown action from peer server ' + peerServerId + ': ' + msg.action + '.');
|
||||
@ -651,12 +668,12 @@ module.exports.CreateMultiServer = function (parent, args) {
|
||||
peerTunnel.close = function (arg) {
|
||||
if (arg == 2) {
|
||||
// Hard close, close the TCP socket
|
||||
if (peerTunnel.ws1 != null) { try { peerTunnel.ws1._socket._parent.end(); peerTunnel.parent.parent.debug('peer', 'FTunnel1: Hard disconnect'); } catch (e) { console.log(e); } }
|
||||
if (peerTunnel.ws2 != null) { try { peerTunnel.ws2._socket._parent.end(); peerTunnel.parent.parent.debug('peer', 'FTunnel2: Hard disconnect'); } catch (e) { console.log(e); } }
|
||||
if (peerTunnel.ws1 != null) { try { peerTunnel.ws1._socket._parent.end(); peerTunnel.parent.parent.debug('peer', 'FTunnel1: Hard disconnect'); } catch (e) { console.log(e); } delete peerTunnel.ws1; }
|
||||
if (peerTunnel.ws2 != null) { try { peerTunnel.ws2._socket._parent.end(); peerTunnel.parent.parent.debug('peer', 'FTunnel2: Hard disconnect'); } catch (e) { console.log(e); } delete peerTunnel.ws2; }
|
||||
} else {
|
||||
// Soft close, close the websocket
|
||||
if (peerTunnel.ws1 != null) { try { peerTunnel.ws1.close(); peerTunnel.parent.parent.debug('peer', 'FTunnel1: Soft disconnect '); } catch (e) { console.log(e); } }
|
||||
if (peerTunnel.ws2 != null) { try { peerTunnel.ws2.close(); peerTunnel.parent.parent.debug('peer', 'FTunnel2: Soft disconnect '); } catch (e) { console.log(e); } }
|
||||
if (peerTunnel.ws1 != null) { try { peerTunnel.ws1.close(); peerTunnel.parent.parent.debug('peer', 'FTunnel1: Soft disconnect '); } catch (e) { console.log(e); } delete peerTunnel.ws1; }
|
||||
if (peerTunnel.ws2 != null) { try { peerTunnel.ws2.close(); peerTunnel.parent.parent.debug('peer', 'FTunnel2: Soft disconnect '); } catch (e) { console.log(e); } delete peerTunnel.ws2; }
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user