Updated MeshCentral Router
Ylian Saint-Hilaire committed
Jul 6, 2020 at 17:16 UTC
b602d374b0375c46e1c854be5531b0e2bdfbf03d
3 files changed
+25
agents/MeshCentralRouter.exe
Binary files a/agents/MeshCentralRouter.exe and b/agents/MeshCentralRouter.exe differ
agents/meshcore.js
+15
@@ -966,6 +966,14 @@ function createMeshCore(agent) {
966
process.coreDumpLocation = null;
967
}
968
break;
969
+ case 'getcoredump':
970
+ var r = { action: 'getcoredump', value: (process.coreDumpLocation != null) };
971
+ if (process.platform == 'win32') {
972
+ r.exists = r.value ? fs.existsSync(process.coreDumpLocation) : false;
973
+ } else {
974
+ r.exists = (r.value && (process.cwd() != '//')) ? fs.existsSync(process.cwd() + 'core') : false;
975
+ }
976
+ mesh.SendCommand(JSON.stringify(r));
977
default:
978
// Unknown action, ignore it.
979
break;
@@ -2284,6 +2292,13 @@ function createMeshCore(agent) {
2292
break;
2293
case 'status':
2294
response = 'coredump is: ' + ((process.coreDumpLocation == null) ? 'off' : 'on');
2295
+ if (process.coreDumpLocation != null) {
2296
+ if (process.platform == 'win32') {
2297
+ if (fs.existsSync(process.coreDumpLocation)) { response += '\r\n CoreDump present at: ' + process.coreDumpLocation; }
2298
+ } else {
2299
+ if ((process.cwd() != '//') && fs.existsSync(process.cwd() + 'core')) { response += '\r\n CoreDump present at: ' + process.cwd() + 'core'; }
2300
+ }
2301
+ }
2302
break;
2303
default:
2304
response = "Proper usage: coredump on|off|status"; // Display usage
meshagent.js
+10
@@ -978,6 +978,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
978
// Set agent core dump
979
if ((parent.parent.config.settings != null) && ((parent.parent.config.settings.agentcoredump === true) || (parent.parent.config.settings.agentcoredump === false))) {
980
obj.send(JSON.stringify({ action: 'coredump', value: parent.parent.config.settings.agentcoredump }));
981
+ if (parent.parent.config.settings.agentcoredump === true) { obj.send(JSON.stringify({ action: 'getcoredump' })); }
982
}
983
984
// 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) {
1369
obj.updateSessions();
1370
break;
1371
}
1372
+ case 'getcoredump': {
1373
+ // Indicates if the agent has a coredump available
1374
+ if (command.exists === true) {
1375
+ //console.log('CoreDump for agent ' + obj.remoteaddrport);
1376
+ obj.coreDumpPresent = true;
1377
+ // TODO: We need to look at getting the dump uploaded to the server.
1378
+ }
1379
+ break;
1380
+ }
1381
case 'plugin': {
1382
if ((parent.parent.pluginHandler == null) || (typeof command.plugin != 'string')) break;
1383
try {