Fixed server exception.

This commit is contained in:
Ylian Saint-Hilaire 2021-05-25 11:43:30 -07:00
parent b9f34381e9
commit 28c4a0ed53
1 changed files with 3 additions and 0 deletions

View File

@ -1128,6 +1128,7 @@ function CreateMeshRelayEx2(parent, ws, req, domain, user, cookie) {
if ((cookie != null) && (cookie.nodeid != null) && (cookie.tcpport != null) && (cookie.domainid != null)) { 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. // We have routing instructions in the cookie, but first, check user access for this node.
parent.db.Get(cookie.nodeid, function (err, docs) { 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 if (docs.length == 0) { console.log('ERR: Node not found'); try { obj.close(); } catch (e) { } return; } // Disconnect websocket
const node = docs[0]; 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))) { } 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. // 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) { 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 if (docs.length == 0) { console.log('ERR: Node not found'); try { obj.close(); } catch (e) { } return; } // Disconnect websocket
const node = docs[0]; 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')) { } 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. // We have routing instructions in the cookie, but first, check user access for this node.
parent.db.Get(cookie.nid, function (err, docs) { 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 if (docs.length == 0) { console.log('ERR: Node not found'); try { obj.close(); } catch (e) { } return; } // Disconnect websocket
const node = docs[0]; const node = docs[0];