Fixed cross-domain event leakage.
Ylian Saint-Hilaire committed
Apr 20, 2020 at 13:11 UTC
9c7aeaef21531c2ef032b404aab7aa296bdb52f2
2 files changed
+4
-4
meshcentral.js
+3
-3
@@ -1634,7 +1634,7 @@ function CreateMeshCentralServer(config, args) {
1634
1635
// Event any changes on this server only
1636
if ((newConnectivity != oldPowerState) || (newPowerState != oldPowerState)) {
1637
- obj.DispatchEvent(obj.webserver.CreateNodeDispatchTargets(meshid, nodeid), obj, { action: 'nodeconnect', meshid: meshid, nodeid: nodeid, conn: newConnectivity, pwr: newPowerState, nolog: 1, nopeers: 1 });
1637
+ obj.DispatchEvent(obj.webserver.CreateNodeDispatchTargets(meshid, nodeid), obj, { action: 'nodeconnect', meshid: meshid, nodeid: nodeid, domain: nodeid.split('/')[1], conn: newConnectivity, pwr: newPowerState, nolog: 1, nopeers: 1 });
1638
}
1639
}
1640
};
@@ -1683,7 +1683,7 @@ function CreateMeshCentralServer(config, args) {
1683
1684
// Event the node connection change
1685
if (eventConnectChange == 1) {
1686
- obj.DispatchEvent(obj.webserver.CreateNodeDispatchTargets(meshid, nodeid), obj, { action: 'nodeconnect', meshid: meshid, nodeid: nodeid, conn: state.connectivity, pwr: state.powerState, ct: connectTime, nolog: 1, nopeers: 1 });
1686
+ obj.DispatchEvent(obj.webserver.CreateNodeDispatchTargets(meshid, nodeid), obj, { action: 'nodeconnect', meshid: meshid, nodeid: nodeid, domain: nodeid.split('/')[1], conn: state.connectivity, pwr: state.powerState, ct: connectTime, nolog: 1, nopeers: 1 });
1687
}
1688
} else {
1689
// Multi server mode
@@ -1757,7 +1757,7 @@ function CreateMeshCentralServer(config, args) {
1757
}
1758
1759
// Event the node connection change
1760
- if (eventConnectChange == 1) { obj.DispatchEvent(obj.webserver.CreateNodeDispatchTargets(meshid, nodeid), obj, { action: 'nodeconnect', meshid: meshid, nodeid: nodeid, conn: state.connectivity, pwr: state.powerState, nolog: 1, nopeers: 1 }); }
1760
+ if (eventConnectChange == 1) { obj.DispatchEvent(obj.webserver.CreateNodeDispatchTargets(meshid, nodeid), obj, { action: 'nodeconnect', meshid: meshid, nodeid: nodeid, domain: nodeid.split('/')[1], conn: state.connectivity, pwr: state.powerState, nolog: 1, nopeers: 1 }); }
1761
} else {
1762
// Multi server mode
1763
meshuser.js
+1
-1
@@ -268,7 +268,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
268
269
// Handle events
270
ws.HandleEvent = function (source, event, ids, id) {
271
- if (!event.domain || event.domain == domain.id) {
271
+ if ((event.domain == null) || (event.domain == domain.id)) {
272
try {
273
if (event == 'close') { try { delete req.session; } catch (ex) { } obj.close(); }
274
else if (event == 'resubscribe') { user.subscriptions = parent.subscribe(user._id, ws); }