Now requires NodeJS v10 or above.

Ylian Saint-Hilaire committed May 27, 2021 at 15:25 UTC f036546c92435ec47a8944c4a0470cf7edd248b4
2 files changed +28 -47
meshcentral.js
+13 -45
@@ -1363,13 +1363,7 @@ function CreateMeshCentralServer(config, args) {
1363
1364 // Start plugin manager if configuration allows this.
1365 if ((obj.config) && (obj.config.settings) && (obj.config.settings.plugins != null) && (obj.config.settings.plugins != false) && ((typeof obj.config.settings.plugins != 'object') || (obj.config.settings.plugins.enabled != false))) {
1366 - const nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
1367 - if (nodeVersion < 7) {
1368 - addServerWarning("Plugin support requires Node v7.x or higher.");
1369 - delete obj.config.settings.plugins;
1370 - } else {
1371 - obj.pluginHandler = require('./pluginHandler.js').pluginHandler(obj);
1372 - }
1366 + obj.pluginHandler = require('./pluginHandler.js').pluginHandler(obj);
1367 }
1368
1369 // Load the default meshcore and meshcmd
@@ -1390,8 +1384,7 @@ function CreateMeshCentralServer(config, args) {
1384 // Load server certificates
1385 obj.certificateOperations.GetMeshServerCertificate(obj.args, obj.config, function (certs) {
1386 // Get the current node version
1393 - const nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
1394 - if ((obj.config.letsencrypt == null) || (obj.redirserver == null) || (nodeVersion < 8)) {
1387 + if ((obj.config.letsencrypt == null) || (obj.redirserver == null)) {
1388 obj.StartEx3(certs); // Just use the configured certificates
1389 } else if ((obj.config.letsencrypt != null) && (obj.config.letsencrypt.nochecks == true)) {
1390 // Use Let's Encrypt with no checking
@@ -1624,8 +1617,7 @@ function CreateMeshCentralServer(config, args) {
1617
1618 // Setup Firebase
1619 if ((config.firebase != null) && (typeof config.firebase.senderid == 'string') && (typeof config.firebase.serverkey == 'string')) {
1627 - const NodeJSVer = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
1628 - if (NodeJSVer >= 10) { obj.firebase = require('./firebase').CreateFirebase(obj, config.firebase.senderid, config.firebase.serverkey); }
1620 + obj.firebase = require('./firebase').CreateFirebase(obj, config.firebase.senderid, config.firebase.serverkey);
1621 } else if ((typeof config.firebaserelay == 'object') && (typeof config.firebaserelay.url == 'string')) {
1622 // Setup the push messaging relay
1623 obj.firebase = require('./firebase').CreateFirebaseRelay(obj, config.firebaserelay.url, config.firebaserelay.key);
@@ -3087,8 +3079,8 @@ var meshserver = null;
3079 var childProcess = null;
3080 var previouslyInstalledModules = {};
3081 function mainStart() {
3090 - // Check the NodeJS is version 6 or better.
3091 - if (Number(process.version.match(/^v(\d+\.\d+)/)[1]) < 6) { console.log("MeshCentral requires Node v6 or above, current version is " + process.version + "."); return; }
3082 + // Check the NodeJS is version 10 or better.
3083 + if (Number(process.version.match(/^v(\d+\.\d+)/)[1]) < 10) { console.log("MeshCentral requires Node v10 or above, current version is " + process.version + "."); return; }
3084
3085 // If running within the node_modules folder, move working directory to the parent of the node_modules folder.
3086 if (__dirname.endsWith('\\node_modules\\meshcentral') || __dirname.endsWith('/node_modules/meshcentral')) { process.chdir(require('path').join(__dirname, '..', '..')); }
@@ -3156,18 +3148,18 @@ function mainStart() {
3148 if ((typeof config.domains[i].authstrategies.saml == 'object') || (typeof config.domains[i].authstrategies.jumpcloud == 'object')) { passport.push('passport-saml'); }
3149 }
3150 if (config.domains[i].sessionrecording != null) { sessionRecording = true; }
3159 - if ((config.domains[i].passwordrequirements != null) && (config.domains[i].passwordrequirements.bancommonpasswords == true)) { if (nodeVersion < 8) { config.domains[i].passwordrequirements = false; addServerWarning('Common password checking requires NodeJS v8 or above.'); } else { wildleek = true; } }
3151 + if ((config.domains[i].passwordrequirements != null) && (config.domains[i].passwordrequirements.bancommonpasswords == true)) { wildleek = true; }
3152 }
3153
3154 // Build the list of required modules
3163 - var modules = ['ws', 'cbor@5.2.0', 'nedb', 'https', 'yauzl', 'xmldom', 'ipcheck', 'express', 'archiver@4.0.2', 'multiparty', 'node-forge', 'express-ws', 'compression', 'body-parser', 'cookie-session', 'express-handlebars'];
3155 + var modules = ['ws@7.4.6', 'cbor@5.2.0', 'nedb', 'https', 'yauzl', 'xmldom', 'ipcheck', 'express', 'archiver@4.0.2', 'multiparty', 'node-forge', 'express-ws', 'compression', 'body-parser', 'cookie-session', 'express-handlebars'];
3156 if (require('os').platform() == 'win32') { modules.push('node-windows'); modules.push('loadavg-windows'); if (sspi == true) { modules.push('node-sspi'); } } // Add Windows modules
3157 if (ldap == true) { modules.push('ldapauth-fork'); }
3158 if (mstsc == true) { modules.push('node-rdpjs-2'); }
3159 if (ssh == true) { modules.push('ssh2'); }
3160 if (passport != null) { modules.push(...passport); }
3161 if (sessionRecording == true) { modules.push('image-size'); } // Need to get the remote desktop JPEG sizes to index the recodring file.
3170 - if (config.letsencrypt != null) { if (nodeVersion < 8) { addServerWarning("Let's Encrypt support requires Node v8.x or higher.", !args.launch); } else { modules.push('acme-client'); } } // Add acme-client module
3162 + if (config.letsencrypt != null) { modules.push('acme-client'); } // Add acme-client module
3163 if (config.settings.mqtt != null) { modules.push('aedes@0.39.0'); } // Add MQTT Modules
3164 if (config.settings.mysql != null) { modules.push('mysql'); } // Add MySQL.
3165 //if (config.settings.mysql != null) { modules.push('@mysql/xdevapi'); } // Add MySQL, official driver (https://dev.mysql.com/doc/dev/connector-nodejs/8.0/)
@@ -3181,29 +3173,14 @@ function mainStart() {
3173 if (sendgrid || (config.sendgrid != null)) { modules.push('@sendgrid/mail'); } // Add SendGrid support
3174 if (args.translate) { modules.push('jsdom'); modules.push('esprima'); modules.push('minify-js'); modules.push('html-minifier'); } // Translation support
3175
3184 - // If running NodeJS < 8, install "util.promisify"
3185 - if (nodeVersion < 8) { modules.push('util.promisify'); }
3186 -
3176 // Setup encrypted zip support if needed
3177 if (config.settings.autobackup && config.settings.autobackup.zippassword) {
3178 modules.push('archiver-zip-encrypted');
3179 // Enable Google Drive Support
3191 - if (typeof config.settings.autobackup.googledrive == 'object') {
3192 - if (nodeVersion >= 8) {
3193 - modules.push('googleapis');
3194 - } else {
3195 - addServerWarning("Google Drive requires Node v8.x or higher.", !args.launch);
3196 - delete config.settings.autobackup.googledrive;
3197 - }
3198 - }
3180 + if (typeof config.settings.autobackup.googledrive == 'object') { modules.push('googleapis'); }
3181 // Enable WebDAV Support
3182 if (typeof config.settings.autobackup.webdav == 'object') {
3201 - if (nodeVersion >= 10) {
3202 - if ((typeof config.settings.autobackup.webdav.url != 'string') || (typeof config.settings.autobackup.webdav.username != 'string') || (typeof config.settings.autobackup.webdav.password != 'string')) { addServerWarning("Missing WebDAV parameters.", !args.launch); } else { modules.push('webdav'); }
3203 - } else {
3204 - addServerWarning("WebDAV requires Node v10.x or higher.", !args.launch);
3205 - delete config.settings.autobackup.webdav;
3206 - }
3183 + if ((typeof config.settings.autobackup.webdav.url != 'string') || (typeof config.settings.autobackup.webdav.username != 'string') || (typeof config.settings.autobackup.webdav.password != 'string')) { addServerWarning("Missing WebDAV parameters.", !args.launch); } else { modules.push('webdav'); }
3184 }
3185 }
3186
@@ -3221,23 +3198,14 @@ function mainStart() {
3198 if (config.settings.desktopmultiplex === true) { modules.push('image-size'); }
3199
3200 // SMS support
3224 - if ((config.sms != null) && (config.sms.provider == 'twilio')) {
3225 - const NodeJSVer = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
3226 - if (NodeJSVer < 8) { console.log("SMS Twilio support requires Node v8 or above, current version is " + process.version + "."); } else { modules.push('twilio'); }
3227 - }
3228 - if ((config.sms != null) && (config.sms.provider == 'plivo')) {
3229 - const NodeJSVer = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
3230 - if (NodeJSVer < 8) { console.log("SMS Plivo support requires Node v8 or above, current version is " + process.version + "."); } else { modules.push('plivo'); }
3231 - }
3201 + if ((config.sms != null) && (config.sms.provider == 'twilio')) { modules.push('twilio'); }
3202 + if ((config.sms != null) && (config.sms.provider == 'plivo')) { modules.push('plivo'); }
3203
3204 // Setup web based push notifications
3205 if ((typeof config.settings.webpush == 'object') && (typeof config.settings.webpush.email == 'string')) { modules.push('web-push'); }
3206
3207 // Firebase Support
3237 - if (config.firebase != null) {
3238 - const NodeJSVer = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
3239 - if (NodeJSVer < 10) { console.log("Firebase support required Node v10 or above, current version is " + process.version + "."); } else { modules.push('node-xcs'); }
3240 - }
3208 + if (config.firebase != null) { modules.push('node-xcs'); }
3209
3210 // Syslog support
3211 if ((require('os').platform() != 'win32') && (config.settings.syslog || config.settings.syslogjson)) { modules.push('modern-syslog'); }
package.json
+15 -2
@@ -36,6 +36,8 @@
36 "sample-config-advanced.json"
37 ],
38 "dependencies": {
39 + "archiver": "^4.0.2",
40 + "archiver-zip-encrypted": "^1.0.9",
41 "body-parser": "^1.19.0",
42 "cbor": "~5.2.0",
43 "compression": "^1.7.4",
@@ -43,14 +45,25 @@
45 "express": "^4.17.0",
46 "express-handlebars": "^3.1.0",
47 "express-ws": "^4.0.0",
48 + "image-size": "^1.0.0",
49 "ipcheck": "^0.1.0",
47 - "minimist": "^1.2.0",
50 + "loadavg-windows": "^1.1.1",
51 + "minimist": "^1.2.5",
52 + "mongodb": "^3.6.9",
53 "multiparty": "^4.2.1",
54 "nedb": "^1.8.0",
55 "node-forge": "^0.10.0",
56 + "node-rdpjs-2": "^0.3.5",
57 + "node-windows": "^1.0.0-beta.5",
58 + "otplib": "^10.2.3",
59 + "saslprep": "^1.0.3",
60 + "ssh2": "^0.8.9",
61 + "util.promisify": "^1.1.1",
62 + "web-push": "^3.4.4",
63 "ws": "^7.4.6",
64 "xmldom": "^0.5.0",
53 - "yauzl": "^2.10.0"
65 + "yauzl": "^2.10.0",
66 + "yubikeyotp": "^0.2.0"
67 },
68 "repository": {
69 "type": "git",