mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-24 22:25:52 -05:00
Added session disconnection log entries, #3437
This commit is contained in:
parent
188b6c1b7c
commit
c14aba06d4
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user