mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-01-11 15:03:20 -05:00
Minor fixes to MeshCtrl.
This commit is contained in:
parent
e562a583d8
commit
8f260ee9f4
10
meshctrl.js
10
meshctrl.js
@ -43,7 +43,7 @@ if (args['_'].length == 0) {
|
|||||||
console.log(" --token [number] - 2nd factor authentication token.");
|
console.log(" --token [number] - 2nd factor authentication token.");
|
||||||
console.log(" --loginkey [hex] - Server login key in hex.");
|
console.log(" --loginkey [hex] - Server login key in hex.");
|
||||||
console.log(" --loginkeyfile [file] - File containing server login key in hex.");
|
console.log(" --loginkeyfile [file] - File containing server login key in hex.");
|
||||||
console.log(" --domain [domainid] - Domain id, default is empty.");
|
console.log(" --domain [domainid] - Domain id, default is empty, only used with loginkey.");
|
||||||
console.log(" --proxy [http://proxy:1] - Specify an HTTP proxy.");
|
console.log(" --proxy [http://proxy:1] - Specify an HTTP proxy.");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -552,10 +552,12 @@ function serverConnect() {
|
|||||||
if (args.domain != null) { domainid = args.domain; }
|
if (args.domain != null) { domainid = args.domain; }
|
||||||
if (args.loginuser != null) { username = args.loginuser; }
|
if (args.loginuser != null) { username = args.loginuser; }
|
||||||
url += '?auth=' + encodeCookie({ userid: 'user/' + domainid + '/' + username, domainid: domainid }, ckey);
|
url += '?auth=' + encodeCookie({ userid: 'user/' + domainid + '/' + username, domainid: domainid }, ckey);
|
||||||
|
} else {
|
||||||
|
if (args.domain != null) { console.log("--domain can only be used along with --loginkey."); process.exit(); return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
const ws = new WebSocket(url, options);
|
const ws = new WebSocket(url, options);
|
||||||
//console.log('Connecting...');
|
//console.log('Connecting to ' + url);
|
||||||
|
|
||||||
ws.on('open', function open() {
|
ws.on('open', function open() {
|
||||||
//console.log('Connected.');
|
//console.log('Connected.');
|
||||||
@ -706,7 +708,6 @@ function serverConnect() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ws.on('message', function incoming(rawdata) {
|
ws.on('message', function incoming(rawdata) {
|
||||||
//console.log(rawdata);
|
|
||||||
var data = null;
|
var data = null;
|
||||||
try { data = JSON.parse(rawdata); } catch (ex) { }
|
try { data = JSON.parse(rawdata); } catch (ex) { }
|
||||||
if (data == null) { console.log('Unable to parse data: ' + rawdata); }
|
if (data == null) { console.log('Unable to parse data: ' + rawdata); }
|
||||||
@ -809,15 +810,18 @@ function serverConnect() {
|
|||||||
console.log(JSON.stringify(nodes, ' ', 2));
|
console.log(JSON.stringify(nodes, ' ', 2));
|
||||||
} else {
|
} else {
|
||||||
// Display the list of nodes in text format
|
// Display the list of nodes in text format
|
||||||
|
var nodecount = 0;
|
||||||
for (var i in data.nodes) {
|
for (var i in data.nodes) {
|
||||||
var devicesInMesh = data.nodes[i];
|
var devicesInMesh = data.nodes[i];
|
||||||
if (settings.xmeshes) { console.log('\r\nDevice group: \"' + settings.xmeshes[i].name + '\"'); }
|
if (settings.xmeshes) { console.log('\r\nDevice group: \"' + settings.xmeshes[i].name + '\"'); }
|
||||||
console.log('id, name, icon, conn, pwr, ip\r\n-----------------------------');
|
console.log('id, name, icon, conn, pwr, ip\r\n-----------------------------');
|
||||||
for (var j in devicesInMesh) {
|
for (var j in devicesInMesh) {
|
||||||
var n = devicesInMesh[j];
|
var n = devicesInMesh[j];
|
||||||
|
nodecount++;
|
||||||
console.log(n._id.split('/')[2] + ', \"' + n.name + '\", ' + (n.icon ? n.icon : 0) + ', ' + (n.conn ? n.conn : 0) + ', ' + (n.pwr ? n.pwr : 0));
|
console.log(n._id.split('/')[2] + ', \"' + n.name + '\", ' + (n.icon ? n.icon : 0) + ', ' + (n.conn ? n.conn : 0) + ', ' + (n.pwr ? n.pwr : 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (nodecount == 0) { console.log('None'); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
process.exit();
|
process.exit();
|
||||||
|
Loading…
Reference in New Issue
Block a user