Main calls for server and console, update function list

Ryan Blenis committed Oct 5, 2019 at 02:50 UTC 2cf3f20fb7b75b6fdef4ece6c33d0879941c1f6e
1 file changed +25 -1
agents/meshcore.min.js
+25 -1
@@ -757,6 +757,17 @@ function createMeshCore(agent)
757 }
758 break;
759 }
760 + case 'plugin': {
761 + if (typeof data.pluginaction == 'string') {
762 + try {
763 + MeshServerLog('Plugin called', data);
764 + require(data.plugin.name).serveraction(data);
765 + } catch(e) {
766 + MeshServerLog('Error calling plugin', data);
767 + }
768 + }
769 + break;
770 + }
771 default:
772 // Unknown action, ignore it.
773 break;
@@ -1683,7 +1694,7 @@ function createMeshCore(agent)
1694 var response = null;
1695 switch (cmd) {
1696 case 'help': { // Displays available commands
1686 - 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';
1697 + 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';
1698 availcommands = availcommands.split(',').sort();
1699 while (availcommands.length > 0) {
1700 if (f.length > 100) { fin += (f + ',\r\n'); f = ''; }
@@ -2339,6 +2350,19 @@ function createMeshCore(agent)
2350 }
2351 break;
2352 }
2353 + case 'plugin': {
2354 + if (typeof args['_'][0] == 'string') {
2355 + try {
2356 + response = require(args['_'][0]).consoleaction(args, rights, sessionid);
2357 + } catch(e) {
2358 + response = 'There was an error in the plugin';
2359 + }
2360 + } else {
2361 + response = 'Proper usage: plugin [pluginName] [args].';
2362 + }
2363 +
2364 + break;
2365 + }
2366 default: { // This is an unknown command, return an error message
2367 response = 'Unknown command \"' + cmd + '\", type \"help\" for list of avaialble commands.';
2368 break;