mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Added handler function for getsysinfo
This commit is contained in:
parent
34aab9c10a
commit
f0d2581b2d
1 changed files with 26 additions and 28 deletions
54
meshuser.js
54
meshuser.js
|
@ -788,34 +788,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'getsysinfo':
|
|
||||||
{
|
|
||||||
if (common.validateString(command.nodeid, 1, 1024) == false) break; // Check the nodeid
|
|
||||||
if (command.nodeid.indexOf('/') == -1) { command.nodeid = 'node/' + domain.id + '/' + command.nodeid; }
|
|
||||||
if ((command.nodeid.split('/').length != 3) || (command.nodeid.split('/')[1] != domain.id)) return; // Invalid domain, operation only valid for current domain
|
|
||||||
|
|
||||||
// Get the node and the rights for this node
|
|
||||||
parent.GetNodeWithRights(domain, user, command.nodeid, function (node, rights, visible) {
|
|
||||||
if (visible == false) { try { ws.send(JSON.stringify({ action: 'getsysinfo', nodeid: command.nodeid, tag: command.tag, noinfo: true, result: 'Invalid device id' })); } catch (ex) { } return; }
|
|
||||||
// Query the database system information
|
|
||||||
db.Get('si' + command.nodeid, function (err, docs) {
|
|
||||||
if ((docs != null) && (docs.length > 0)) {
|
|
||||||
var doc = docs[0];
|
|
||||||
doc.action = 'getsysinfo';
|
|
||||||
doc.nodeid = node._id;
|
|
||||||
doc.tag = command.tag;
|
|
||||||
delete doc.type;
|
|
||||||
delete doc.domain;
|
|
||||||
delete doc._id;
|
|
||||||
if (command.nodeinfo === true) { doc.node = node; doc.rights = rights; }
|
|
||||||
try { ws.send(JSON.stringify(doc)); } catch (ex) { }
|
|
||||||
} else {
|
|
||||||
try { ws.send(JSON.stringify({ action: 'getsysinfo', nodeid: node._id, tag: command.tag, noinfo: true, result: 'Invalid device id' })); } catch (ex) { }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'files':
|
case 'files':
|
||||||
{
|
{
|
||||||
// Send the full list of server files to the browser app
|
// Send the full list of server files to the browser app
|
||||||
|
@ -5475,6 +5447,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||||
|
|
||||||
const serverCommands = {
|
const serverCommands = {
|
||||||
'getnetworkinfo': serverCommandGetNetworkInfo,
|
'getnetworkinfo': serverCommandGetNetworkInfo,
|
||||||
|
'getsysinfo': serverCommandGetSysInfo,
|
||||||
'lastconnect': serverCommandLastConnect,
|
'lastconnect': serverCommandLastConnect,
|
||||||
'serverconsole': serverCommandServerConsole
|
'serverconsole': serverCommandServerConsole
|
||||||
};
|
};
|
||||||
|
@ -5556,6 +5529,31 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function serverCommandGetSysInfo(command) {
|
||||||
|
if (!validNodeIdAndDomain(command)) return;
|
||||||
|
|
||||||
|
// Get the node and the rights for this node
|
||||||
|
parent.GetNodeWithRights(domain, user, command.nodeid, function (node, rights, visible) {
|
||||||
|
if (visible == false) { try { ws.send(JSON.stringify({ action: 'getsysinfo', nodeid: command.nodeid, tag: command.tag, noinfo: true, result: 'Invalid device id' })); } catch (ex) { } return; }
|
||||||
|
// Query the database system information
|
||||||
|
db.Get('si' + command.nodeid, function (err, docs) {
|
||||||
|
if ((docs != null) && (docs.length > 0)) {
|
||||||
|
var doc = docs[0];
|
||||||
|
doc.action = 'getsysinfo';
|
||||||
|
doc.nodeid = node._id;
|
||||||
|
doc.tag = command.tag;
|
||||||
|
delete doc.type;
|
||||||
|
delete doc.domain;
|
||||||
|
delete doc._id;
|
||||||
|
if (command.nodeinfo === true) { doc.node = node; doc.rights = rights; }
|
||||||
|
try { ws.send(JSON.stringify(doc)); } catch (ex) { }
|
||||||
|
} else {
|
||||||
|
try { ws.send(JSON.stringify({ action: 'getsysinfo', nodeid: node._id, tag: command.tag, noinfo: true, result: 'Invalid device id' })); } catch (ex) { }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function serverCommandLastConnect(command) {
|
function serverCommandLastConnect(command) {
|
||||||
if (!validNodeIdAndDomain(command)) return;
|
if (!validNodeIdAndDomain(command)) return;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue