From e102b21f29fe7ea511dfca83b2d5c19a599b1b73 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 6 Nov 2018 19:41:21 -0800 Subject: [PATCH] Fixed user session counts --- meshuser.js | 10 +++++----- mpsserver.js | 4 ++-- package.json | 2 +- sample-config.json | 4 +++- views/default.handlebars | 2 +- webserver.js | 10 +++++----- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/meshuser.js b/meshuser.js index 8f2bb93b..07653731 100644 --- a/meshuser.js +++ b/meshuser.js @@ -81,9 +81,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use if (user == null) { try { obj.ws.close(); } catch (e) { } return; } // Associate this websocket session with the web session - //req.session.ws = obj.ws; - //req.session.ws.userid = req.session.userid; - //req.session.ws.domainid = domain.id; + obj.ws.userid = req.session.userid; + obj.ws.domainid = domain.id; // Add this web socket session to session list obj.ws.sessionId = user._id + '/' + ('' + Math.random()).substring(2); @@ -102,7 +101,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use obj.ws.HandleEvent = function (source, event) { if (!event.domain || event.domain == obj.domain.id) { try { - if (event == 'close') { req.session.destroy(); obj.close(); } + if (event == 'close') { try { delete req.session; } catch (ex) { } obj.close(); } else if (event == 'resubscribe') { user.subscriptions = obj.parent.subscribe(user._id, ws); } else if (event == 'updatefiles') { updateUserFiles(user, ws, domain); } else { ws.send(JSON.stringify({ action: 'event', event: event })); } @@ -1137,7 +1136,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use case 'close': { // Close the web socket session - if (obj.req.session && obj.req.session.ws && obj.req.session.ws == ws) delete obj.req.session.ws; + console.log('CLOSING1'); + if (obj.req.session && obj.req.session.ws && obj.req.session.ws == ws) { console.log('CLOSING2'); delete obj.req.session.ws; } try { ws.close(); } catch (e) { } break; } diff --git a/mpsserver.js b/mpsserver.js index 8517636b..e8c1f804 100644 --- a/mpsserver.js +++ b/mpsserver.js @@ -26,7 +26,7 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) { const tls = require("tls"); const MAX_IDLE = 90000; // 90 seconds max idle time, higher than the typical KEEP-ALIVE periode of 60 seconds - if (obj.args.tlsoffload) { + if (obj.args.mpstlsoffload) { obj.server = net.createServer(onConnection); } else { obj.server = tls.createServer({ key: certificates.mps.key, cert: certificates.mps.cert, requestCert: true, rejectUnauthorized: false }, onConnection); @@ -99,7 +99,7 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) { }; function onConnection(socket) { - if (obj.args.tlsoffload) { + if (obj.args.mpstlsoffload) { socket.tag = { first: true, clientCert: null, accumulator: "", activetunnels: 0, boundPorts: [], socket: socket, host: null, nextchannelid: 4, channels: {}, nextsourceport: 0 }; } else { socket.tag = { first: true, clientCert: socket.getPeerCertificate(true), accumulator: "", activetunnels: 0, boundPorts: [], socket: socket, host: null, nextchannelid: 4, channels: {}, nextsourceport: 0 }; diff --git a/package.json b/package.json index 4ee9a1b8..a6831aaf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.2.2-s", + "version": "0.2.2-t", "keywords": [ "Remote Management", "Intel AMT", diff --git a/sample-config.json b/sample-config.json index e7173ed8..b9fd5e1e 100644 --- a/sample-config.json +++ b/sample-config.json @@ -16,7 +16,9 @@ "_ClickOnce": false, "_SelfUpdate": true, "_UserAllowedIP": "127.0.0.1,::1,192.168.0.100", - "_LocalDiscovery": { "name": "Local server name", "info": "Information about this server" } + "_LocalDiscovery": { "name": "Local server name", "info": "Information about this server" }, + "_TlsOffload": true, + "_MpsTlsOffload": true }, "_domains": { "": { diff --git a/views/default.handlebars b/views/default.handlebars index 45220a88..430ef0a5 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -2101,7 +2101,7 @@ if (serverinfo != null) { x += addHtmlValue('MPS Server', ''); } x += ""; - // Setup CIRA with certificate authentication (Really difficult, only is allowed) + // Setup CIRA with certificate authentication (Really difficult, only if TLS offload is not used) if ((features & 16) == 0) { x += "