mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-02-12 19:11:51 +00:00
Added desktop session length into event log when multiplexor is used.
This commit is contained in:
parent
ce8b2a6bd8
commit
eb30d40e25
4 changed files with 16 additions and 11 deletions
1
db.js
1
db.js
|
@ -1167,7 +1167,6 @@ module.exports.CreateDB = function (parent, func) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
obj.GetEventsTimeRange = function (ids, domain, msgids, start, end, func) {
|
obj.GetEventsTimeRange = function (ids, domain, msgids, start, end, func) {
|
||||||
//obj.eventsfile.find({ domain: domain, $or: [{ ids: { $in: ids } }], msgid: { $in: msgids }, time: { $gte: start, $lte: end } }).project({ type: 0, _id: 0, domain: 0, ids: 0, node: 0 }).sort({ time: 1 }).toArray(func);
|
|
||||||
if (ids.indexOf('*') >= 0) {
|
if (ids.indexOf('*') >= 0) {
|
||||||
sqlDbQuery('SELECT doc FROM events WHERE ((domain = ?) AND (time BETWEEN ? AND ?)) ORDER BY time', [domain, start, end], func);
|
sqlDbQuery('SELECT doc FROM events WHERE ((domain = ?) AND (time BETWEEN ? AND ?)) ORDER BY time', [domain, start, end], func);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -119,6 +119,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
||||||
peer.overflow = false;
|
peer.overflow = false;
|
||||||
peer.sendQueue = [];
|
peer.sendQueue = [];
|
||||||
peer.paused = false;
|
peer.paused = false;
|
||||||
|
peer.startTime = Date.now();
|
||||||
|
|
||||||
// Add the user to the userids list if needed
|
// Add the user to the userids list if needed
|
||||||
if ((peer.user != null) && (obj.userIds.indexOf(peer.user._id) == -1)) { obj.userIds.push(peer.user._id); }
|
if ((peer.user != null) && (obj.userIds.indexOf(peer.user._id) == -1)) { obj.userIds.push(peer.user._id); }
|
||||||
|
@ -208,6 +209,14 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
||||||
if ((obj.viewersOverflowCount < obj.viewers.length) && (obj.recordingFileWriting == false) && obj.agent && (obj.agent.paused == true)) { obj.agent.paused = false; obj.agent.ws._socket.resume(); }
|
if ((obj.viewersOverflowCount < obj.viewers.length) && (obj.recordingFileWriting == false) && obj.agent && (obj.agent.paused == true)) { obj.agent.paused = false; obj.agent.ws._socket.resume(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log leaving the multiplex session
|
||||||
|
if (obj.startTime != null) { // Used to check if the agent has connected. If not, don't log this event since the session never really started.
|
||||||
|
//var event = { etype: 'relay', action: 'relaylog', domain: domain.id, nodeid: obj.nodeid, userid: peer.user._id, username: peer.user.name, msgid: 5, msg: "Left the desktop multiplex session", protocol: 2 };
|
||||||
|
const sessionSeconds = Math.floor((Date.now() - peer.startTime) / 1000);
|
||||||
|
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, nodeid: obj.nodeid, userid: peer.user._id, username: peer.user.name, msgid: 122, msgArgs: [sessionSeconds], msg: "Left the desktop multiplex session after " + sessionSeconds + " second(s).", protocol: 2 };
|
||||||
|
parent.parent.DispatchEvent(['*', obj.nodeid, peer.user._id, obj.meshid], obj, event);
|
||||||
|
}
|
||||||
|
|
||||||
// Aggressive clean up of the viewer
|
// Aggressive clean up of the viewer
|
||||||
delete peer.desktopPaused;
|
delete peer.desktopPaused;
|
||||||
delete peer.imageType;
|
delete peer.imageType;
|
||||||
|
@ -219,12 +228,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
||||||
delete peer.sending;
|
delete peer.sending;
|
||||||
delete peer.overflow;
|
delete peer.overflow;
|
||||||
delete peer.sendQueue;
|
delete peer.sendQueue;
|
||||||
|
delete peer.startTime;
|
||||||
// Log leaving the multiplex session
|
|
||||||
if (obj.startTime != null) {
|
|
||||||
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, nodeid: obj.nodeid, userid: peer.user._id, username: peer.user.name, msgid: 5, msg: "Left the desktop multiplex session", protocol: 2 };
|
|
||||||
parent.parent.DispatchEvent(['*', obj.nodeid, peer.user._id, obj.meshid], obj, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this is the last viewer, disconnect the agent
|
// If this is the last viewer, disconnect the agent
|
||||||
if ((obj.viewers != null) && (obj.viewers.length == 0) && (obj.agent != null)) { obj.agent.close(); dispose(); return true; }
|
if ((obj.viewers != null) && (obj.viewers.length == 0) && (obj.agent != null)) { obj.agent.close(); dispose(); return true; }
|
||||||
|
|
|
@ -5421,7 +5421,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||||
|
|
||||||
// Get the events in the time range
|
// Get the events in the time range
|
||||||
// MySQL or MariaDB query will ignore the MsgID filter.
|
// MySQL or MariaDB query will ignore the MsgID filter.
|
||||||
db.GetEventsTimeRange(ids, domain.id, [5, 10, 12], new Date(command.start * 1000), new Date(command.end * 1000), function (err, docs) {
|
db.GetEventsTimeRange(ids, domain.id, [5, 10, 11, 12, 122], new Date(command.start * 1000), new Date(command.end * 1000), function (err, docs) {
|
||||||
if (err != null) return;
|
if (err != null) return;
|
||||||
var data = { groups: {} };
|
var data = { groups: {} };
|
||||||
|
|
||||||
|
@ -5438,7 +5438,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||||
|
|
||||||
// Rows
|
// Rows
|
||||||
for (var i in docs) {
|
for (var i in docs) {
|
||||||
if ((docs[i].msgid != 5) && (docs[i].msgid != 10) && (docs[i].msgid != 12)) continue; // If MySQL or MariaDB query, we can't filter on MsgID, so we have to do it here.
|
if ((docs[i].msgid != 5) && (docs[i].msgid != 10) && (docs[i].msgid != 11) && (docs[i].msgid != 12) && (docs[i].msgid != 122)) continue; // If MySQL or MariaDB query, we can't filter on MsgID, so we have to do it here.
|
||||||
|
|
||||||
var entry = { time: docs[i].time.valueOf() };
|
var entry = { time: docs[i].time.valueOf() };
|
||||||
|
|
||||||
|
@ -5448,7 +5448,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||||
entry.protocol = docs[i].protocol;
|
entry.protocol = docs[i].protocol;
|
||||||
|
|
||||||
// Session length
|
// Session length
|
||||||
if (((docs[i].msgid == 10) || (docs[i].msgid == 12)) && (docs[i].msgArgs != null) && (typeof docs[i].msgArgs == 'object') && (typeof docs[i].msgArgs[3] == 'number')) { entry.length = docs[i].msgArgs[3]; }
|
if (((docs[i].msgid >= 10) && (docs[i].msgid <= 12)) && (docs[i].msgArgs != null) && (typeof docs[i].msgArgs == 'object') && (typeof docs[i].msgArgs[3] == 'number')) { entry.length = docs[i].msgArgs[3]; }
|
||||||
|
else if ((docs[i].msgid == 122) && (docs[i].msgArgs != null) && (typeof docs[i].msgArgs == 'object') && (typeof docs[i].msgArgs[0] == 'number')) { entry.length = docs[i].msgArgs[0]; }
|
||||||
|
|
||||||
if (command.groupBy == 1) { // Add entry to per user group
|
if (command.groupBy == 1) { // Add entry to per user group
|
||||||
if (data.groups[docs[i].userid] == null) { data.groups[docs[i].userid] = { entries: [] }; }
|
if (data.groups[docs[i].userid] == null) { data.groups[docs[i].userid] = { entries: [] }; }
|
||||||
|
|
|
@ -12887,7 +12887,8 @@
|
||||||
118: "This agent has an outstated certificate validation mechanism, consider updating.",
|
118: "This agent has an outstated certificate validation mechanism, consider updating.",
|
||||||
119: "This agent is using insecure tunnels, consider updating.",
|
119: "This agent is using insecure tunnels, consider updating.",
|
||||||
120: "Started local relay session \"{0}\", protocol {1} to {2}",
|
120: "Started local relay session \"{0}\", protocol {1} to {2}",
|
||||||
121: "Ended local relay session \"{0}\", protocol {1} to {2}, {3} second(s)"
|
121: "Ended local relay session \"{0}\", protocol {1} to {2}, {3} second(s)",
|
||||||
|
122: "Left the desktop multiplex session after {0} second(s).",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Highlights the device being hovered
|
// Highlights the device being hovered
|
||||||
|
|
Loading…
Reference in a new issue