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; 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: default:
// Unknown action, ignore it. // Unknown action, ignore it.
break; break;
@ -1683,7 +1694,7 @@ function createMeshCore(agent)
var response = null; var response = null;
switch (cmd) { switch (cmd) {
case 'help': { // Displays available commands 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(); availcommands = availcommands.split(',').sort();
while (availcommands.length > 0) { while (availcommands.length > 0) {
if (f.length > 100) { fin += (f + ',\r\n'); f = ''; } if (f.length > 100) { fin += (f + ',\r\n'); f = ''; }
@ -2339,6 +2350,19 @@ function createMeshCore(agent)
} }
break; 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 default: { // This is an unknown command, return an error message
response = 'Unknown command \"' + cmd + '\", type \"help\" for list of avaialble commands.'; response = 'Unknown command \"' + cmd + '\", type \"help\" for list of avaialble commands.';
break; break;