Fixed missing relay event logging.

This commit is contained in:
Ylian Saint-Hilaire 2019-08-01 15:44:08 -07:00
parent 74037723d5
commit 0ebb9a715c
2 changed files with 12 additions and 4 deletions

View File

@ -171,6 +171,9 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
if (user) {
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: user._id, username: parent.users[user._id].name, msg: 'Started relay session \"' + obj.id + '\" from ' + cleanRemoteAddr(obj.peer.ws._socket.remoteAddress) + ' to ' + cleanRemoteAddr(ws._socket.remoteAddress) };
parent.parent.DispatchEvent(['*', user._id], obj, event);
} else if (obj.peer.user) {
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: obj.peer.user._id, username: parent.users[obj.peer.user._id].name, msg: 'Started relay session \"' + obj.id + '\" from ' + cleanRemoteAddr(obj.peer.ws._socket.remoteAddress) + ' to ' + cleanRemoteAddr(ws._socket.remoteAddress) };
parent.parent.DispatchEvent(['*', obj.peer.user._id], obj, event);
}
} else {
// Connected already, drop (TODO: maybe we should re-connect?)
@ -245,9 +248,14 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
try { peer.ws._socket._parent.end(); } catch (e) { } // Hard disconnect
// Log the disconnection
if (user && ws.time) {
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: user._id, username: parent.users[user._id].name, msg: 'Ended relay session \"' + obj.id + '\" from ' + cleanRemoteAddr(obj.peer.ws._socket.remoteAddress) + ' to ' + cleanRemoteAddr(ws._socket.remoteAddress) + ', ' + Math.floor((Date.now() - ws.time) / 1000) + ' second(s)' };
parent.parent.DispatchEvent(['*', user._id], obj, event);
if (ws.time) {
if (user) {
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: user._id, username: parent.users[user._id].name, msg: 'Ended relay session \"' + obj.id + '\" from ' + cleanRemoteAddr(obj.peer.ws._socket.remoteAddress) + ' to ' + cleanRemoteAddr(ws._socket.remoteAddress) + ', ' + Math.floor((Date.now() - ws.time) / 1000) + ' second(s)' };
parent.parent.DispatchEvent(['*', user._id], obj, event);
} else if (peer.user) {
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: peer.user._id, username: parent.users[peer.user._id].name, msg: 'Ended relay session \"' + obj.id + '\" from ' + cleanRemoteAddr(obj.peer.ws._socket.remoteAddress) + ' to ' + cleanRemoteAddr(ws._socket.remoteAddress) + ', ' + Math.floor((Date.now() - ws.time) / 1000) + ' second(s)' };
parent.parent.DispatchEvent(['*', peer.user._id], obj, event);
}
}
// Aggressive peer cleanup

View File

@ -1,6 +1,6 @@
{
"name": "meshcentral",
"version": "0.3.9-a",
"version": "0.3.9-b",
"keywords": [
"Remote Management",
"Intel AMT",