From 89f37973a0314755d2ec19df21ead0f3ee7fd461 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Mon, 17 Jun 2019 15:37:13 -0700 Subject: [PATCH] Server fixes when agent comes in with unknown agentid. --- meshagent.js | 22 ++++++++++++---------- package.json | 2 +- webserver.js | 4 ++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/meshagent.js b/meshagent.js index a5d493e6..383370f8 100644 --- a/meshagent.js +++ b/meshagent.js @@ -141,16 +141,18 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { } // We need to check if the core is current. Figure out what core we need. - var corename; - if (obj.agentCoreCheck == 1001) { - // If the user asked, use the recovery core. - corename = parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].rcore; - } else if (obj.agentInfo.capabilities & 0x40) { - // If this is a recovery agent, use the agent recovery core. - corename = parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].arcore; - } else { - // This is the normal core for this agent type. - corename = parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].core; + var corename = null; + if (parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId] != null) { + if (obj.agentCoreCheck == 1001) { + // If the user asked, use the recovery core. + corename = parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].rcore; + } else if (obj.agentInfo.capabilities & 0x40) { + // If this is a recovery agent, use the agent recovery core. + corename = parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].arcore; + } else { + // This is the normal core for this agent type. + corename = parent.parent.meshAgentsArchitectureNumbers[obj.agentInfo.agentId].core; + } } // If we have a core, use it. diff --git a/package.json b/package.json index d376479a..f4870999 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.3.6-o", + "version": "0.3.6-p", "keywords": [ "Remote Management", "Intel AMT", diff --git a/webserver.js b/webserver.js index 41cc8a7e..3844fee0 100644 --- a/webserver.js +++ b/webserver.js @@ -1721,7 +1721,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { var urlArgs = '', urlName = null, splitUrl = req.originalUrl.split("?"); if (splitUrl.length > 1) { urlArgs = '?' + splitUrl[1]; } if ((splitUrl.length > 0) && (splitUrl[0].length > 1)) { urlName = splitUrl[0].substring(1).toLowerCase(); } - if ((urlName == null) || (domain.redirects[urlName] == null)) { res.sendStatus(404); return; } + if ((urlName == null) || (domain.redirects[urlName] == null) || (urlName[0] == '_')) { res.sendStatus(404); return; } res.redirect(domain.redirects[urlName] + urlArgs + getQueryPortion(req)); } @@ -2743,7 +2743,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { obj.app.get(url + 'welcome.jpg', handleWelcomeImageRequest); // Server redirects - if (parent.config.domains[i].redirects) { for (var j in parent.config.domains[i].redirects) { obj.app.get(url + j, handleDomainRedirect); } } + if (parent.config.domains[i].redirects) { for (var j in parent.config.domains[i].redirects) { if (j[0] != '_') { obj.app.get(url + j, handleDomainRedirect); } } } // Server picture obj.app.get(url + 'serverpic.ashx', function (req, res) {