mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Improved MeshCtrl.js
This commit is contained in:
parent
b5e6187e3a
commit
1eeb764657
5 changed files with 132 additions and 17 deletions
91
meshctrl.js
91
meshctrl.js
|
@ -3,7 +3,7 @@
|
|||
const crypto = require('crypto');
|
||||
var settings = {};
|
||||
const args = require('minimist')(process.argv.slice(2));
|
||||
const possibleCommands = ['listusers', 'listdevicegroups', 'listdevices', 'listusersofdevicegroup', 'serverinfo', 'userinfo', 'adduser', 'removeuser', 'adddevicegroup', 'removedevicegroup', 'broadcast', 'showevents', 'addusertodevicegroup', 'removeuserfromdevicegroup', 'sendinviteemail', 'generateinvitelink', 'config'];
|
||||
const possibleCommands = ['listusers', 'listdevicegroups', 'listdevices', 'listusersofdevicegroup', 'serverinfo', 'userinfo', 'adduser', 'removeuser', 'adddevicegroup', 'removedevicegroup', 'broadcast', 'showevents', 'addusertodevicegroup', 'removeuserfromdevicegroup', 'addusertodevice', 'removeuserfromdevice', 'sendinviteemail', 'generateinvitelink', 'config'];
|
||||
//console.log(args);
|
||||
|
||||
if (args['_'].length == 0) {
|
||||
|
@ -25,6 +25,8 @@ if (args['_'].length == 0) {
|
|||
console.log(" RemoveDeviceGroup - Delete a device group.");
|
||||
console.log(" AddUserToDeviceGroup - Add a user to a device group.");
|
||||
console.log(" RemoveUserFromDeviceGroup - Remove a user from a device group.");
|
||||
console.log(" AddUserToDevice - Add a user to a device.");
|
||||
console.log(" RemoveUserFromDevice - Remove a user from a device.");
|
||||
console.log(" SendInviteEmail - Send an agent install invitation email.");
|
||||
console.log(" GenerateInviteLink - Create an invitation link.");
|
||||
console.log(" Broadcast - Display a message to all online users.");
|
||||
|
@ -68,6 +70,18 @@ if (args['_'].length == 0) {
|
|||
else { ok = true; }
|
||||
break;
|
||||
}
|
||||
case 'addusertodevice': {
|
||||
if (args.userid == null) { console.log("Add user to device missing useid, use --userid [userid]"); }
|
||||
else if (args.id == null) { console.log("Add user to device missing device id, use --id [deviceid]"); }
|
||||
else { ok = true; }
|
||||
break;
|
||||
}
|
||||
case 'removeuserfromdevice': {
|
||||
if (args.userid == null) { console.log("Remove user from device missing useid, use --userid [userid]"); }
|
||||
else if (args.id == null) { console.log("Remove user from device missing device id, use --id [deviceid]"); }
|
||||
else { ok = true; }
|
||||
break;
|
||||
}
|
||||
case 'adddevicegroup': {
|
||||
if (args.name == null) { console.log("Message group name, use --name [name]"); }
|
||||
else { ok = true; }
|
||||
|
@ -262,6 +276,14 @@ if (args['_'].length == 0) {
|
|||
console.log(" --noterminal - Hide the terminal tab from this user.");
|
||||
console.log(" --nofiles - Hide the files tab from this user.");
|
||||
console.log(" --noamt - Hide the Intel AMT tab from this user.");
|
||||
console.log(" --limitedevents - User can only see his own events.");
|
||||
console.log(" --chatnotify - Allow chat and notification options.");
|
||||
console.log(" --uninstall - Allow remote uninstall of the agent.");
|
||||
if (args.limiteddesktop) { meshrights |= 4096; }
|
||||
if (args.limitedevents) { meshrights |= 8192; }
|
||||
if (args.chatnotify) { meshrights |= 16384; }
|
||||
if (args.uninstall) { meshrights |= 32768; }
|
||||
|
||||
break;
|
||||
}
|
||||
case 'removeuserfromdevicegroup': {
|
||||
|
@ -272,11 +294,43 @@ if (args['_'].length == 0) {
|
|||
console.log(" --userid [userid] - The user identifier.");
|
||||
break;
|
||||
}
|
||||
case 'addusertodevice': {
|
||||
console.log("Add a user to a device, Example usages:\r\n");
|
||||
console.log(" MeshCtrl AddUserToDevice --id deviceid --userid userid --fullrights");
|
||||
console.log(" MeshCtrl AddUserToDevice --id deviceid --userid userid --remotecontrol");
|
||||
console.log("\r\nRequired arguments:\r\n");
|
||||
console.log(" --id [deviceid] - The device identifier.");
|
||||
console.log(" --userid [userid] - The user identifier.");
|
||||
console.log("\r\nOptional arguments:\r\n");
|
||||
console.log(" --fullrights - Allow full rights over this device.");
|
||||
console.log(" --remotecontrol - Allow device remote control operations.");
|
||||
console.log(" --agentconsole - Allow agent console operations.");
|
||||
console.log(" --serverfiles - Allow access to group server files.");
|
||||
console.log(" --wakedevices - Allow device wake operation.");
|
||||
console.log(" --notes - Allow editing of device notes.");
|
||||
console.log(" --desktopviewonly - Restrict user to view-only remote desktop.");
|
||||
console.log(" --limiteddesktop - Limit remote desktop keys.");
|
||||
console.log(" --noterminal - Hide the terminal tab from this user.");
|
||||
console.log(" --nofiles - Hide the files tab from this user.");
|
||||
console.log(" --noamt - Hide the Intel AMT tab from this user.");
|
||||
console.log(" --limitedevents - User can only see his own events.");
|
||||
console.log(" --chatnotify - Allow chat and notification options.");
|
||||
console.log(" --uninstall - Allow remote uninstall of the agent.");
|
||||
break;
|
||||
}
|
||||
case 'removeuserfromdevice': {
|
||||
console.log("Remove a user from a device, Example usages:\r\n");
|
||||
console.log(" MeshCtrl RemoveuserFromDeviceGroup --id deviceid --userid userid");
|
||||
console.log("\r\nRequired arguments:\r\n");
|
||||
console.log(" --id [deviceid] - The device identifier.");
|
||||
console.log(" --userid [userid] - The user identifier.");
|
||||
break;
|
||||
}
|
||||
case 'broadcast': {
|
||||
console.log("Display a message to all logged in users, Example usages:\r\n");
|
||||
console.log(" MeshCtrl Broadcast --msg \"This is a test\"");
|
||||
console.log("\r\nRequired arguments:\r\n");
|
||||
console.log(" --msg [message] - Message to display.");
|
||||
console.log(" --msg [message] - Message to display.");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
@ -532,6 +586,9 @@ function serverConnect() {
|
|||
if (args.nofiles) { meshrights |= 1024; }
|
||||
if (args.noamt) { meshrights |= 2048; }
|
||||
if (args.limiteddesktop) { meshrights |= 4096; }
|
||||
if (args.limitedevents) { meshrights |= 8192; }
|
||||
if (args.chatnotify) { meshrights |= 16384; }
|
||||
if (args.uninstall) { meshrights |= 32768; }
|
||||
var op = { action: 'addmeshuser', meshid: args.id, usernames: [args.userid], meshadmin: meshrights, responseid: 'meshctrl' };
|
||||
ws.send(JSON.stringify(op));
|
||||
break;
|
||||
|
@ -541,13 +598,38 @@ function serverConnect() {
|
|||
ws.send(JSON.stringify(op));
|
||||
break;
|
||||
}
|
||||
case 'addusertodevice': {
|
||||
var meshrights = 0;
|
||||
if (args.fullrights) { meshrights = (8 + 16 + 32 + 64 + 128 + 16384 + 32768); }
|
||||
if (args.remotecontrol) { meshrights |= 8; }
|
||||
if (args.agentconsole) { meshrights |= 16; }
|
||||
if (args.serverfiles) { meshrights |= 32; }
|
||||
if (args.wakedevices) { meshrights |= 64; }
|
||||
if (args.notes) { meshrights |= 128; }
|
||||
if (args.desktopviewonly) { meshrights |= 256; }
|
||||
if (args.noterminal) { meshrights |= 512; }
|
||||
if (args.nofiles) { meshrights |= 1024; }
|
||||
if (args.noamt) { meshrights |= 2048; }
|
||||
if (args.limiteddesktop) { meshrights |= 4096; }
|
||||
if (args.limitedevents) { meshrights |= 8192; }
|
||||
if (args.chatnotify) { meshrights |= 16384; }
|
||||
if (args.uninstall) { meshrights |= 32768; }
|
||||
var op = { action: 'adddeviceuser', nodeid: args.id, usernames: [args.userid], rights: meshrights, responseid: 'meshctrl' };
|
||||
ws.send(JSON.stringify(op));
|
||||
break;
|
||||
}
|
||||
case 'removeuserfromdevice': {
|
||||
var op = { action: 'adddeviceuser', nodeid: args.id, usernames: [args.userid], rights: 0, responseid: 'meshctrl' };
|
||||
ws.send(JSON.stringify(op));
|
||||
break;
|
||||
}
|
||||
case 'sendinviteemail': {
|
||||
var op = { action: "inviteAgent", meshid: args.id, email: args.email, name: "", os: "0", responseid: 'meshctrl' }
|
||||
var op = { action: 'inviteAgent', meshid: args.id, email: args.email, name: '', os: '0', responseid: 'meshctrl' }
|
||||
ws.send(JSON.stringify(op));
|
||||
break;
|
||||
}
|
||||
case 'generateinvitelink': {
|
||||
var op = { action: "createInviteLink", meshid: args.id, expire: args.hours, flags: 0, responseid: 'meshctrl' }
|
||||
var op = { action: 'createInviteLink', meshid: args.id, expire: args.hours, flags: 0, responseid: 'meshctrl' }
|
||||
ws.send(JSON.stringify(op));
|
||||
break;
|
||||
}
|
||||
|
@ -604,6 +686,7 @@ function serverConnect() {
|
|||
case 'addmeshuser': //
|
||||
case 'removemeshuser': //
|
||||
case 'inviteAgent': //
|
||||
case 'adddeviceuser': //
|
||||
case 'userbroadcast': { // BROADCAST
|
||||
if (data.responseid == 'meshctrl') {
|
||||
if (data.meshid) { console.log(data.result, data.meshid); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue