MeshCtrl can now create device groups with features/consent options.

Ylian Saint-Hilaire committed Oct 5, 2020 at 17:12 UTC 4a0c46e12c8ea50cd0b7d01b3f545d4e6edea189
3 files changed +19 -2
meshctrl.js
+11
@@ -458,11 +458,20 @@ if (args['_'].length == 0) {
458 console.log("Add a device group, Example usages:\r\n");
459 console.log(" MeshCtrl AddDeviceGroup --name newgroupname");
460 console.log(" MeshCtrl AddDeviceGroup --name newgroupname --desc description --amtonly");
461 + console.log(" MeshCtrl AddDeviceGroup --name newgroupname --features 1 --consent 7");
462 console.log("\r\nRequired arguments:\r\n");
463 console.log(" --name [name] - Name of the new group.");
464 console.log("\r\nOptional arguments:\r\n");
465 console.log(" --desc [description] - New group description.");
466 console.log(" --amtonly - New group is agent-less, Intel AMT only.");
467 + console.log(" --features [number] - Set device group features, sum of numbers below.");
468 + console.log(" 1 = Auto-Remove 2 = Hostname Sync");
469 + console.log(" 4 = Record Sessions");
470 + console.log(" --consent [number] - Set device group user consent, sum of numbers below.");
471 + console.log(" 1 = Desktop notify user 2 = Terminal notify user ");
472 + console.log(" 4 = Files notify user 8 = Desktop prompt user ");
473 + console.log(" 16 = Terminal prompt user 32 = Files prompt user ");
474 + console.log(" 64 = Desktop Toolbar ");
475 break;
476 }
477 case 'removedevicegroup': {
@@ -1094,6 +1103,8 @@ function serverConnect() {
1103 var op = { action: 'createmesh', meshname: args.name, meshtype: 2, responseid: 'meshctrl' };
1104 if (args.desc) { op.desc = args.desc; }
1105 if (args.amtonly) { op.meshtype = 1; }
1106 + if (args.features) { op.flags = parseInt(args.features); }
1107 + if (args.consent) { op.consent = parseInt(args.consent); }
1108 ws.send(JSON.stringify(op));
1109 break;
1110 }
meshuser.js
+7 -1
@@ -2705,6 +2705,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2705 var links = {};
2706 links[user._id] = { name: user.name, rights: 4294967295 };
2707 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 };
2708 +
2709 + // Add flags and consent if present
2710 + if (typeof command.flags == 'number') { mesh.flags = command.flags; }
2711 + if (typeof command.consent == 'number') { mesh.consent = command.consent; }
2712 +
2713 + // Save the new device group
2714 db.Set(mesh);
2715 parent.meshes[meshid] = mesh;
2716 parent.parent.AddEventDispatch([meshid], ws);
@@ -2723,7 +2729,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2729 parent.parent.DispatchEvent(targets, obj, event);
2730
2731 // Event the device group creation
2726 - 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 };
2732 + 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 };
2733 parent.parent.DispatchEvent(['*', meshid, user._id], obj, event); // Even if DB change stream is active, this event must be acted upon.
2734
2735 // Log in the auth log
views/default.handlebars
+1 -1
@@ -2631,7 +2631,7 @@
2631 case 'createmesh': {
2632 // A new mesh was created
2633 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.
2634 - 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 };
2634 + 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 };
2635 mainUpdate(4 + 128 + 8192 + 16384);
2636 meshserver.send({ action: 'files' });
2637 }