mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-24 06:05:53 -05:00
Added soft/hard agent disconnect
This commit is contained in:
parent
06ee41c3ad
commit
1473b091b0
@ -32,8 +32,8 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
|
|
||||||
// Disconnect this agent
|
// Disconnect this agent
|
||||||
obj.close = function (arg) {
|
obj.close = function (arg) {
|
||||||
//console.log('MeshAgent.close(' + arg + ')');
|
if ((arg == 1) || (arg == null)) { try { obj.ws.close(); obj.parent.parent.debug(1, 'Soft disconnect ' + obj.nodeid); } catch (e) { console.log(e); } } // Soft close, close the websocket
|
||||||
if (arg !== 1) { try { obj.ws.close(); } catch (e) { } }
|
if (arg == 2) { try { obj.ws._socket._parent.end(); obj.parent.parent.debug(1, 'Hard disconnect ' + obj.nodeid); } catch (e) { console.log(e); } } // Hard close, close the TCP socket
|
||||||
if (obj.parent.wsagents[obj.dbNodeKey] == obj) {
|
if (obj.parent.wsagents[obj.dbNodeKey] == obj) {
|
||||||
delete obj.parent.wsagents[obj.dbNodeKey];
|
delete obj.parent.wsagents[obj.dbNodeKey];
|
||||||
obj.parent.parent.ClearConnectivityState(obj.dbMeshKey, obj.dbNodeKey, 1);
|
obj.parent.parent.ClearConnectivityState(obj.dbMeshKey, obj.dbNodeKey, 1);
|
||||||
@ -211,7 +211,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
ws.on('error', function (err) { console.log(err); });
|
ws.on('error', function (err) { console.log(err); });
|
||||||
|
|
||||||
// If the mesh agent web socket is closed, clean up.
|
// If the mesh agent web socket is closed, clean up.
|
||||||
ws.on('close', function (req) { obj.close(1); });
|
ws.on('close', function (req) { obj.close(0); });
|
||||||
|
|
||||||
// Start authenticate the mesh agent by sending a auth nonce & server TLS cert hash.
|
// Start authenticate the mesh agent by sending a auth nonce & server TLS cert hash.
|
||||||
// Send 256 bits SHA256 hash of TLS cert public key + 256 bits nonce
|
// Send 256 bits SHA256 hash of TLS cert public key + 256 bits nonce
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "meshcentral",
|
"name": "meshcentral",
|
||||||
"version": "0.0.6-u",
|
"version": "0.0.6-v",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Remote Management",
|
"Remote Management",
|
||||||
"Intel AMT",
|
"Intel AMT",
|
||||||
|
@ -3515,7 +3515,7 @@
|
|||||||
if (e.shiftKey == true) { meshserver.Send({ action: 'uploadagentcore', nodeid: consoleNode._id, path:'*' }); } // Upload default core
|
if (e.shiftKey == true) { meshserver.Send({ action: 'uploadagentcore', nodeid: consoleNode._id, path:'*' }); } // Upload default core
|
||||||
else if (e.altKey == true) { meshserver.Send({ action: 'uploadagentcore', nodeid: consoleNode._id }); } // Clear the core
|
else if (e.altKey == true) { meshserver.Send({ action: 'uploadagentcore', nodeid: consoleNode._id }); } // Clear the core
|
||||||
else if (e.ctrlKey == true) { p15uploadCore2(); } // Upload the core from a file
|
else if (e.ctrlKey == true) { p15uploadCore2(); } // Upload the core from a file
|
||||||
else { setDialogMode(2, "Change Mesh Agent Core", 3, p15uploadCoreEx, '<select id=d3coreMode style=float:right;width:260px><option value=1>Upload default server core</option><option value=2>Clear the core</option><option value=3>Upload a core file</option><option value=4>Force disconnect agent</option></select><div>Change Core</div>'); }
|
else { setDialogMode(2, "Change Mesh Agent Core", 3, p15uploadCoreEx, '<select id=d3coreMode style=float:right;width:260px><option value=1>Upload default server core</option><option value=2>Clear the core</option><option value=3>Upload a core file</option><option value=4>Soft disconnect agent</option><option value=5>Hard disconnect agent</option></select><div>Change Core</div>'); }
|
||||||
}
|
}
|
||||||
|
|
||||||
function p15uploadCoreEx() {
|
function p15uploadCoreEx() {
|
||||||
@ -3529,8 +3529,11 @@
|
|||||||
// Upload file as core
|
// Upload file as core
|
||||||
p15uploadCore2();
|
p15uploadCore2();
|
||||||
} else if (Q('d3coreMode').value == 4) {
|
} else if (Q('d3coreMode').value == 4) {
|
||||||
// Force disconnect the mesh agent
|
// Soft disconnect the mesh agent
|
||||||
meshserver.Send({ action: 'agentdisconnect', nodeid: consoleNode._id });
|
meshserver.Send({ action: 'agentdisconnect', nodeid: consoleNode._id, disconnectMode: 1 });
|
||||||
|
} else if (Q('d3coreMode').value == 5) {
|
||||||
|
// Hard disconnect the mesh agent
|
||||||
|
meshserver.Send({ action: 'agentdisconnect', nodeid: consoleNode._id, disconnectMode: 2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1545,7 +1545,7 @@ module.exports.CreateWebServer = function (parent, db, args, secret, certificate
|
|||||||
case 'agentdisconnect':
|
case 'agentdisconnect':
|
||||||
{
|
{
|
||||||
// Force mesh agent disconnection
|
// Force mesh agent disconnection
|
||||||
forceMeshAgentDisconnect(user, domain, command.nodeid);
|
forceMeshAgentDisconnect(user, domain, command.nodeid, command.disconnectMode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'close':
|
case 'close':
|
||||||
@ -1913,7 +1913,7 @@ module.exports.CreateWebServer = function (parent, db, args, secret, certificate
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Force mesh agent disconnection
|
// Force mesh agent disconnection
|
||||||
function forceMeshAgentDisconnect(user, domain, nodeid) {
|
function forceMeshAgentDisconnect(user, domain, nodeid, disconnectMode) {
|
||||||
if ((nodeid == undefined) || (nodeid == null)) return;
|
if ((nodeid == undefined) || (nodeid == null)) return;
|
||||||
var splitnode = nodeid.split('/');
|
var splitnode = nodeid.split('/');
|
||||||
if ((splitnode.length != 3) || (splitnode[1] != domain.id)) return; // Check that nodeid is valid and part of our domain
|
if ((splitnode.length != 3) || (splitnode[1] != domain.id)) return; // Check that nodeid is valid and part of our domain
|
||||||
@ -1922,7 +1922,7 @@ module.exports.CreateWebServer = function (parent, db, args, secret, certificate
|
|||||||
|
|
||||||
// Check we have agent rights
|
// Check we have agent rights
|
||||||
var rights = user.links[agent.dbMeshKey].rights;
|
var rights = user.links[agent.dbMeshKey].rights;
|
||||||
if ((rights != undefined) && ((rights & 16) != 0) && (user.siteadmin == 0xFFFFFFFF)) { agent.close(); }
|
if ((rights != undefined) && ((rights & 16) != 0) && (user.siteadmin == 0xFFFFFFFF)) { agent.close(disconnectMode); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the core module to the mesh agent
|
// Send the core module to the mesh agent
|
||||||
|
Loading…
Reference in New Issue
Block a user