Updated MeshCentral Router

This commit is contained in:
Ylian Saint-Hilaire 2020-07-06 17:16:54 -07:00
parent 2ba782b2e7
commit b602d374b0
3 changed files with 25 additions and 0 deletions

Binary file not shown.

View File

@ -966,6 +966,14 @@ function createMeshCore(agent) {
process.coreDumpLocation = null;
}
break;
case 'getcoredump':
var r = { action: 'getcoredump', value: (process.coreDumpLocation != null) };
if (process.platform == 'win32') {
r.exists = r.value ? fs.existsSync(process.coreDumpLocation) : false;
} else {
r.exists = (r.value && (process.cwd() != '//')) ? fs.existsSync(process.cwd() + 'core') : false;
}
mesh.SendCommand(JSON.stringify(r));
default:
// Unknown action, ignore it.
break;
@ -2284,6 +2292,13 @@ function createMeshCore(agent) {
break;
case 'status':
response = 'coredump is: ' + ((process.coreDumpLocation == null) ? 'off' : 'on');
if (process.coreDumpLocation != null) {
if (process.platform == 'win32') {
if (fs.existsSync(process.coreDumpLocation)) { response += '\r\n CoreDump present at: ' + process.coreDumpLocation; }
} else {
if ((process.cwd() != '//') && fs.existsSync(process.cwd() + 'core')) { response += '\r\n CoreDump present at: ' + process.cwd() + 'core'; }
}
}
break;
default:
response = "Proper usage: coredump on|off|status"; // Display usage

View File

@ -978,6 +978,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
// Set agent core dump
if ((parent.parent.config.settings != null) && ((parent.parent.config.settings.agentcoredump === true) || (parent.parent.config.settings.agentcoredump === false))) {
obj.send(JSON.stringify({ action: 'coredump', value: parent.parent.config.settings.agentcoredump }));
if (parent.parent.config.settings.agentcoredump === true) { obj.send(JSON.stringify({ action: 'getcoredump' })); }
}
// Do this if IP location is enabled on this domain TODO: Set IP location per device group?
@ -1368,6 +1369,15 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
obj.updateSessions();
break;
}
case 'getcoredump': {
// Indicates if the agent has a coredump available
if (command.exists === true) {
//console.log('CoreDump for agent ' + obj.remoteaddrport);
obj.coreDumpPresent = true;
// TODO: We need to look at getting the dump uploaded to the server.
}
break;
}
case 'plugin': {
if ((parent.parent.pluginHandler == null) || (typeof command.plugin != 'string')) break;
try {