diff --git a/agents/meshcore.js b/agents/meshcore.js index e698a65d..a72ca575 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -602,6 +602,7 @@ function MeshServerLogEx(id, args, msg, state) { var msg = { action: 'log', msgid: id, msgArgs: args, msg: msg }; if (state) { if (state.userid) { msg.userid = state.userid; } + if (state.xuserid) { msg.xuserid = state.xuserid; } if (state.username) { msg.username = state.username; } if (state.sessionid) { msg.sessionid = state.sessionid; } if (state.remoteaddr) { msg.remoteaddr = state.remoteaddr; } @@ -1063,16 +1064,19 @@ function handleServerCommand(data) { if ((data.rights != 4294967295) && (data.xuserid != data.userid)) return; // This command requires full admin rights on the device or user self-closes it's own sessions for (var i in tunnels) { if ((tunnels[i].userid == data.xuserid) && (tunnels[i].guestname == data.guestname)) { - var disconnect = false; - if ((data.protocol == 'kvm') && (tunnels[i].protocol == 2)) { disconnect = true; } - else if ((data.protocol == 'terminal') && (tunnels[i].protocol == 1)) { disconnect = true; } - 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; } + var disconnect = false, msgid = 0; + if ((data.protocol == 'kvm') && (tunnels[i].protocol == 2)) { msgid = 134; disconnect = true; } + else if ((data.protocol == 'terminal') && (tunnels[i].protocol == 1)) { msgid = 135; disconnect = true; } + else if ((data.protocol == 'files') && (tunnels[i].protocol == 5)) { msgid = 136; disconnect = true; } + else if ((data.protocol == 'tcp') && (tunnels[i].tcpport != null)) { msgid = 137; disconnect = true; } + else if ((data.protocol == 'udp') && (tunnels[i].udpport != null)) { msgid = 137; disconnect = true; } if (disconnect) { if (tunnels[i].s != null) { tunnels[i].s.end(); } else { tunnels[i].end(); } - // TODO: Log tunnel disconnection + // Log tunnel disconnection + var xusername = data.xuserid.split('/')[2]; + if (data.guestname != null) { xusername += '/' + guestname; } + MeshServerLogEx(msgid, [xusername], "Forcibly disconnected session of user: " + xusername, data); } } } diff --git a/meshagent.js b/meshagent.js index 01be68e5..1b1568ae 100644 --- a/meshagent.js +++ b/meshagent.js @@ -1355,6 +1355,10 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { var loguser = parent.users[command.userid]; if (loguser) { event.userid = command.userid; event.username = loguser.name; targets.push(command.userid); } } + if (typeof command.xuserid == 'string') { + var xloguser = parent.users[command.xuserid]; + if (xloguser) { targets.push(command.xuserid); } + } if ((typeof command.sessionid == 'string') && (command.sessionid.length < 500)) { event.sessionid = command.sessionid; } parent.parent.DispatchEvent(targets, obj, event); } diff --git a/meshuser.js b/meshuser.js index 6f3ae20c..6771e352 100644 --- a/meshuser.js +++ b/meshuser.js @@ -4686,7 +4686,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use 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 }; + var event = { etype: 'user', userid: user._id, username: user.name, nodeid: command.nodeid, xuserid: command.xuserid, action: 'endsession', msgid: 134, msgArgs: [xusername], msg: 'Forcibly 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); diff --git a/views/default.handlebars b/views/default.handlebars index 82dafb9f..3a1af6fa 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -13355,10 +13355,10 @@ 131: "Added device share {0} with unlimited time.", 132: "Turn on.", 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}" + 134: "Forcibly disconnected desktop session of user {0}", + 135: "Forcibly disconnected terminal session of user {0}", + 136: "Forcibly disconnected files session of user {0}", + 137: "Forcibly disconnected routing session of user {0}" }; // Highlights the device being hovered