mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-04-15 08:36:05 -04:00
Minor MeshCMD improvements.
This commit is contained in:
parent
03ea7bc999
commit
5eb7c18e24
@ -437,7 +437,7 @@ function run(argv) {
|
|||||||
// Start Intel AMT configuration
|
// Start Intel AMT configuration
|
||||||
var amtMeiModule, amtMei;
|
var amtMeiModule, amtMei;
|
||||||
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
||||||
amtMei.on('error', function (e) { console.log('ERROR: ' + e); exit(1); return; });
|
amtMei.on('error', function (e) { console.log('amtstartconfig error: ' + e); exit(1); return; });
|
||||||
amtMei.startConfiguration(function (state) {
|
amtMei.startConfiguration(function (state) {
|
||||||
if (state == 3) { console.log("Intel AMT is not in correct mode."); }
|
if (state == 3) { console.log("Intel AMT is not in correct mode."); }
|
||||||
else if (state == 1) { console.log("Intel AMT internal error."); }
|
else if (state == 1) { console.log("Intel AMT internal error."); }
|
||||||
@ -451,7 +451,7 @@ function run(argv) {
|
|||||||
// Stop Intel AMT configuration
|
// Stop Intel AMT configuration
|
||||||
var amtMeiModule, amtMei;
|
var amtMeiModule, amtMei;
|
||||||
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
||||||
amtMei.on('error', function (e) { console.log('ERROR: ' + e); exit(1); return; });
|
amtMei.on('error', function (e) { console.log('amtstopconfig error: ' + e); exit(1); return; });
|
||||||
amtMei.stopConfiguration(function (state) {
|
amtMei.stopConfiguration(function (state) {
|
||||||
if (state == 3) { console.log("Intel AMT is not in in-provisionning mode."); }
|
if (state == 3) { console.log("Intel AMT is not in in-provisionning mode."); }
|
||||||
else if (state == 1) { console.log("Intel AMT internal error."); }
|
else if (state == 1) { console.log("Intel AMT internal error."); }
|
||||||
@ -494,7 +494,7 @@ function run(argv) {
|
|||||||
// Display Intel ME versions
|
// Display Intel ME versions
|
||||||
var amtMeiModule, amtMei;
|
var amtMeiModule, amtMei;
|
||||||
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
||||||
amtMei.on('error', function (e) { console.log('ERROR: ' + e); exit(1); return; });
|
amtMei.on('error', function (e) { console.log('amtversion error: ' + e); exit(1); return; });
|
||||||
amtMei.getVersion(function (val) {
|
amtMei.getVersion(function (val) {
|
||||||
if (args.json) {
|
if (args.json) {
|
||||||
console.log(JSON.stringify(val, null, 2));
|
console.log(JSON.stringify(val, null, 2));
|
||||||
@ -517,7 +517,7 @@ function run(argv) {
|
|||||||
// Display Intel AMT list of trusted hashes
|
// Display Intel AMT list of trusted hashes
|
||||||
var amtMeiModule, amtMei, amtHashes = [];
|
var amtMeiModule, amtMei, amtHashes = [];
|
||||||
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
||||||
amtMei.on('error', function (e) { console.log('ERROR: ' + e); exit(1); return; });
|
amtMei.on('error', function (e) { console.log('amthashes error: ' + e); exit(1); return; });
|
||||||
amtMei.getHashHandles(function (handles) {
|
amtMei.getHashHandles(function (handles) {
|
||||||
exitOnCount = handles.length;
|
exitOnCount = handles.length;
|
||||||
for (var i = 0; i < handles.length; ++i) {
|
for (var i = 0; i < handles.length; ++i) {
|
||||||
@ -541,7 +541,7 @@ function run(argv) {
|
|||||||
mestate = {};
|
mestate = {};
|
||||||
var amtMeiModule, amtMei;
|
var amtMeiModule, amtMei;
|
||||||
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
||||||
amtMei.on('error', function (e) { console.log('ERROR: ' + e); exit(1); return; });
|
amtMei.on('error', function (e) { console.log('amtinfo error: ' + e); exit(1); return; });
|
||||||
try {
|
try {
|
||||||
amtMei.getVersion(function (result) {
|
amtMei.getVersion(function (result) {
|
||||||
if (result) {
|
if (result) {
|
||||||
@ -633,7 +633,7 @@ function run(argv) {
|
|||||||
options.checkServerIdentity = function (cert) { }
|
options.checkServerIdentity = function (cert) { }
|
||||||
//console.log("options: " + JSON.stringify(options, null, 2));
|
//console.log("options: " + JSON.stringify(options, null, 2));
|
||||||
var req = http.request(options);
|
var req = http.request(options);
|
||||||
req.on('error', function (e) { console.log("Error: " + e); exit(1); });
|
req.on('error', function (e) { console.log("amtinfojson error: " + e); exit(1); });
|
||||||
req.on('response', function (response) { console.log("Status code: " + response.statusCode); exit(1); });
|
req.on('response', function (response) { console.log("Status code: " + response.statusCode); exit(1); });
|
||||||
req.end(JSON.stringify(state));
|
req.end(JSON.stringify(state));
|
||||||
} else {
|
} else {
|
||||||
@ -1290,7 +1290,7 @@ function configureJsonControl(data) {
|
|||||||
function deactivateCCM() {
|
function deactivateCCM() {
|
||||||
var amtMeiModule, amtMei;
|
var amtMeiModule, amtMei;
|
||||||
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
||||||
amtMei.on('error', function (e) { console.log('ERROR: ' + e); exit(1); return; });
|
amtMei.on('error', function (e) { console.log('deactivateCCM() error: ' + e); exit(1); return; });
|
||||||
amtMei.unprovision(1, function (status) { if (status == 0) { console.log('Success'); } else { console.log('Error ' + status); } exit(1); });
|
amtMei.unprovision(1, function (status) { if (status == 0) { console.log('Success'); } else { console.log('Error ' + status); } exit(1); });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1488,7 +1488,7 @@ function getAmtInfo(func, tag) {
|
|||||||
getAmtInfoFetchingTimer = null;
|
getAmtInfoFetchingTimer = null;
|
||||||
var amtMeiModule, amtMei;
|
var amtMeiModule, amtMei;
|
||||||
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
||||||
amtMei.on('error', function (e) { console.log('ERROR: ' + e); exit(1); return; });
|
amtMei.on('error', function (e) { console.log('getAmtInfo() error: ' + e); exit(1); return; });
|
||||||
}, 3000);
|
}, 3000);
|
||||||
amtMei.getProtocolVersion(function (result) { if (result != null) { amtMeiTmpState.MeiVersion = result; } });
|
amtMei.getProtocolVersion(function (result) { if (result != null) { amtMeiTmpState.MeiVersion = result; } });
|
||||||
amtMei.getVersion(function (val) {
|
amtMei.getVersion(function (val) {
|
||||||
@ -1549,7 +1549,7 @@ function startLms(func, lmscommander, tag) {
|
|||||||
|
|
||||||
console.log('Setting up MEI...');
|
console.log('Setting up MEI...');
|
||||||
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
|
||||||
amtMei.on('error', function (e) { console.log('ERROR: ' + e); exit(1); return; });
|
amtMei.on('error', function (e) { console.log('startLms() error: ' + e); exit(1); return; });
|
||||||
//console.log("PTHI Connected.");
|
//console.log("PTHI Connected.");
|
||||||
|
|
||||||
try { amtLms = new lme_heci({ debug: settings.lmsdebug }); } catch (ex) { if (func != null) { func(0, tag); } return; }
|
try { amtLms = new lme_heci({ debug: settings.lmsdebug }); } catch (ex) { if (func != null) { func(0, tag); } return; }
|
||||||
@ -2038,7 +2038,7 @@ function startRouter() {
|
|||||||
options.rejectUnauthorized = false;
|
options.rejectUnauthorized = false;
|
||||||
settings.websocket = http.request(options);
|
settings.websocket = http.request(options);
|
||||||
settings.websocket.upgrade = OnServerWebSocket;
|
settings.websocket.upgrade = OnServerWebSocket;
|
||||||
settings.websocket.on('error', function (e) { console.log("ERROR: " + JSON.stringify(e)); });
|
settings.websocket.on('error', function (ex) { console.log("Unable to connect to server: " + JSON.stringify(ex)); process.exit(1); return; });
|
||||||
settings.websocket.end();
|
settings.websocket.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2143,7 +2143,7 @@ function OnServerWebSocket(msg, s, head) {
|
|||||||
|
|
||||||
function startRouterEx() {
|
function startRouterEx() {
|
||||||
tcpserver = net.createServer(OnTcpClientConnected);
|
tcpserver = net.createServer(OnTcpClientConnected);
|
||||||
tcpserver.on('error', function (e) { console.log("ERROR: " + JSON.stringify(e)); exit(0); return; });
|
tcpserver.on('error', function (e) { console.log("startRouterEx() Error: " + JSON.stringify(e)); exit(0); return; });
|
||||||
try {
|
try {
|
||||||
tcpserver.listen(settings.localport, function () {
|
tcpserver.listen(settings.localport, function () {
|
||||||
// We started listening.
|
// We started listening.
|
||||||
@ -2177,7 +2177,7 @@ function OnTcpClientConnected(c) {
|
|||||||
c.websocket.tcp = c;
|
c.websocket.tcp = c;
|
||||||
c.websocket.tunneling = false;
|
c.websocket.tunneling = false;
|
||||||
c.websocket.upgrade = OnWebSocket;
|
c.websocket.upgrade = OnWebSocket;
|
||||||
c.websocket.on('error', function (e) { console.log("ERROR: " + JSON.stringify(e)); });
|
c.websocket.on('error', function (e) { console.log("OnTcpClientConnected() Error: " + JSON.stringify(e)); });
|
||||||
c.websocket.end();
|
c.websocket.end();
|
||||||
} catch (e) { debug(2, e); }
|
} catch (e) { debug(2, e); }
|
||||||
}
|
}
|
||||||
@ -2218,17 +2218,19 @@ function discoverMeshServerOnce() {
|
|||||||
for (var adapter in interfaces) {
|
for (var adapter in interfaces) {
|
||||||
if (interfaces.hasOwnProperty(adapter)) {
|
if (interfaces.hasOwnProperty(adapter)) {
|
||||||
for (var i = 0; i < interfaces[adapter].length; ++i) {
|
for (var i = 0; i < interfaces[adapter].length; ++i) {
|
||||||
var addr = interfaces[adapter][i];
|
try {
|
||||||
multicastSockets[i] = dgram.createSocket({ type: (addr.family == 'IPv4' ? 'udp4' : 'udp6') });
|
var addr = interfaces[adapter][i];
|
||||||
multicastSockets[i].bind({ address: addr.address, exclusive: false });
|
if (multicastSockets[i] == null) {
|
||||||
if (addr.family == 'IPv4') {
|
multicastSockets[i] = dgram.createSocket({ type: (addr.family == 'IPv4' ? 'udp4' : 'udp6') });
|
||||||
try {
|
multicastSockets[i].bind({ address: addr.address, exclusive: false });
|
||||||
|
}
|
||||||
|
if (addr.family == 'IPv4') {
|
||||||
multicastSockets[i].addMembership(membershipIPv4);
|
multicastSockets[i].addMembership(membershipIPv4);
|
||||||
//multicastSockets[i].setMulticastLoopback(true);
|
//multicastSockets[i].setMulticastLoopback(true);
|
||||||
multicastSockets[i].once('message', OnMulticastMessage);
|
multicastSockets[i].once('message', OnMulticastMessage);
|
||||||
multicastSockets[i].send(settings.serverid, 16989, membershipIPv4);
|
multicastSockets[i].send(settings.serverid, 16989, membershipIPv4);
|
||||||
} catch (e) { }
|
}
|
||||||
}
|
} catch (ex) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3051,7 +3053,7 @@ if (serviceName == null) {
|
|||||||
else if (process.execPath.includes('LMS')) { serviceName = 'LMS'; }
|
else if (process.execPath.includes('LMS')) { serviceName = 'LMS'; }
|
||||||
else if (process.execPath.includes('MeshCommander')) { serviceName = 'MeshCommander'; }
|
else if (process.execPath.includes('MeshCommander')) { serviceName = 'MeshCommander'; }
|
||||||
if (serviceName == null) { for (var i in process.argv) { if ((process.argv[i].toLowerCase() == '-install') || (process.argv[i].toLowerCase() == '-uninstall')) { console.log('In order to install/uninstall, a service type must be specified.'); process.exit(); } } }
|
if (serviceName == null) { for (var i in process.argv) { if ((process.argv[i].toLowerCase() == '-install') || (process.argv[i].toLowerCase() == '-uninstall')) { console.log('In order to install/uninstall, a service type must be specified.'); process.exit(); } } }
|
||||||
if (serviceName == null) { try { run(process.argv); } catch (e) { console.log("ERROR: " + e); } }
|
if (serviceName == null) { try { run(process.argv); } catch (e) { console.log("Run() error: " + e); } }
|
||||||
} else {
|
} else {
|
||||||
var serviceHost = require('service-host');
|
var serviceHost = require('service-host');
|
||||||
var meshcmdService = new serviceHost({ name: serviceName, displayName: serviceDisplayName, startType: 'AUTO_START', description: serviceDesc });
|
var meshcmdService = new serviceHost({ name: serviceName, displayName: serviceDisplayName, startType: 'AUTO_START', description: serviceDesc });
|
||||||
@ -3074,6 +3076,6 @@ if (serviceName == null) {
|
|||||||
meshcmdService.on('serviceStop', function onStop() { console.log("Stopping service"); process.exit(); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set.
|
meshcmdService.on('serviceStop', function onStop() { console.log("Stopping service"); process.exit(); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set.
|
||||||
|
|
||||||
// Called when the executable is not running as a service, run normally.
|
// Called when the executable is not running as a service, run normally.
|
||||||
meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log("ERROR: " + e); } });
|
meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log("onNormalStart() error: " + e); } });
|
||||||
meshcmdService.run();
|
meshcmdService.run();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user