Main calls for server and console, update function list

This commit is contained in:
Ryan Blenis 2019-10-05 02:50:32 -04:00
parent 69e721e5cf
commit 2cf3f20fb7
1 changed files with 25 additions and 1 deletions

View File

@ -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;