From 2cf3f20fb7b75b6fdef4ece6c33d0879941c1f6e Mon Sep 17 00:00:00 2001 From: Ryan Blenis Date: Sat, 5 Oct 2019 02:50:32 -0400 Subject: [PATCH] Main calls for server and console, update function list --- agents/meshcore.min.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/agents/meshcore.min.js b/agents/meshcore.min.js index d6c15a1a..bc6ad446 100644 --- a/agents/meshcore.min.js +++ b/agents/meshcore.min.js @@ -757,6 +757,17 @@ 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; @@ -1683,7 +1694,7 @@ function createMeshCore(agent) var response = null; switch (cmd) { case 'help': { // Displays available commands - var fin = '', f = '', availcommands = 'help,info,osinfo,args,print,type,dbget,dbset,dbcompact,eval,parseuri,httpget,nwslist,wsconnect,wssend,wsclose,notify,ls,ps,kill,amt,netinfo,location,power,wakeonlan,setdebug,smbios,rawsmbios,toast,lock,users,sendcaps,openurl,amtreset,amtccm,amtacm,amtdeactivate,amtpolicy,getscript,getclip,setclip,log,av,cpuinfo,sysinfo,apf,scanwifi,scanamt'; + var fin = '', f = '', availcommands = 'help,info,osinfo,args,print,type,dbkeys,dbget,dbset,dbcompact,eval,parseuri,httpget,nwslist,plugin,wsconnect,wssend,wsclose,notify,ls,ps,kill,amt,netinfo,location,power,wakeonlan,setdebug,smbios,rawsmbios,toast,lock,users,sendcaps,openurl,amtreset,amtccm,amtacm,amtdeactivate,amtpolicy,getscript,getclip,setclip,log,av,cpuinfo,sysinfo,apf,scanwifi,scanamt'; availcommands = availcommands.split(',').sort(); while (availcommands.length > 0) { if (f.length > 100) { fin += (f + ',\r\n'); f = ''; } @@ -2339,6 +2350,19 @@ function createMeshCore(agent) } break; } + case 'plugin': { + if (typeof args['_'][0] == 'string') { + try { + response = require(args['_'][0]).consoleaction(args, rights, sessionid); + } catch(e) { + response = 'There was an error in the plugin'; + } + } else { + response = 'Proper usage: plugin [pluginName] [args].'; + } + + break; + } default: { // This is an unknown command, return an error message response = 'Unknown command \"' + cmd + '\", type \"help\" for list of avaialble commands.'; break;