Fixed server exception.

Ylian Saint-Hilaire committed May 25, 2021 at 11:43 UTC 28c4a0ed5315bd6a2c7eb86b00a88f2c3bb0d56e
1 file changed +3
meshdesktopmultiplex.js
+3
@@ -1128,6 +1128,7 @@ function CreateMeshRelayEx2(parent, ws, req, domain, user, cookie) {
1128 if ((cookie != null) && (cookie.nodeid != null) && (cookie.tcpport != null) && (cookie.domainid != null)) {
1129 // We have routing instructions in the cookie, but first, check user access for this node.
1130 parent.db.Get(cookie.nodeid, function (err, docs) {
1131 + if (obj.req == null) return; // This connection was closed.
1132 if (docs.length == 0) { console.log('ERR: Node not found'); try { obj.close(); } catch (e) { } return; } // Disconnect websocket
1133 const node = docs[0];
1134
@@ -1146,6 +1147,7 @@ function CreateMeshRelayEx2(parent, ws, req, domain, user, cookie) {
1147 } else if ((obj.req.query.nodeid != null) && ((obj.req.query.tcpport != null) || (obj.req.query.udpport != null))) {
1148 // We have routing instructions in the URL arguments, but first, check user access for this node.
1149 parent.db.Get(obj.req.query.nodeid, function (err, docs) {
1150 + if (obj.req == null) return; // This connection was closed.
1151 if (docs.length == 0) { console.log('ERR: Node not found'); try { obj.close(); } catch (e) { } return; } // Disconnect websocket
1152 const node = docs[0];
1153
@@ -1171,6 +1173,7 @@ function CreateMeshRelayEx2(parent, ws, req, domain, user, cookie) {
1173 } else if ((cookie != null) && (cookie.nid != null) && (typeof cookie.r == 'number') && (typeof cookie.cf == 'number') && (typeof cookie.gn == 'string')) {
1174 // We have routing instructions in the cookie, but first, check user access for this node.
1175 parent.db.Get(cookie.nid, function (err, docs) {
1176 + if (obj.req == null) return; // This connection was closed.
1177 if (docs.length == 0) { console.log('ERR: Node not found'); try { obj.close(); } catch (e) { } return; } // Disconnect websocket
1178 const node = docs[0];
1179