diff --git a/agents/MeshCmd-signed.exe b/agents/MeshCmd-signed.exe index 29afc341..eb7f2df6 100644 Binary files a/agents/MeshCmd-signed.exe and b/agents/MeshCmd-signed.exe differ diff --git a/agents/MeshCmd64-signed.exe b/agents/MeshCmd64-signed.exe index 43972747..249a904a 100644 Binary files a/agents/MeshCmd64-signed.exe and b/agents/MeshCmd64-signed.exe differ diff --git a/agents/meshcore.js b/agents/meshcore.js index d52c5fff..197627b9 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -688,6 +688,7 @@ function createMeshCore(agent) { // Create a new tunnel object var xurl = getServerTargetUrlEx(data.value); if (xurl != null) { + xurl = xurl.split('$').join('%24').split('@').join('%40'); // Escape the $ and @ characters var woptions = http.parseUri(xurl); woptions.rejectUnauthorized = 0; //sendConsoleText(JSON.stringify(woptions)); @@ -2892,7 +2893,7 @@ function createMeshCore(agent) { } else { var httprequest = null; try { - var options = http.parseUri(args['_'][0]); + var options = http.parseUri(args['_'][0].split('$').join('%24').split('@').join('%40')); // Escape the $ and @ characters in the URL options.rejectUnauthorized = 0; httprequest = http.request(options); } catch (e) { response = 'Invalid HTTP websocket request'; } diff --git a/meshdesktopmultiplex.js b/meshdesktopmultiplex.js index 33e993a4..91715b14 100644 --- a/meshdesktopmultiplex.js +++ b/meshdesktopmultiplex.js @@ -93,7 +93,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) { // Add an agent or viewer obj.addPeer = function (peer) { - if (obj.viewers == null) return; + if (obj.viewers == null) { parent.parent.debug('relay', 'DesktopRelay: Error, addingPeer on disposed session'); return; } if (peer.req.query.browser) { //console.log('addPeer-viewer', obj.nodeid); @@ -138,7 +138,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) { obj.sendSessionMetadata(); } else { //console.log('addPeer-agent', obj.nodeid); - if (obj.agent != null) return false; + if (obj.agent != null) { parent.parent.debug('relay', 'DesktopRelay: Error, duplicate agent connection'); return false; } // Setup the agent obj.agent = peer; diff --git a/webserver.js b/webserver.js index d94f6847..4ac2abc9 100644 --- a/webserver.js +++ b/webserver.js @@ -4270,6 +4270,9 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { parent.debug('webrequest', '(' + req.clientIp + ') ' + req.url); res.removeHeader('X-Powered-By'); + // Skip the rest is this is an agent connection + if ((req.url.indexOf('/meshrelay.ashx/.websocket') >= 0) || (req.url.indexOf('/agent.ashx/.websocket') >= 0)) { next(); return; } + // If this domain has configured headers, use them. // Example headers: { 'Strict-Transport-Security': 'max-age=360000;includeSubDomains' }; // { 'Referrer-Policy': 'no-referrer', 'x-frame-options': 'SAMEORIGIN', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "default-src http: ws: data: 'self';script-src http: 'unsafe-inline';style-src http: 'unsafe-inline'" }; @@ -4293,7 +4296,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { if ((req.session.ip != null) && (req.clientIp != null) && (req.session.ip != req.clientIp)) { req.session = {}; } // Extend the session time by forcing a change to the session every minute. - req.session.nowInMinutes = Math.floor(Date.now() / 60e3); + if (req.session.userid != null) { req.session.nowInMinutes = Math.floor(Date.now() / 60e3); } else { delete req.session.nowInMinutes; } // Detect if this is a file sharing domain, if so, just share files. if ((domain != null) && (domain.share != null)) {