Improved agent meshcore self-update debugging.
This commit is contained in:
parent
67c28658fe
commit
77e3acad08
|
@ -113,7 +113,7 @@ function run(argv) {
|
|||
//console.log('addedModules = ' + JSON.stringify(addedModules));
|
||||
var actionpath = 'meshaction.txt';
|
||||
if (args.actionfile != null) { actionpath = args.actionfile; }
|
||||
var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTCONFIG', 'AMTSCAN', 'AMTPOWER', 'AMTFEATURES', 'AMTNETWORK', 'AMTLOADWEBAPP', 'AMTLOADSMALLWEBAPP', 'AMTLOADLARGEWEBAPP', 'AMTCLEARWEBAPP', 'AMTSTORAGESTATE', 'AMTINFO', 'AMTINFODEBUG', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTUUID', 'AMTCCM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTEVENTLOG', 'AMTPRESENCE', 'AMTWIFI', 'AMTWAKE'];
|
||||
var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTCONFIG', 'AMTSCAN', 'AMTPOWER', 'AMTFEATURES', 'AMTNETWORK', 'AMTLOADWEBAPP', 'AMTLOADSMALLWEBAPP', 'AMTLOADLARGEWEBAPP', 'AMTCLEARWEBAPP', 'AMTSTORAGESTATE', 'AMTINFO', 'AMTINFODEBUG', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTUUID', 'AMTCCM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTEVENTLOG', 'AMTPRESENCE', 'AMTWIFI', 'AMTWAKE', 'AMTSTOPCONFIGURATION'];
|
||||
|
||||
// Load the action file
|
||||
var actionfile = null;
|
||||
|
@ -428,7 +428,19 @@ function run(argv) {
|
|||
console.log('Proxy set to ' + proxy[0] + ':' + proxyport);
|
||||
}
|
||||
|
||||
if (settings.action == 'smbios') {
|
||||
if (settings.action == 'amtstopconfiguration') {
|
||||
// Stop Intel AMT configuration
|
||||
var amtMeiModule, amtMei;
|
||||
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.stopConfiguration(function (state) {
|
||||
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 == 0) { console.log("Success."); }
|
||||
else { console.log("Unknown state: " + state); }
|
||||
exit(1);
|
||||
});
|
||||
} else if (settings.action == 'smbios') {
|
||||
// Display SM BIOS tables in raw form
|
||||
SMBiosTables = require('smbios');
|
||||
SMBiosTables.get(function (data) {
|
||||
|
|
|
@ -2751,7 +2751,11 @@ function processConsoleCommand(cmd, args, rights, sessionid) {
|
|||
break;
|
||||
case 'agentupdateex':
|
||||
// Perform an direct agent update without requesting any information from the server, this should not typically be used.
|
||||
agentUpdate_Start(null, { sessionid: sessionid });
|
||||
if (args['_'].length == 1) {
|
||||
if (args['_'][0].startsWith('https://')) { agentUpdate_Start(args['_'][0], { sessionid: sessionid }); } else { response = "Usage: agentupdateex https://server/path"; }
|
||||
} else {
|
||||
agentUpdate_Start(null, { sessionid: sessionid });
|
||||
}
|
||||
break;
|
||||
case 'msh':
|
||||
response = JSON.stringify(_MSH(), null, 2);
|
||||
|
@ -4139,8 +4143,10 @@ function agentUpdate_Start(updateurl, updateoptions) {
|
|||
var sessionid = (updateoptions != null) ? updateoptions.sessionid : null; // If this is null, messages will be broadcast. Otherwise they will be unicasted
|
||||
|
||||
// If the url starts with *, switch it to use the same protoco, host and port as the control channel.
|
||||
updateurl = getServerTargetUrlEx(updateurl);
|
||||
if (updateurl.startsWith("wss://")) { updateurl = "https://" + updateurl.substring(6); }
|
||||
if (updateurl != null) {
|
||||
updateurl = getServerTargetUrlEx(updateurl);
|
||||
if (updateurl.startsWith("wss://")) { updateurl = "https://" + updateurl.substring(6); }
|
||||
}
|
||||
|
||||
if (agentUpdate_Start._selfupdate != null) {
|
||||
// We were already called, so we will ignore this duplicate request
|
||||
|
@ -4171,10 +4177,10 @@ function agentUpdate_Start(updateurl, updateoptions) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (sessionid != null) { sendConsoleText('Downloading update from: ' + updateurl, sessionid); }
|
||||
if ((sessionid != null) && (updateurl != null)) { sendConsoleText('Downloading update from: ' + updateurl, sessionid); }
|
||||
var options = require('http').parseUri(updateurl != null ? updateurl : require('MeshAgent').ServerUrl);
|
||||
options.protocol = 'https:';
|
||||
if (updateurl == null) { options.path = ('/meshagents?id=' + require('MeshAgent').ARCHID); }
|
||||
if (updateurl == null) { options.path = ('/meshagents?id=' + require('MeshAgent').ARCHID); sendConsoleText('Downloading update from: ' + options.path, sessionid); }
|
||||
options.rejectUnauthorized = false;
|
||||
options.checkServerIdentity = function checkServerIdentity(certs) {
|
||||
// If the tunnel certificate matches the control channel certificate, accept the connection
|
||||
|
|
|
@ -353,8 +353,10 @@ function agentUpdate_Start(updateurl, updateoptions) {
|
|||
var sessionid = (updateoptions != null) ? updateoptions.sessionid : null; // If this is null, messages will be broadcast. Otherwise they will be unicasted
|
||||
|
||||
// If the url starts with *, switch it to use the same protoco, host and port as the control channel.
|
||||
updateurl = getServerTargetUrlEx(updateurl);
|
||||
if (updateurl.startsWith("wss://")) { updateurl = "https://" + updateurl.substring(6); }
|
||||
if (updateurl != null) {
|
||||
updateurl = getServerTargetUrlEx(updateurl);
|
||||
if (updateurl.startsWith("wss://")) { updateurl = "https://" + updateurl.substring(6); }
|
||||
}
|
||||
|
||||
if (agentUpdate_Start._selfupdate != null) {
|
||||
// We were already called, so we will ignore this duplicate request
|
||||
|
@ -385,10 +387,10 @@ function agentUpdate_Start(updateurl, updateoptions) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (sessionid != null) { sendConsoleText('Downloading update from: ' + updateurl, sessionid); }
|
||||
if ((sessionid != null) && (updateurl != null)) { sendConsoleText('Downloading update from: ' + updateurl, sessionid); }
|
||||
var options = require('http').parseUri(updateurl != null ? updateurl : require('MeshAgent').ServerUrl);
|
||||
options.protocol = 'https:';
|
||||
if (updateurl == null) { options.path = ('/meshagents?id=' + require('MeshAgent').ARCHID); }
|
||||
if (updateurl == null) { options.path = ('/meshagents?id=' + require('MeshAgent').ARCHID); sendConsoleText('Downloading update from: ' + options.path, sessionid); }
|
||||
options.rejectUnauthorized = false;
|
||||
options.checkServerIdentity = function checkServerIdentity(certs) {
|
||||
// If the tunnel certificate matches the control channel certificate, accept the connection
|
||||
|
@ -1002,7 +1004,7 @@ function processConsoleCommand(cmd, args, rights, sessionid) {
|
|||
var response = null;
|
||||
switch (cmd) {
|
||||
case 'help':
|
||||
response = "Available commands are: agentupdate, dbkeys, dbget, dbset, dbcompact, eval, netinfo, osinfo, setdebug, versions.";
|
||||
response = "Available commands are: agentupdate, agentupdateex, dbkeys, dbget, dbset, dbcompact, eval, netinfo, osinfo, setdebug, versions.";
|
||||
break;
|
||||
case '_descriptors':
|
||||
response = 'Open Descriptors: ' + JSON.stringify(getOpenDescriptors());
|
||||
|
@ -1016,7 +1018,11 @@ function processConsoleCommand(cmd, args, rights, sessionid) {
|
|||
break;
|
||||
case 'agentupdateex':
|
||||
// Perform an direct agent update without requesting any information from the server, this should not typically be used.
|
||||
agentUpdate_Start(null, { sessionid: sessionid });
|
||||
if (args['_'].length == 1) {
|
||||
if (args['_'][0].startsWith('https://')) { agentUpdate_Start(args['_'][0], { sessionid: sessionid }); } else { response = "Usage: agentupdateex https://server/path"; }
|
||||
} else {
|
||||
agentUpdate_Start(null, { sessionid: sessionid });
|
||||
}
|
||||
break;
|
||||
case 'eval':
|
||||
{ // Eval JavaScript
|
||||
|
|
|
@ -1170,6 +1170,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||
obj.agentCoreUpdateTaskId = taskid;
|
||||
const url = '*' + require('url').parse(obj.agentExeInfo.url).path;
|
||||
var cmd = { action: 'agentupdate', url: url, hash: obj.agentExeInfo.hashhex };
|
||||
parent.parent.debug('agentupdate', "Sending agent update url: " + cmd.url);
|
||||
|
||||
// Add the hash
|
||||
if (obj.agentExeInfo.fileHash != null) { cmd.hash = obj.agentExeInfo.fileHashHex; } else { cmd.hash = obj.agentExeInfo.hashhex; }
|
||||
|
@ -1486,6 +1487,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||
obj.agentCoreUpdateTaskId = taskid;
|
||||
const url = '*' + require('url').parse(obj.agentExeInfo.url).path;
|
||||
var cmd = { action: 'agentupdate', url: url, hash: obj.agentExeInfo.hashhex, sessionid: agentUpdateFunc.sessionid };
|
||||
parent.parent.debug('agentupdate', "Sending user requested agent update url: " + cmd.url);
|
||||
|
||||
// Add the hash
|
||||
if (obj.agentExeInfo.fileHash != null) { cmd.hash = obj.agentExeInfo.fileHashHex; } else { cmd.hash = obj.agentExeInfo.hashhex; }
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue