Added ShowEvents command to MeshCtrl.
Ylian Saint-Hilaire committed
Mar 20, 2020 at 15:47 UTC
ba6790012db3e0e9fdf5e147ebabe91b37554162
2 files changed
+15
-2
meshctrl.js
+14
-1
@@ -3,7 +3,7 @@
3
const crypto = require('crypto');
4
var settings = {};
5
const args = require('minimist')(process.argv.slice(2));
6
-const possibleCommands = ['listusers', 'listdevicegroups', 'listdevices', 'listusersofdevicegroup', 'serverinfo', 'userinfo', 'adduser', 'removeuser', 'adddevicegroup', 'removedevicegroup', 'broadcast', 'addusertodevicegroup', 'removeuserfromdevicegroup', 'sendinviteemail', 'generateinvitelink', 'config'];
6
+const possibleCommands = ['listusers', 'listdevicegroups', 'listdevices', 'listusersofdevicegroup', 'serverinfo', 'userinfo', 'adduser', 'removeuser', 'adddevicegroup', 'removedevicegroup', 'broadcast', 'showevents', 'addusertodevicegroup', 'removeuserfromdevicegroup', 'sendinviteemail', 'generateinvitelink', 'config'];
7
//console.log(args);
8
9
if (args['_'].length == 0) {
@@ -28,6 +28,7 @@ if (args['_'].length == 0) {
28
console.log(" SendInviteEmail - Send an agent install invitation email.");
29
console.log(" GenerateInviteLink - Create an invitation link.");
30
console.log(" Broadcast - Display a message to all online users.");
31
+ console.log(" ShowEvents - Display real-time server events in JSON format.");
32
console.log("\r\nSupported login arguments:");
33
console.log(" --url [wss://server] - Server url, wss://localhost:443 is default.");
34
console.log(" --loginuser [username] - Login username, admin is default.");
@@ -82,6 +83,10 @@ if (args['_'].length == 0) {
83
else { ok = true; }
84
break;
85
}
86
+ case 'showevents': {
87
+ ok = true;
88
+ break;
89
+ }
90
case 'adduser': {
91
if (args.user == null) { console.log("New account name missing, use --user [name]"); }
92
else if ((args.pass == null) && (args.randompass == null)) { console.log("New account password missing, use --pass [password] or --randompass"); }
@@ -551,6 +556,10 @@ function serverConnect() {
556
ws.send(JSON.stringify(op));
557
break;
558
}
559
+ case 'showevents': {
560
+ console.log('Connected. Press ctrl-c to end.');
561
+ break;
562
+ }
563
}
564
});
565
@@ -561,6 +570,10 @@ function serverConnect() {
570
var data = null;
571
try { data = JSON.parse(rawdata); } catch (ex) { }
572
if (data == null) { console.log('Unable to parse data: ' + rawdata); }
573
+ if (settings.cmd == 'showevents') {
574
+ console.log(data);
575
+ return;
576
+ }
577
switch (data.action) {
578
case 'serverinfo': { // SERVERINFO
579
if (settings.cmd == 'serverinfo') {
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.5.0-m",
3
+ "version": "0.5.0-n",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",