mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-01-12 15:33:20 -05:00
More lastconnect improvements, added meshid.
This commit is contained in:
parent
880be2b41b
commit
a45febe864
@ -2139,7 +2139,7 @@ function CreateMeshCentralServer(config, args) {
|
||||
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 });
|
||||
|
||||
// Save indication of node connection change
|
||||
const lc = { _id: 'lc' + nodeid, type: 'lastconnect', domain: nodeid.split('/')[1], time: Date.now(), cause: 1, connectType: connectType, serverid: obj.serverId };
|
||||
const lc = { _id: 'lc' + nodeid, type: 'lastconnect', domain: nodeid.split('/')[1], meshid: meshid, time: Date.now(), cause: 1, connectType: connectType, serverid: obj.serverId };
|
||||
if (extraInfo && extraInfo.remoteaddrport) { lc.addr = extraInfo.remoteaddrport; }
|
||||
obj.db.Set(lc);
|
||||
}
|
||||
@ -2182,7 +2182,7 @@ function CreateMeshCentralServer(config, args) {
|
||||
|
||||
// Save indication of node connection change
|
||||
if (serverid == obj.serverId) {
|
||||
const lc = { _id: 'lc' + nodeid, type: 'lastconnect', domain: nodeid.split('/')[1], time: Date.now(), cause: 1, connectType: connectType, serverid: obj.serverId };
|
||||
const lc = { _id: 'lc' + nodeid, type: 'lastconnect', domain: nodeid.split('/')[1], meshid: meshid, time: Date.now(), cause: 1, connectType: connectType, serverid: obj.serverId };
|
||||
if (extraInfo && extraInfo.remoteaddrport) { lc.addr = extraInfo.remoteaddrport; }
|
||||
obj.db.Set(lc);
|
||||
}
|
||||
@ -2210,7 +2210,7 @@ function CreateMeshCentralServer(config, args) {
|
||||
state.connectivity -= connectType;
|
||||
|
||||
// Save indication of node connection change
|
||||
const lc = { _id: 'lc' + nodeid, type: 'lastconnect', domain: nodeid.split('/')[1], time: Date.now(), cause: 0, connectType: connectType, serverid: obj.serverId };
|
||||
const lc = { _id: 'lc' + nodeid, type: 'lastconnect', domain: nodeid.split('/')[1], meshid: meshid, time: Date.now(), cause: 0, connectType: connectType, serverid: obj.serverId };
|
||||
if (extraInfo && extraInfo.remoteaddrport) { lc.addr = extraInfo.remoteaddrport; }
|
||||
obj.db.Set(lc);
|
||||
|
||||
@ -2250,7 +2250,7 @@ function CreateMeshCentralServer(config, args) {
|
||||
|
||||
// Save indication of node connection change
|
||||
if (serverid == obj.serverId) {
|
||||
const lc = { _id: 'lc' + nodeid, type: 'lastconnect', domain: nodeid.split('/')[1], time: Date.now(), cause: 0, connectType: connectType, serverid: obj.serverId };
|
||||
const lc = { _id: 'lc' + nodeid, type: 'lastconnect', domain: nodeid.split('/')[1], meshid: meshid, time: Date.now(), cause: 0, connectType: connectType, serverid: obj.serverId };
|
||||
if (extraInfo && extraInfo.remoteaddrport) { lc.addr = extraInfo.remoteaddrport; }
|
||||
obj.db.Set(lc);
|
||||
}
|
||||
|
@ -3211,6 +3211,11 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
}
|
||||
}
|
||||
|
||||
// Update lastconnect meshid for this node
|
||||
db.Get('lc' + node._id, function (err, xnodes) {
|
||||
if ((xnodes != null) && (xnodes.length == 1) && (xnodes[0].meshid != command.meshid)) { xnodes[0].meshid = command.meshid; db.Set(xnodes[0]); }
|
||||
});
|
||||
|
||||
// Event the node change
|
||||
var newMesh = parent.meshes[command.meshid];
|
||||
var event = { etype: 'node', userid: user._id, username: user.name, action: 'nodemeshchange', nodeid: node._id, node: node, oldMeshId: oldMeshId, newMeshId: command.meshid, msgid: 85, msgArgs: [node.name, newMesh.name], msg: 'Moved device ' + node.name + ' to group ' + newMesh.name, domain: domain.id };
|
||||
@ -5284,7 +5289,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
|
||||
// Merge any last connection information
|
||||
const lc = lastConnects['lc' + results[i].node._id];
|
||||
if (lc != null) { delete lc._id; delete lc.type; delete lc.domain; results[i].lastConnect = lc; }
|
||||
if (lc != null) { delete lc._id; delete lc.type;; delete lc.meshid; delete lc.domain; results[i].lastConnect = lc; }
|
||||
}
|
||||
|
||||
var output = null;
|
||||
|
Loading…
Reference in New Issue
Block a user