From 28c4a0ed5315bd6a2c7eb86b00a88f2c3bb0d56e Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 25 May 2021 11:43:30 -0700 Subject: [PATCH] Fixed server exception. --- meshdesktopmultiplex.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/meshdesktopmultiplex.js b/meshdesktopmultiplex.js index 575efc61..da47d16e 100644 --- a/meshdesktopmultiplex.js +++ b/meshdesktopmultiplex.js @@ -1128,6 +1128,7 @@ function CreateMeshRelayEx2(parent, ws, req, domain, user, cookie) { if ((cookie != null) && (cookie.nodeid != null) && (cookie.tcpport != null) && (cookie.domainid != null)) { // We have routing instructions in the cookie, but first, check user access for this node. parent.db.Get(cookie.nodeid, function (err, docs) { + if (obj.req == null) return; // This connection was closed. if (docs.length == 0) { console.log('ERR: Node not found'); try { obj.close(); } catch (e) { } return; } // Disconnect websocket const node = docs[0]; @@ -1146,6 +1147,7 @@ function CreateMeshRelayEx2(parent, ws, req, domain, user, cookie) { } else if ((obj.req.query.nodeid != null) && ((obj.req.query.tcpport != null) || (obj.req.query.udpport != null))) { // We have routing instructions in the URL arguments, but first, check user access for this node. parent.db.Get(obj.req.query.nodeid, function (err, docs) { + if (obj.req == null) return; // This connection was closed. if (docs.length == 0) { console.log('ERR: Node not found'); try { obj.close(); } catch (e) { } return; } // Disconnect websocket const node = docs[0]; @@ -1171,6 +1173,7 @@ function CreateMeshRelayEx2(parent, ws, req, domain, user, cookie) { } else if ((cookie != null) && (cookie.nid != null) && (typeof cookie.r == 'number') && (typeof cookie.cf == 'number') && (typeof cookie.gn == 'string')) { // We have routing instructions in the cookie, but first, check user access for this node. parent.db.Get(cookie.nid, function (err, docs) { + if (obj.req == null) return; // This connection was closed. if (docs.length == 0) { console.log('ERR: Node not found'); try { obj.close(); } catch (e) { } return; } // Disconnect websocket const node = docs[0];