mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
More plugin hooks / development of base
This commit is contained in:
parent
36931698ad
commit
d143990f31
6 changed files with 200 additions and 17 deletions
33
agents/meshcore.min.js
vendored
33
agents/meshcore.min.js
vendored
|
@ -757,17 +757,6 @@ function createMeshCore(agent)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'plugin': {
|
||||
if (typeof data.pluginaction == 'string') {
|
||||
try {
|
||||
MeshServerLog('Plugin called', data);
|
||||
require(data.plugin.name).serveraction(data);
|
||||
} catch(e) {
|
||||
MeshServerLog('Error calling plugin', data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// Unknown action, ignore it.
|
||||
break;
|
||||
|
@ -841,6 +830,19 @@ function createMeshCore(agent)
|
|||
}
|
||||
case 'ping': { mesh.SendCommand('{"action":"pong"}'); break; }
|
||||
case 'pong': { break; }
|
||||
case 'plugin': {
|
||||
if (typeof data.pluginaction == 'string') {
|
||||
try {
|
||||
|
||||
MeshServerLog('Plugin called', data);
|
||||
/* Not yet implmented
|
||||
require(data.plugin.name).serveraction(data);*/
|
||||
} catch(e) {
|
||||
MeshServerLog('Error calling plugin', data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// Unknown action, ignore it.
|
||||
break;
|
||||
|
@ -2353,9 +2355,12 @@ function createMeshCore(agent)
|
|||
case 'plugin': {
|
||||
if (typeof args['_'][0] == 'string') {
|
||||
try {
|
||||
response = require(args['_'][0]).consoleaction(args, rights, sessionid);
|
||||
// pass off the action to the plugin
|
||||
// for plugin creators, you'll want to have a plugindir/modules_meshcore/plugin.js
|
||||
// to control the output / actions here.
|
||||
response = require(args['_'][0]).consoleaction(args, rights, sessionid, mesh);
|
||||
} catch(e) {
|
||||
response = 'There was an error in the plugin';
|
||||
response = 'There was an error in the plugin (' + e + ')';
|
||||
}
|
||||
} else {
|
||||
response = 'Proper usage: plugin [pluginName] [args].';
|
||||
|
@ -2475,6 +2480,8 @@ function createMeshCore(agent)
|
|||
//if (process.platform == 'win32') { try { pr = require('win-info').pendingReboot(); } catch (ex) { pr = null; } } // Pending reboot
|
||||
if ((meshCoreObj.av == null) || (JSON.stringify(meshCoreObj.av) != JSON.stringify(av))) { meshCoreObj.av = av; mesh.SendCommand(meshCoreObj); }
|
||||
}
|
||||
|
||||
// TODO: add plugin hook here
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue