diff --git a/agents/meshcore.js b/agents/meshcore.js index c23540bc..e698a65d 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -1069,7 +1069,11 @@ function handleServerCommand(data) { else if ((data.protocol == 'files') && (tunnels[i].protocol == 5)) { disconnect = true; } else if ((data.protocol == 'tcp') && (tunnels[i].tcpport != null)) { disconnect = true; } else if ((data.protocol == 'udp') && (tunnels[i].udpport != null)) { disconnect = true; } - if (disconnect) { if (tunnels[i].s != null) { tunnels[i].s.end(); } else { tunnels[i].end(); } } + if (disconnect) { + if (tunnels[i].s != null) { tunnels[i].s.end(); } else { tunnels[i].end(); } + + // TODO: Log tunnel disconnection + } } } break; diff --git a/meshuser.js b/meshuser.js index 88eb2fbd..6d2594d4 100644 --- a/meshuser.js +++ b/meshuser.js @@ -4848,6 +4848,16 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use if ((viewer.user._id == command.xuserid) && (viewer.guestName == command.guestname)) { viewersToClose.push(viewer); } // Only close viewers that match the userid and guestname if present. } for (var i = 0; i < viewersToClose.length; i++) { viewersToClose[i].close(); } // Close any viewers we need closed. + + // Log the desktop session disconnection + var targets = ['*', user._id, command.xuserid]; + const splitxuser = command.xuserid.split('/'); + var xusername = splitxuser[2]; + if (command.guestname != null) { xusername += '/' + command.guestname; } + var event = { etype: 'user', userid: user._id, username: user.name, nodeid: command.nodeid, xuserid: command.xuserid, action: 'endsession', msgid: 134, msgArgs: [xusername], msg: 'Disconnected desktop session of user ' + xusername, domain: domain.id }; + if (command.guestname != null) { event.guestname = command.guestname; } + if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. + parent.parent.DispatchEvent(targets, obj, event); }); break; diff --git a/views/default.handlebars b/views/default.handlebars index 04992619..82dafb9f 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -13354,7 +13354,11 @@ 130: "User notifications changed", 131: "Added device share {0} with unlimited time.", 132: "Turn on.", - 133: "Turn off." + 133: "Turn off.", + 134: "Disconnected desktop session of user {0}", + 135: "Disconnected terminal session of user {0}", + 136: "Disconnected files session of user {0}", + 137: "Disconnected routing session of user {0}" }; // Highlights the device being hovered