This commit is contained in:
Ylian Saint-Hilaire 2020-03-13 15:43:39 -07:00
commit 9e963e5eb3
3 changed files with 24 additions and 6 deletions

View File

@ -1960,7 +1960,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 = 'agentsize,version,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,wallpaper'; var fin = '', f = '', availcommands = 'alert,agentsize,version,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,wallpaper';
if (process.platform == 'win32') { availcommands += ',safemode,wpfhwacceleration'; } if (process.platform == 'win32') { availcommands += ',safemode,wpfhwacceleration'; }
availcommands = availcommands.split(',').sort(); availcommands = availcommands.split(',').sort();
while (availcommands.length > 0) { while (availcommands.length > 0) {
@ -1971,6 +1971,24 @@ function createMeshCore(agent) {
response = "Available commands: \r\n" + fin + "."; response = "Available commands: \r\n" + fin + ".";
break; break;
} }
case 'alert':
if (args['_'].length == 0)
{
response = "Proper usage: alert TITLE, CAPTION [, TIMEOUT]"; // Display usage
}
else
{
var p = args['_'].join(' ').split(',');
if(p.length<2)
{
response = "Proper usage: alert TITLE, CAPTION [, TIMEOUT]"; // Display usage
}
else
{
this._alert = require('message-box').create(p[0], p[1], p.length==3?parseInt(p[2]):9999);
}
}
break;
case 'agentsize': case 'agentsize':
var actualSize = Math.floor(require('fs').statSync(process.execPath).size / 1024); var actualSize = Math.floor(require('fs').statSync(process.execPath).size / 1024);
if (process.platform == 'win32') { if (process.platform == 'win32') {

View File

@ -276,12 +276,12 @@ module.exports.pluginHandler = function (parent) {
// MeshCentral doesn't adhere to semantic versioning (due to the -<alpha_char> at the end of the version) // MeshCentral doesn't adhere to semantic versioning (due to the -<alpha_char> at the end of the version)
// Convert 1.2.3-a to 1.2.3-3 where the letter is converted to a number. // Convert 1.2.3-a to 1.2.3-3 where the letter is converted to a number.
function versionToNumber(ver) { var x = ver.split('-'); if (x.length != 2) return ver; x[1] = x[1].toLowerCase().charCodeAt(0) - 96; return x.join('.'); } obj.versionToNumber = function(ver) { var x = ver.split('-'); if (x.length != 2) return ver; x[1] = x[1].toLowerCase().charCodeAt(0) - 96; return x.join('.'); }
// Check if the current version of MeshCentral is at least the minimal required. // Check if the current version of MeshCentral is at least the minimal required.
function checkMeshCentralVersion(current, minimal) { obj.versionCompare = function(current, minimal) {
if (minimal.startsWith('>=')) { minimal = minimal.substring(2); } if (minimal.startsWith('>=')) { minimal = minimal.substring(2); }
var c = versionToNumber(current).split('.'), m = versionToNumber(minimal).split('.'); var c = obj.versionToNumber(current).split('.'), m = obj.versionToNumber(minimal).split('.');
if (c.length != m.length) return false; if (c.length != m.length) return false;
for (var i = 0; i < c.length; i++) { var cx = parseInt(c[i]), cm = parseInt(m[i]); if (cx > cm) { return true; } if (cx < cm) { return false; } } for (var i = 0; i < c.length; i++) { var cx = parseInt(c[i]), cm = parseInt(m[i]); if (cx > cm) { return true; } if (cx < cm) { return false; } }
return true; return true;
@ -312,7 +312,7 @@ module.exports.pluginHandler = function (parent) {
'installedVersion': curconf.version, 'installedVersion': curconf.version,
'version': newconf.version, 'version': newconf.version,
'hasUpdate': s.gt(newconf.version, curconf.version), 'hasUpdate': s.gt(newconf.version, curconf.version),
'meshCentralCompat': checkMeshCentralVersion(parent.currentVer, newconf.meshCentralCompat), 'meshCentralCompat': obj.versionCompare(parent.currentVer, newconf.meshCentralCompat),
'changelogUrl': curconf.changelogUrl, 'changelogUrl': curconf.changelogUrl,
'status': curconf.status 'status': curconf.status
}); });

View File

@ -49,7 +49,7 @@ A valid JSON object within a file named `config.json` in the root folder of your
| repository.type | Yes | string | valid values are `git` and in the future, `npm` will also be supported in the future | repository.type | Yes | string | valid values are `git` and in the future, `npm` will also be supported in the future
| repository.url | Yes | string | the URL to the project's repository | repository.url | Yes | string | the URL to the project's repository
| versionHistoryUrl | No | string | the URL to the project's versions/tags | versionHistoryUrl | No | string | the URL to the project's versions/tags
| meshCentralCompat | Yes | string | the semantic version string of required compatibility with the MeshCentral server | meshCentralCompat | Yes | string | the minimum version string of required compatibility with the MeshCentral server, can be formatted as "0.1.2-c" or ">=0.1.2-c". Currently only supports minimum version, not full semantic checking.
## Plugin Hooks ## Plugin Hooks
These are separated into the following categories depending on the type of functionality the plugin should offer. These are separated into the following categories depending on the type of functionality the plugin should offer.