mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-02-12 11:01:52 +00:00
MeshRelay fix for #3118
This commit is contained in:
parent
f44faa67b4
commit
f918ae537c
1 changed files with 13 additions and 9 deletions
22
meshrelay.js
22
meshrelay.js
|
@ -953,17 +953,21 @@ function CreateMeshRelayEx(parent, ws, req, domain, user, cookie) {
|
||||||
return obj;
|
return obj;
|
||||||
} else {
|
} else {
|
||||||
// No routing needed. Just check permissions and fill in the device nodeid and meshid.
|
// No routing needed. Just check permissions and fill in the device nodeid and meshid.
|
||||||
parent.db.Get(obj.req.query.nodeid, function (err, docs) {
|
if ((obj.req.query.nodeid != null) && (obj.req.query.nodeid.startsWith('node/'))) {
|
||||||
if (docs.length == 0) { console.log('ERR: Node not found'); try { obj.close(); } catch (e) { } return; } // Disconnect websocket
|
var nodeSplit = obj.req.query.nodeid.split('/');
|
||||||
const node = docs[0];
|
if ((nodeSplit.length != 3) || (nodeSplit[1] != domain.id)) { console.log('ERR: Invalid NodeID'); try { obj.close(); } catch (e) { } return; }
|
||||||
|
parent.db.Get(obj.req.query.nodeid, function (err, docs) {
|
||||||
|
if (docs.length == 0) { console.log('ERR: Node not found'); try { obj.close(); } catch (e) { } return; } // Disconnect websocket
|
||||||
|
const node = docs[0];
|
||||||
|
|
||||||
// Check if this user has permission to manage this computer
|
// Check if this user has permission to manage this computer
|
||||||
if ((parent.GetNodeRights(user, node.meshid, node._id) & MESHRIGHT_REMOTECONTROL) == 0) { console.log('ERR: Access denied (2)'); try { obj.close(); } catch (e) { } return; }
|
if ((parent.GetNodeRights(user, node.meshid, node._id) & MESHRIGHT_REMOTECONTROL) == 0) { console.log('ERR: Access denied (2)'); try { obj.close(); } catch (e) { } return; }
|
||||||
|
|
||||||
// Set nodeid and meshid
|
// Set nodeid and meshid
|
||||||
obj.nodeid = node._id;
|
obj.nodeid = node._id;
|
||||||
obj.meshid = node.meshid;
|
obj.meshid = node.meshid;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue