From f90fe05fe0699a4a73c8df19b49411916a1b8707 Mon Sep 17 00:00:00 2001 From: Ryan Blenis Date: Wed, 6 Nov 2019 20:00:09 -0500 Subject: [PATCH] Fake semantic versioning for MeshCentral version comparison / plugin update compatibility check --- meshuser.js | 3 +-- pluginHandler.js | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/meshuser.js b/meshuser.js index ed011cbd..390586e3 100644 --- a/meshuser.js +++ b/meshuser.js @@ -3130,8 +3130,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use } case 'addplugin': { if ((user.siteadmin & 0xFFFFFFFF) == 0 || parent.parent.pluginHandler == null) break; // must be full admin, plugins enabled - try { - //parent.parent.pluginHandler.addPlugin(command.url) + try { parent.parent.pluginHandler.getPluginConfig(command.url) .then(parent.parent.pluginHandler.addPlugin) .then(function(docs){ diff --git a/pluginHandler.js b/pluginHandler.js index fddc3f03..3fb25741 100644 --- a/pluginHandler.js +++ b/pluginHandler.js @@ -263,12 +263,16 @@ module.exports.pluginHandler = function (parent) { }); if (curconf == null) reject('Some plugin configs could not be parsed'); var s = require('semver'); + // MeshCentral doesn't adhere to semantic versioning (due to the - at the end of the version) + // Convert the letter to ASCII for a "true" version number comparison + var mcCurVer = parent.currentVer.replace(/-(.)$/, (m, p1) => { return p1.charCodeAt(0); }); + var piCompatVer = newconf.meshCentralCompat.replace(/-(.)$/, (m, p1) => { return p1.charCodeAt(0); }); latestRet.push({ "id": curconf._id, "installedVersion": curconf.version, "version": newconf.version, "hasUpdate": s.gt(newconf.version, curconf.version), - "meshCentralCompat": s.satisfies(s.coerce(parent.currentVer), newconf.meshCentralCompat), + "meshCentralCompat": s.satisfies(mcCurVer, piCompatVer), "changelogUrl": curconf.changelogUrl, "status": curconf.status });