mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	Fixed plugin version matching, 2-factor reuirement + skip, removed GreenLock completely.
This commit is contained in:
		
							parent
							
								
									5acfc5f0fc
								
							
						
					
					
						commit
						d483872aa6
					
				
					 6 changed files with 40 additions and 374 deletions
				
			
		|  | @ -274,6 +274,19 @@ module.exports.pluginHandler = function (parent) { | |||
|         }) | ||||
|     }; | ||||
| 
 | ||||
|     // 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.
 | ||||
|     function versionToNumber(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.
 | ||||
|     function checkMeshCentralVersion(current, minimal) { | ||||
|         if (minimal.startsWith('>=')) { minimal = minimal.substring(2); } | ||||
|         var c = versionToNumber(current).split('.'), m = versionToNumber(minimal).split('.'); | ||||
|         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; } } | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     obj.getPluginLatest = function () { | ||||
|         return new Promise(function (resolve, reject) { | ||||
|             parent.db.getPlugins(function (err, plugins) { | ||||
|  | @ -294,16 +307,12 @@ 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 -<alpha_char> 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 ("000" + p1.charCodeAt(0)).substr(-3,3); }); | ||||
|                             var piCompatVer = newconf.meshCentralCompat.replace(/-(.)\b/g, (m, p1) => { return ("000" + p1.charCodeAt(0)).substr(-3,3); }); | ||||
|                             latestRet.push({ | ||||
|                                 'id': curconf._id, | ||||
|                                 'installedVersion': curconf.version, | ||||
|                                 'version': newconf.version, | ||||
|                                 'hasUpdate': s.gt(newconf.version, curconf.version), | ||||
|                                 'meshCentralCompat': s.satisfies(mcCurVer, piCompatVer), | ||||
|                                 'meshCentralCompat': checkMeshCentralVersion(parent.currentVer, newconf.meshCentralCompat), | ||||
|                                 'changelogUrl': curconf.changelogUrl, | ||||
|                                 'status': curconf.status | ||||
|                             }); | ||||
|  | @ -377,7 +386,7 @@ module.exports.pluginHandler = function (parent) { | |||
|                     response.pipe(file); | ||||
|                     file.on('finish', function () { | ||||
|                         file.close(function () { | ||||
|                             var yauzl = require("yauzl"); | ||||
|                             var yauzl = require('yauzl'); | ||||
|                             if (!obj.fs.existsSync(obj.pluginPath)) { | ||||
|                                 obj.fs.mkdirSync(obj.pluginPath); | ||||
|                             } | ||||
|  | @ -498,9 +507,10 @@ module.exports.pluginHandler = function (parent) { | |||
|     obj.removePlugin = function (id, func) { | ||||
|         parent.db.getPlugin(id, function (err, docs) { | ||||
|             var plugin = docs[0]; | ||||
|             var rimraf = require('rimraf'); | ||||
|             var rimraf = null; | ||||
|             try { rimraf = require('rimraf'); } catch (ex) { } | ||||
|             let pluginPath = obj.parent.path.join(obj.pluginPath, plugin.shortName); | ||||
|             rimraf.sync(pluginPath); | ||||
|             if (rimraf) rimraf.sync(pluginPath); | ||||
|             parent.db.deletePlugin(id, func); | ||||
|             delete obj.plugins[plugin.shortName]; | ||||
|         }); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue