From aaa3b0f8577a9c9e043813a3f0e592c12eb1dcc1 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Mon, 5 Oct 2020 17:12:19 -0700 Subject: [PATCH] MeshCtrl can now create device groups with features/consent options. --- meshctrl.js | 11 +++++++++++ meshuser.js | 8 +++++++- views/default.handlebars | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/meshctrl.js b/meshctrl.js index 916d530e..f8aea7f9 100644 --- a/meshctrl.js +++ b/meshctrl.js @@ -458,11 +458,20 @@ if (args['_'].length == 0) { console.log("Add a device group, Example usages:\r\n"); console.log(" MeshCtrl AddDeviceGroup --name newgroupname"); console.log(" MeshCtrl AddDeviceGroup --name newgroupname --desc description --amtonly"); + console.log(" MeshCtrl AddDeviceGroup --name newgroupname --features 1 --consent 7"); console.log("\r\nRequired arguments:\r\n"); console.log(" --name [name] - Name of the new group."); console.log("\r\nOptional arguments:\r\n"); console.log(" --desc [description] - New group description."); console.log(" --amtonly - New group is agent-less, Intel AMT only."); + console.log(" --features [number] - Set device group features, sum of numbers below."); + console.log(" 1 = Auto-Remove 2 = Hostname Sync"); + console.log(" 4 = Record Sessions"); + console.log(" --consent [number] - Set device group user consent, sum of numbers below."); + console.log(" 1 = Desktop notify user 2 = Terminal notify user "); + console.log(" 4 = Files notify user 8 = Desktop prompt user "); + console.log(" 16 = Terminal prompt user 32 = Files prompt user "); + console.log(" 64 = Desktop Toolbar "); break; } case 'removedevicegroup': { @@ -1094,6 +1103,8 @@ function serverConnect() { var op = { action: 'createmesh', meshname: args.name, meshtype: 2, responseid: 'meshctrl' }; if (args.desc) { op.desc = args.desc; } if (args.amtonly) { op.meshtype = 1; } + if (args.features) { op.flags = parseInt(args.features); } + if (args.consent) { op.consent = parseInt(args.consent); } ws.send(JSON.stringify(op)); break; } diff --git a/meshuser.js b/meshuser.js index f7f2d313..bf1abdd2 100644 --- a/meshuser.js +++ b/meshuser.js @@ -2705,6 +2705,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use var links = {}; links[user._id] = { name: user.name, rights: 4294967295 }; mesh = { type: 'mesh', _id: meshid, name: command.meshname, mtype: command.meshtype, desc: command.desc, domain: domain.id, links: links, creation: Date.now(), creatorid: user._id, creatorname: user.name }; + + // Add flags and consent if present + if (typeof command.flags == 'number') { mesh.flags = command.flags; } + if (typeof command.consent == 'number') { mesh.consent = command.consent; } + + // Save the new device group db.Set(mesh); parent.meshes[meshid] = mesh; parent.parent.AddEventDispatch([meshid], ws); @@ -2723,7 +2729,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use parent.parent.DispatchEvent(targets, obj, event); // Event the device group creation - var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: meshid, name: command.meshname, mtype: command.meshtype, desc: command.desc, action: 'createmesh', links: links, msgid: 76, msgArgs: [command.meshname], msg: 'Device group created: ' + command.meshname, domain: domain.id, creation: mesh.creation, creatorid: mesh.creatorid, creatorname: mesh.creatorname }; + var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: meshid, name: command.meshname, mtype: command.meshtype, desc: command.desc, action: 'createmesh', links: links, msgid: 76, msgArgs: [command.meshname], msg: 'Device group created: ' + command.meshname, domain: domain.id, creation: mesh.creation, creatorid: mesh.creatorid, creatorname: mesh.creatorname, flags: mesh.flags, consent: mesh.consent }; parent.parent.DispatchEvent(['*', meshid, user._id], obj, event); // Even if DB change stream is active, this event must be acted upon. // Log in the auth log diff --git a/views/default.handlebars b/views/default.handlebars index f2fc54bc..1bd83f03 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -2631,7 +2631,7 @@ case 'createmesh': { // A new mesh was created if ((meshes[message.event.meshid] == null) && ((serverinfo.manageAllDeviceGroups) || (message.event.links[userinfo._id] != null))) { // Check if this is a mesh create for a mesh we own. If site administrator, we get all messages so need to ignore some. - meshes[message.event.meshid] = { _id: message.event.meshid, name: message.event.name, mtype: message.event.mtype, desc: message.event.desc, links: message.event.links, creation: message.event.creation, creatorid: message.event.creatorid, creatorname: message.event.creatorname }; + meshes[message.event.meshid] = { _id: message.event.meshid, name: message.event.name, mtype: message.event.mtype, desc: message.event.desc, links: message.event.links, creation: message.event.creation, creatorid: message.event.creatorid, creatorname: message.event.creatorname, flags: message.event.flags, consent: message.event.consent }; mainUpdate(4 + 128 + 8192 + 16384); meshserver.send({ action: 'files' }); }