diff --git a/meshrelay.js b/meshrelay.js index 43efeb4a..22ca38b2 100644 --- a/meshrelay.js +++ b/meshrelay.js @@ -18,6 +18,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie obj.ws = ws; obj.id = req.query.id; obj.user = user; + obj.req = req; // Used in multi-server.js // Relay session count (we may remove this in the future) obj.relaySessionCounted = true; @@ -181,22 +182,22 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie parent.parent.fs.open(recFullFilename, 'w', function (err, fd) { if (err != null) { // Unable to record - ws.send('c'); // Send connect to both peers - relayinfo.peer1.ws.send('c'); + try { ws.send('c'); } catch (ex) { } // Send connect to both peers + try { relayinfo.peer1.ws.send('c'); } catch (ex) { } } else { // Write the recording file header var firstBlock = JSON.stringify({ magic: 'MeshCentralRelaySession', ver: 1, userid: sessionUser._id, username: sessionUser.name, sessionid: obj.id, ipaddr1: cleanRemoteAddr(ws._socket.remoteAddress), ipaddr2: cleanRemoteAddr(obj.peer.ws._socket.remoteAddress), time: new Date().toLocaleString(), protocol: req.query.p, nodeid: req.query.nodeid }); recordingEntry(fd, 1, ((req.query.browser) ? 2 : 0), firstBlock, function () { relayinfo.peer1.ws.logfile = ws.logfile = { fd: fd, lock: false }; - ws.send('cr'); // Send connect to both peers, 'cr' indicates the session is being recorded. - relayinfo.peer1.ws.send('cr'); + try { ws.send('cr'); } catch (ex) { } // Send connect to both peers, 'cr' indicates the session is being recorded. + try { relayinfo.peer1.ws.send('cr'); } catch (ex) { } }); } }); } else { // Send session start - ws.send('c'); // Send connect to both peers - relayinfo.peer1.ws.send('c'); + try { ws.send('c'); } catch (ex) { } // Send connect to both peers + try { relayinfo.peer1.ws.send('c'); } catch (ex) { } } parent.parent.debug(1, 'Relay connected: ' + obj.id + ' (' + cleanRemoteAddr(ws._socket.remoteAddress) + ' --> ' + cleanRemoteAddr(obj.peer.ws._socket.remoteAddress) + ')'); diff --git a/multiserver.js b/multiserver.js index 40c52297..10e17774 100644 --- a/multiserver.js +++ b/multiserver.js @@ -583,7 +583,7 @@ module.exports.CreateMultiServer = function (parent, args) { if (path[0] == '/') path = path.substring(1); if (path.substring(path.length - 11) == '/.websocket') { path = path.substring(0, path.length - 11); } var queryStr = ''; - for (var i in req.query) { queryStr += ((queryStr == '') ? '?' : '&') + i + '=' + req.query[i]; } + for (var i in req.query) { if (i.toLowerCase() != 'auth') { queryStr += ((queryStr == '') ? '?' : '&') + i + '=' + req.query[i]; } } if (user != null) { queryStr += ((queryStr == '') ? '?' : '&') + 'auth=' + obj.parent.encodeCookie({ userid: user._id, domainid: user.domain }, cookieKey); } var url = obj.peerConfig.servers[serverid].url + path + queryStr; diff --git a/package.json b/package.json index 50e2684d..6377aa92 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.3.9-x", + "version": "0.3.9-y", "keywords": [ "Remote Management", "Intel AMT", diff --git a/webserver.js b/webserver.js index afc0c8b8..506deded 100644 --- a/webserver.js +++ b/webserver.js @@ -3192,6 +3192,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { } else if ((req.query.auth != null) && (req.query.auth != '')) { // This is a encrypted cookie authentication var cookie = obj.parent.decodeCookie(req.query.auth, obj.parent.loginCookieEncryptionKey, 240); // Cookie with 4 hour timeout + if ((cookie == null) && (obj.parent.multiServer != null)) { cookie = obj.parent.decodeCookie(req.query.auth, obj.parent.serverKey, 240); } // Try the server key if ((cookie != null) && (obj.users[cookie.userid]) && (cookie.domainid == domain.id)) { // Valid cookie, we are authenticated func(ws, req, domain, obj.users[cookie.userid], cookie);