Desktop sharing disconnect fix.

Ylian Saint-Hilaire committed Aug 7, 2020 at 17:21 UTC 154f5174356031480d784c9df06f3eb506d3ce62
1 file changed +4 -4
meshrelay.js
+4 -4
@@ -16,8 +16,8 @@
16 module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie) {
17 const currentTime = Date.now();
18 if (cookie) {
19 - if ((typeof cookie.expire == 'number') && (cookie.expire <= currentTime)) { delete req.query.nodeid; }
20 - else if (typeof cookie.nid == 'string') { req.query.nodeid = cookie.nid; }
19 + if ((typeof cookie.expire == 'number') && (cookie.expire <= currentTime)) { try { ws.close(); parent.parent.debug('relay', 'Relay: Expires cookie (' + req.clientIp + ')'); } catch (e) { console.log(e); } return; }
20 + if (typeof cookie.nid == 'string') { req.query.nodeid = cookie.nid; }
21 }
22 var obj = {};
23 obj.ws = ws;
@@ -301,7 +301,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
301 } else {
302 // Wait for other relay connection
303 ws._socket.pause(); // Hold traffic until the other connection
304 - parent.wsrelays[obj.id] = { peer1: obj, state: 1, timeout: setTimeout(function () { closeBothSides(); }, 30000) };
304 + parent.wsrelays[obj.id] = { peer1: obj, state: 1, timeout: setTimeout(closeBothSides, 30000) };
305 parent.parent.debug('relay', 'Relay holding: ' + obj.id + ' (' + obj.req.clientIp + ') ' + (obj.authenticated ? 'Authenticated' : ''));
306
307 // Check if a peer server has this connection
@@ -484,7 +484,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
484 }
485
486 // If this session has a expire time, setup the expire timer now.
487 - if (cookie && (typeof cookie.expire == 'number')) { obj.expireTimer = setTimeout(obj.close, cookie.expire - currentTime); }
487 + if (cookie && (typeof cookie.expire == 'number')) { obj.expireTimer = setTimeout(closeBothSides, cookie.expire - currentTime); }
488
489 // Mark this relay session as authenticated if this is the user end.
490 obj.authenticated = (user != null);