mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-24 22:25:52 -05:00
Improved MeshCtrl with proxy support.
This commit is contained in:
parent
e58838dfe8
commit
74f02b984b
23
meshctrl.js
23
meshctrl.js
@ -1,10 +1,14 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
const crypto = require('crypto');
|
// Make sure we have the dependency modules
|
||||||
|
try { require('minimist'); } catch (ex) { console.log('Missing module "minimist", type "npm install minimist" to install it.'); return; }
|
||||||
|
try { require('ws'); } catch (ex) { console.log('Missing module "ws", type "npm install ws" to install it.'); return; }
|
||||||
|
|
||||||
var settings = {};
|
var settings = {};
|
||||||
|
const crypto = require('crypto');
|
||||||
const args = require('minimist')(process.argv.slice(2));
|
const args = require('minimist')(process.argv.slice(2));
|
||||||
const possibleCommands = ['listusers', 'listdevicegroups', 'listdevices', 'listusersofdevicegroup', 'serverinfo', 'userinfo', 'adduser', 'removeuser', 'adddevicegroup', 'removedevicegroup', 'broadcast', 'showevents', 'addusertodevicegroup', 'removeuserfromdevicegroup', 'addusertodevice', 'removeuserfromdevice', '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.proxy != null) { try { require('https-proxy-agent'); } catch (ex) { console.log('Missing module "https-proxy-agent", type "npm install https-proxy-agent" to install it.'); return; } }
|
||||||
|
|
||||||
if (args['_'].length == 0) {
|
if (args['_'].length == 0) {
|
||||||
console.log("MeshCtrl performs command line actions on a MeshCentral server.");
|
console.log("MeshCtrl performs command line actions on a MeshCentral server.");
|
||||||
@ -39,6 +43,7 @@ if (args['_'].length == 0) {
|
|||||||
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.");
|
||||||
|
console.log(" --proxy [http://proxy:1] - Specify an HTTP proxy.");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
settings.cmd = args['_'][0].toLowerCase();
|
settings.cmd = args['_'][0].toLowerCase();
|
||||||
@ -493,6 +498,12 @@ function serverConnect() {
|
|||||||
// TODO: checkServerIdentity does not work???
|
// TODO: checkServerIdentity does not work???
|
||||||
var options = { rejectUnauthorized: false, checkServerIdentity: onVerifyServer }
|
var options = { rejectUnauthorized: false, checkServerIdentity: onVerifyServer }
|
||||||
|
|
||||||
|
// Setup the HTTP proxy if needed
|
||||||
|
if (args.proxy != null) {
|
||||||
|
const HttpsProxyAgent = require('https-proxy-agent');
|
||||||
|
options.agent = new HttpsProxyAgent(require('url').parse(args.proxy));
|
||||||
|
}
|
||||||
|
|
||||||
// Password authentication
|
// Password authentication
|
||||||
if (args.loginpass != null) {
|
if (args.loginpass != null) {
|
||||||
var username = 'admin';
|
var username = 'admin';
|
||||||
@ -661,7 +672,13 @@ function serverConnect() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ws.on('close', function close() { process.exit(); });
|
ws.on('close', function() { process.exit(); });
|
||||||
|
ws.on('error', function (err) {
|
||||||
|
if (err.code == 'ENOTFOUND') { console.log('Unable to resolve ' + url); }
|
||||||
|
else if (err.code == 'ECONNREFUSED') { console.log('Unable to connect to ' + url); }
|
||||||
|
else { console.log(err); }
|
||||||
|
process.exit();
|
||||||
|
});
|
||||||
|
|
||||||
ws.on('message', function incoming(rawdata) {
|
ws.on('message', function incoming(rawdata) {
|
||||||
//console.log(rawdata);
|
//console.log(rawdata);
|
||||||
|
@ -5874,6 +5874,8 @@
|
|||||||
QV('p11DeskConsoleMsg', true);
|
QV('p11DeskConsoleMsg', true);
|
||||||
if (p11DeskConsoleMsgTimer != null) { clearTimeout(p11DeskConsoleMsgTimer); }
|
if (p11DeskConsoleMsgTimer != null) { clearTimeout(p11DeskConsoleMsgTimer); }
|
||||||
p11DeskConsoleMsgTimer = setTimeout(p11clearConsoleMsg, 8000);
|
p11DeskConsoleMsgTimer = setTimeout(p11clearConsoleMsg, 8000);
|
||||||
|
} else {
|
||||||
|
p11clearConsoleMsg();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
desktop.m.CompressionLevel = desktopsettings.quality; // Number from 1 to 100. 50 or less is best.
|
desktop.m.CompressionLevel = desktopsettings.quality; // Number from 1 to 100. 50 or less is best.
|
||||||
|
Loading…
Reference in New Issue
Block a user