Expand pluginHandler support to communicate with browser<->server over the control channel. Expand plugin functionality on agents to get plugin commands as their own action.

Expand pluginHandler support to communicate with browser<->server over the control channel. Expand plugin functionality on agents to get plugin commands as their own action.

Ryan Blenis committed Oct 24, 2019 at 16:41 UTC 3e20fc5195df97e22bd61daaed74a7e59da7739e
3 files changed +7 -19
agents/meshcore.js
+1 -9
@@ -819,15 +819,7 @@ function createMeshCore(agent) {
819 case 'ping': { mesh.SendCommand('{"action":"pong"}'); break; }
820 case 'pong': { break; }
821 case 'plugin': {
822 - if (typeof data.pluginaction == 'string') {
823 - try {
824 - MeshServerLog('Plugin called', data);
825 - // Not yet implemented
826 - // require(data.plugin.name).serveraction(data);
827 - } catch (e) {
828 - MeshServerLog('Error calling plugin', data);
829 - }
830 - }
822 + try { require(data.plugin).consoleaction(data, data.rights, data.sessionid, this); } catch (e) { throw e; }
823 break;
824 }
825 default:
agents/meshcore.min.js
+1 -9
@@ -819,15 +819,7 @@ function createMeshCore(agent) {
819 case 'ping': { mesh.SendCommand('{"action":"pong"}'); break; }
820 case 'pong': { break; }
821 case 'plugin': {
822 - if (typeof data.pluginaction == 'string') {
823 - try {
824 - MeshServerLog('Plugin called', data);
825 - // Not yet implemented
826 - // require(data.plugin.name).serveraction(data);
827 - } catch (e) {
828 - MeshServerLog('Error calling plugin', data);
829 - }
830 - }
822 + try { require(data.plugin).consoleaction(data, data.rights, data.sessionid, this); } catch (e) { throw e; }
823 break;
824 }
825 default:
meshuser.js
+5 -1
@@ -50,6 +50,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
50 var obj = {};
51 obj.user = user;
52 obj.domain = domain;
53 + obj.ws = ws;
54
55 // Server side Intel AMT stack
56 const WsmanComm = require('./amt/amt-wsman-comm.js');
@@ -3105,7 +3106,10 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
3106 if (command.routeToNode === true) {
3107 routeCommandToNode(command);
3108 } else {
3108 - // TODO
3109 + try {
3110 + var pluginHandler = require('./pluginHandler.js').pluginHandler(parent.parent);
3111 + pluginHandler.plugins[command.plugin].serveraction(command, obj, parent);
3112 + } catch (e) { console.log('Error loading plugin handler (' + e + ')'); }
3113 }
3114
3115 break;