Server crash fix in MeshUser.js

Ylian Saint-Hilaire committed Mar 9, 2019 at 14:53 UTC 1673acf424f763d665a0a0740ec5297253f348f1
2 files changed +13 -11
meshuser.js
+12 -10
@@ -464,10 +464,10 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
464 if (user.siteadmin != 0xFFFFFFFF) break;
465
466 var r = '';
467 - var args = splitArgs(command.value);
468 - if (args.length == 0) break;
469 - const cmd = args[0].toLowerCase();
470 - args = parseArgs(args);
467 + var cmdargs = splitArgs(command.value);
468 + if (cmdargs.length == 0) break;
469 + const cmd = cmdargs[0].toLowerCase();
470 + cmdargs = parseArgs(cmdargs);
471
472 switch (cmd) {
473 case 'help': {
@@ -495,7 +495,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
495 break;
496 }
497 case 'args': {
498 - r = cmd + ': ' + JSON.stringify(args);
498 + r = cmd + ': ' + JSON.stringify(cmdargs);
499 break;
500 }
501 case 'usersessions': {
@@ -528,10 +528,10 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
528 break;
529 }
530 case 'setmaxtasks': {
531 - if ((args["_"].length != 1) || (parseInt(args["_"][0]) < 1) || (parseInt(args["_"][0]) > 1000)) {
531 + if ((cmdargs["_"].length != 1) || (parseInt(cmdargs["_"][0]) < 1) || (parseInt(cmdargs["_"][0]) > 1000)) {
532 r = 'Usage: setmaxtasks [1 to 1000]';
533 } else {
534 - parent.parent.taskLimiter.maxTasks = parseInt(args["_"][0]);
534 + parent.parent.taskLimiter.maxTasks = parseInt(cmdargs["_"][0]);
535 r = 'MaxTasks set to ' + parent.parent.taskLimiter.maxTasks + '.';
536 }
537 break;
@@ -990,7 +990,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
990 if (args.lanonly == true) { return; } // User-to-device chat is not support in LAN-only mode yet. We need the agent to replace the IP address of the server??
991
992 // Create the server url
993 - var httpsPort = ((parent.args.aliasport == null) ? parent.args.port : parent.args.aliasport); // Use HTTPS alias port is specified
993 + var httpsPort = ((args.aliasport == null) ? args.port : args.aliasport); // Use HTTPS alias port is specified
994 var xdomain = (domain.dns == null) ? domain.id : '';
995 if (xdomain != '') xdomain += "/";
996 var url = "http" + (args.notls ? '' : 's') + "://" + parent.getWebServerName(domain) + ":" + httpsPort + "/" + xdomain + "messenger?id=meshmessenger/" + encodeURIComponent(command.nodeid) + "/" + encodeURIComponent(user._id) + "&title=" + encodeURIComponent(user.name);
@@ -1243,7 +1243,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
1243 if ((command.amttls != 1) && (command.amttls != 0)) break;
1244
1245 // If we are in WAN-only mode, hostname is not used
1246 - if ((parent.parent.args.wanonly == true) && (command.hostname)) { delete command.hostname; }
1246 + if ((args.wanonly == true) && (command.hostname)) { delete command.hostname; }
1247
1248 // Get the mesh
1249 mesh = parent.meshes[command.meshid];
@@ -1557,7 +1557,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
1557 event.msg = ": ";
1558
1559 // If we are in WAN-only mode, host is not used
1560 - if ((parent.parent.args.wanonly == true) && (command.host)) { delete command.host; }
1560 + if ((args.wanonly == true) && (command.host)) { delete command.host; }
1561
1562 // Look for a change
1563 if (command.icon && (command.icon != node.icon)) { change = 1; node.icon = command.icon; changes.push('icon'); }
@@ -1846,6 +1846,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
1846 }
1847 case 'otp-hkey-get':
1848 {
1849 +
1850 +
1851 // Check is 2-step login is supported
1852 const twoStepLoginSupported = ((domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.lanonly !== true) && (args.nousers !== true));
1853 if (twoStepLoginSupported == false) break;
package.json
+1 -1
@@ -1,6 +1,6 @@
1 {
2 "name": "meshcentral",
3 - "version": "0.2.9-z",
3 + "version": "0.3.0-b",
4 "keywords": [
5 "Remote Management",
6 "Intel AMT",