Started work on internalization of event log.

This commit is contained in:
Ylian Saint-Hilaire 2020-09-08 18:59:58 -07:00
parent 8726254e36
commit 6aabbf9dc9
10 changed files with 185 additions and 38429 deletions

View File

@ -366,6 +366,19 @@ function createMeshCore(agent) {
if (state.userid) { msg.userid = state.userid; }
if (state.username) { msg.username = state.username; }
if (state.sessionid) { msg.sessionid = state.sessionid; }
if (state.remoteaddr) { msg.remoteaddr = state.remoteaddr; }
}
mesh.SendCommand(msg);
}
// Add to the server event log, use internationalized events
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.username) { msg.username = state.username; }
if (state.sessionid) { msg.sessionid = state.sessionid; }
if (state.remoteaddr) { msg.remoteaddr = state.remoteaddr; }
}
mesh.SendCommand(msg);
}
@ -725,7 +738,7 @@ function createMeshCore(agent) {
switch (data.type) {
case 'console': { // Process a console command
if (data.value && data.sessionid) {
MeshServerLog("Processing console command: " + data.value, data);
MeshServerLogEx(17, [data.value], "Processing console command: " + data.value, data);
var args = splitArgs(data.value);
processConsoleCommand(args[0].toLowerCase(), parseArgs(args), data.rights, data.sessionid);
}
@ -776,7 +789,7 @@ function createMeshCore(agent) {
case 'messagebox': {
// Display a message box
if (data.title && data.msg) {
MeshServerLog("Displaying message box, title=" + data.title + ", message=" + data.msg, data);
MeshServerLogEx(18, [data.title, data.msg], "Displaying message box, title=" + data.title + ", message=" + data.msg, data);
data.msg = data.msg.split('\r').join('\\r').split('\n').join('\\n');
try { require('message-box').create(data.title, data.msg, 120); } catch (ex) { }
}
@ -794,7 +807,7 @@ function createMeshCore(agent) {
case 'pskill': {
// Kill a process
if (data.value) {
MeshServerLog("Killing process " + data.value, data);
MeshServerLogEx(19, [data.value], "Killing process " + data.value, data);
try { process.kill(data.value); } catch (e) { sendConsoleText("pskill: " + JSON.stringify(e)); }
}
break;
@ -867,7 +880,7 @@ function createMeshCore(agent) {
}
case 'openUrl': {
// Open a local web browser and return success/fail
MeshServerLog("Opening: " + data.url, data);
MeshServerLogEx(20, [data.url], "Opening: " + data.url, data);
sendConsoleText("OpenURL: " + data.url);
if (data.url) { mesh.SendCommand({ action: 'msg', type: 'openUrl', url: data.url, sessionid: data.sessionid, success: (openUserDesktopUrl(data.url) != null) }); }
break;
@ -878,14 +891,14 @@ function createMeshCore(agent) {
if (require('MeshAgent').isService) {
require('clipboard').dispatchRead().then(function (str) {
if (str) {
MeshServerLog("Getting clipboard content, " + str.length + " byte(s)", data);
MeshServerLogEx(21, [str.length], "Getting clipboard content, " + str.length + " byte(s)", data);
mesh.SendCommand({ action: 'msg', type: 'getclip', sessionid: data.sessionid, data: str, tag: data.tag });
}
});
} else {
require("clipboard").read().then(function (str) {
if (str) {
MeshServerLog("Getting clipboard content, " + str.length + " byte(s)", data);
MeshServerLogEx(21, [str.length], "Getting clipboard content, " + str.length + " byte(s)", data);
mesh.SendCommand({ action: 'msg', type: 'getclip', sessionid: data.sessionid, data: str, tag: data.tag });
}
});
@ -896,7 +909,7 @@ function createMeshCore(agent) {
// Set the load clipboard to a user value
//sendConsoleText('setClip: ' + JSON.stringify(data));
if (typeof data.data == 'string') {
MeshServerLog("Setting clipboard content, " + data.data.length + " byte(s)", data);
MeshServerLogEx(22, [data.data.length], "Setting clipboard content, " + data.data.length + " byte(s)", data);
if (require('MeshAgent').isService) { require('clipboard').dispatchWrite(data.data); } else { require("clipboard")(data.data); } // Set the clipboard
mesh.SendCommand({ action: 'msg', type: 'setclip', sessionid: data.sessionid, success: true });
}
@ -919,7 +932,7 @@ function createMeshCore(agent) {
}
case 'acmactivate': {
if (amt != null) {
MeshServerLog("Attempting Intel AMT ACM mode activation", data);
MeshServerLogEx(23, null, "Attempting Intel AMT ACM mode activation", data);
amt.setAcmResponse(data);
}
break;
@ -932,7 +945,7 @@ function createMeshCore(agent) {
}
case 'runcommands': {
if (mesh.cmdchild != null) { sendConsoleText("Run commands can't execute, already busy."); break; }
MeshServerLog("Running commands", data);
MeshServerLogEx(24, null, "Running commands", data);
sendConsoleText("Run commands: " + data.cmds);
if (process.platform == 'win32') {
if (data.type == 1) {
@ -978,7 +991,7 @@ function createMeshCore(agent) {
var forced = 0;
if (data.forced == 1) { forced = 1; }
data.actiontype = parseInt(data.actiontype);
MeshServerLog("Performing power action=" + data.actiontype + ", forced=" + forced, data);
MeshServerLogEx(25, [data.actiontype, forced], "Performing power action=" + data.actiontype + ", forced=" + forced, data);
sendConsoleText("Performing power action=" + data.actiontype + ", forced=" + forced + '.');
var r = mesh.ExecPowerState(data.actiontype, forced);
sendConsoleText("ExecPowerState returned code: " + r);
@ -993,7 +1006,7 @@ function createMeshCore(agent) {
case 'toast': {
// Display a toast message
if (data.title && data.msg) {
MeshServerLog("Displaying toast message, title=" + data.title + ", message=" + data.msg, data);
MeshServerLogEx(26, [data.title, data.msg], "Displaying toast message, title=" + data.title + ", message=" + data.msg, data);
data.msg = data.msg.split('\r').join('\\r').split('\n').join('\\n');
try { require('toaster').Toast(data.title, data.msg); } catch (ex) { }
}
@ -1002,7 +1015,7 @@ function createMeshCore(agent) {
case 'openUrl': {
// Open a local web browser and return success/fail
//sendConsoleText('OpenURL: ' + data.url);
MeshServerLog("Opening: " + data.url, data);
MeshServerLogEx(20, [data.url], "Opening: " + data.url, data);
if (data.url) { mesh.SendCommand({ action: 'openUrl', url: data.url, sessionid: data.sessionid, success: (openUserDesktopUrl(data.url) != null) }); }
break;
}
@ -1428,7 +1441,7 @@ function createMeshCore(agent) {
function ()
{
// Success
MeshServerLog("Local user accepted remote terminal request (" + this.retPromise.httprequest.remoteaddr + ")", this.retPromise.that.httprequest);
MeshServerLogEx(27, null, "Local user accepted remote terminal request (" + this.retPromise.httprequest.remoteaddr + ")", this.retPromise.that.httprequest);
this.retPromise.that.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null, msgid: 0 }));
this.retPromise._consent = null;
this.retPromise._res();
@ -1436,7 +1449,7 @@ function createMeshCore(agent) {
function (e)
{
// Denied
MeshServerLog("Local user rejected remote terminal request (" + this.retPromise.that.httprequest.remoteaddr + ")", this.retPromise.that.httprequest);
MeshServerLogEx(28, null, "Local user rejected remote terminal request (" + this.retPromise.that.httprequest.remoteaddr + ")", this.retPromise.that.httprequest);
this.retPromise.that.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString(), msgid: 2 }));
this.retPromise._rej(e.toString());
});
@ -1742,7 +1755,7 @@ function createMeshCore(agent) {
this.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')(this.httprequest.privacybartext.replace('{0}', this.httprequest.desktop.kvm.users.join(', ')).replace('{1}', this.httprequest.desktop.kvm.rusers.join(', ')), require('MeshAgent')._tsid);
this.httprequest.desktop.kvm.connectionBar.httprequest = this.httprequest;
this.httprequest.desktop.kvm.connectionBar.on('close', function () {
MeshServerLog("Remote Desktop Connection forcefully closed by local user (" + this.httprequest.remoteaddr + ")", this.httprequest);
MeshServerLogEx(29, null, "Remote Desktop Connection forcefully closed by local user (" + this.httprequest.remoteaddr + ")", this.httprequest);
for (var i in this.httprequest.desktop.kvm._pipedStreams) {
this.httprequest.desktop.kvm._pipedStreams[i].end();
}
@ -1795,7 +1808,7 @@ function createMeshCore(agent) {
{
// Success
this.ws._consentpromise = null;
MeshServerLog("Starting remote desktop after local user accepted (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
MeshServerLogEx(30, null, "Starting remote desktop after local user accepted (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null, msgid: 0 }));
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 1)) {
// User Notifications is required
@ -1814,17 +1827,17 @@ function createMeshCore(agent) {
}
try {
this.ws.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')(this.ws.httprequest.privacybartext.replace('{0}', this.ws.httprequest.desktop.kvm.users.join(', ')).replace('{1}', this.ws.httprequest.desktop.kvm.rusers.join(', ')), require('MeshAgent')._tsid);
MeshServerLog("Remote Desktop Connection Bar Activated/Updated (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
MeshServerLogEx(31, null, "Remote Desktop Connection Bar Activated/Updated (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
}
catch (xx) {
if (process.platform != 'darwin') {
MeshServerLog("Remote Desktop Connection Bar Failed or Not Supported (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
MeshServerLogEx(32, null, "Remote Desktop Connection Bar Failed or Not Supported (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
}
}
if (this.ws.httprequest.desktop.kvm.connectionBar) {
this.ws.httprequest.desktop.kvm.connectionBar.httprequest = this.ws.httprequest;
this.ws.httprequest.desktop.kvm.connectionBar.on('close', function () {
MeshServerLog("Remote Desktop Connection forcefully closed by local user (" + this.httprequest.remoteaddr + ")", this.httprequest);
MeshServerLogEx(33, null, "Remote Desktop Connection forcefully closed by local user (" + this.httprequest.remoteaddr + ")", this.httprequest);
for (var i in this.httprequest.desktop.kvm._pipedStreams) {
this.httprequest.desktop.kvm._pipedStreams[i].end();
}
@ -1839,14 +1852,14 @@ function createMeshCore(agent) {
{
// User Consent Denied/Failed
this.ws._consentpromise = null;
MeshServerLog("Failed to start remote desktop after local user rejected (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
MeshServerLogEx(34, null, "Failed to start remote desktop after local user rejected (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
this.ws.end(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString(), msgid: 2 }));
});
} else {
// User Consent Prompt is not required
if (this.httprequest.consent && (this.httprequest.consent & 1)) {
// User Notifications is required
MeshServerLog("Started remote desktop with toast notification (" + this.httprequest.remoteaddr + ")", this.httprequest);
MeshServerLogEx(35, null, "Started remote desktop with toast notification (" + this.httprequest.remoteaddr + ")", this.httprequest);
var notifyMessage = this.httprequest.realname + " started a remote desktop session.", notifyTitle = "MeshCentral";
if (this.httprequest.soptions != null) {
if (this.httprequest.soptions.notifyTitle != null) { notifyTitle = this.httprequest.soptions.notifyTitle; }
@ -1854,7 +1867,7 @@ function createMeshCore(agent) {
}
try { require('toaster').Toast(notifyTitle, notifyMessage, tsid); } catch (ex) { }
} else {
MeshServerLog("Started remote desktop without notification (" + this.httprequest.remoteaddr + ")", this.httprequest);
MeshServerLogEx(36, null, "Started remote desktop without notification (" + this.httprequest.remoteaddr + ")", this.httprequest);
}
if (this.httprequest.consent && (this.httprequest.consent & 0x40)) {
// Connection Bar is required
@ -1864,15 +1877,15 @@ function createMeshCore(agent) {
}
try {
this.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')(this.httprequest.privacybartext.replace('{0}', this.httprequest.desktop.kvm.rusers.join(', ')).replace('{1}', this.httprequest.desktop.kvm.users.join(', ')), require('MeshAgent')._tsid);
MeshServerLog("Remote Desktop Connection Bar Activated/Updated (" + this.httprequest.remoteaddr + ")", this.httprequest);
MeshServerLogEx(37, null, "Remote Desktop Connection Bar Activated/Updated (" + this.httprequest.remoteaddr + ")", this.httprequest);
}
catch (xx) {
MeshServerLog("Remote Desktop Connection Bar Failed or not Supported (" + this.httprequest.remoteaddr + ")", this.httprequest);
MeshServerLogEx(38, null, "Remote Desktop Connection Bar Failed or not Supported (" + this.httprequest.remoteaddr + ")", this.httprequest);
}
if (this.httprequest.desktop.kvm.connectionBar) {
this.httprequest.desktop.kvm.connectionBar.httprequest = this.httprequest;
this.httprequest.desktop.kvm.connectionBar.on('close', function () {
MeshServerLog("Remote Desktop Connection forcefully closed by local user (" + this.httprequest.remoteaddr + ")", this.httprequest);
MeshServerLogEx(39, null, "Remote Desktop Connection forcefully closed by local user (" + this.httprequest.remoteaddr + ")", this.httprequest);
for (var i in this.httprequest.desktop.kvm._pipedStreams) {
this.httprequest.desktop.kvm._pipedStreams[i].end();
}
@ -1937,7 +1950,7 @@ function createMeshCore(agent) {
{
// Success
this.ws._consentpromise = null;
MeshServerLog("Starting remote files after local user accepted (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
MeshServerLogEx(40, null, "Starting remote files after local user accepted (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null }));
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 4)) {
// User Notifications is required
@ -1954,14 +1967,14 @@ function createMeshCore(agent) {
{
// User Consent Denied/Failed
this.ws._consentpromise = null;
MeshServerLog("Failed to start remote files after local user rejected (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
MeshServerLogEx(41, null, "Failed to start remote files after local user rejected (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
this.ws.end(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString(), msgid: 2 }));
});
} else {
// User Consent Prompt is not required
if (this.httprequest.consent && (this.httprequest.consent & 4)) {
// User Notifications is required
MeshServerLog("Started remote files with toast notification (" + this.httprequest.remoteaddr + ")", this.httprequest);
MeshServerLogEx(42, null, "Started remote files with toast notification (" + this.httprequest.remoteaddr + ")", this.httprequest);
var notifyMessage = this.httprequest.realname + " started a remote file session.", notifyTitle = "MeshCentral";
if (this.httprequest.soptions != null) {
if (this.httprequest.soptions.notifyTitle != null) { notifyTitle = this.httprequest.soptions.notifyTitle; }
@ -1969,7 +1982,7 @@ function createMeshCore(agent) {
}
try { require('toaster').Toast(notifyTitle, notifyMessage); } catch (ex) { }
} else {
MeshServerLog("Started remote files without notification (" + this.httprequest.remoteaddr + ")", this.httprequest);
MeshServerLogEx(43, null, "Started remote files without notification (" + this.httprequest.remoteaddr + ")", this.httprequest);
}
this.resume();
}
@ -2031,7 +2044,7 @@ function createMeshCore(agent) {
case 'mkdir': {
// Create a new empty folder
fs.mkdirSync(cmd.path);
MeshServerLog("Create folder: \"" + cmd.path + "\"", this.httprequest);
MeshServerLogEx(44, [cmd.path], "Create folder: \"" + cmd.path + "\"", this.httprequest);
break;
}
case 'rm': {
@ -2040,9 +2053,13 @@ function createMeshCore(agent) {
var p = obj.path.join(cmd.path, cmd.delfiles[i]), delcount = 0;
try { delcount = deleteFolderRecursive(p, cmd.rec); } catch (e) { }
if ((delcount == 1) && !cmd.rec) {
MeshServerLog("Delete: \"" + p + "\"", this.httprequest);
MeshServerLogEx(45, [p], "Delete: \"" + p + "\"", this.httprequest);
} else {
MeshServerLog((cmd.rec ? "Delete recursive: \"" : "Delete: \"") + p + "\", " + delcount + " element(s) removed", this.httprequest);
if (cmd.rec) {
MeshServerLogEx(46, [p, delcount], "Delete recursive: \"" + p + "\", " + delcount + " element(s) removed", this.httprequest);
} else {
MeshServerLogEx(47, [p, delcount], "Delete: \"" + p + "\", " + delcount + " element(s) removed", this.httprequest);
}
}
}
break;
@ -2062,7 +2079,7 @@ function createMeshCore(agent) {
// Rename a file or folder
var oldfullpath = obj.path.join(cmd.path, cmd.oldname);
var newfullpath = obj.path.join(cmd.path, cmd.newname);
MeshServerLog('Rename: \"' + oldfullpath + '\" to \"' + cmd.newname + '\"', this.httprequest);
MeshServerLogEx(48, [oldfullpath, cmd.newname], 'Rename: \"' + oldfullpath + '\" to \"' + cmd.newname + '\"', this.httprequest);
try { fs.renameSync(oldfullpath, newfullpath); } catch (e) { console.log(e); }
break;
}
@ -2077,7 +2094,7 @@ function createMeshCore(agent) {
if ((process.cwd() != '//') && fs.existsSync(process.cwd() + 'core')) { cmd.path = process.cwd() + 'core'; }
}
}
MeshServerLog('Download: \"' + cmd.path + '\"', this.httprequest);
MeshServerLogEx(49, [cmd.path], 'Download: \"' + cmd.path + '\"', this.httprequest);
if ((cmd.path == null) || (this.filedownload != null)) { this.write({ action: 'download', sub: 'cancel', id: this.filedownload.id }); delete this.filedownload; }
this.filedownload = { id: cmd.id, path: cmd.path, ptr: 0 }
try { this.filedownload.f = fs.openSync(this.filedownload.path, 'rbN'); } catch (e) { this.write({ action: 'download', sub: 'cancel', id: this.filedownload.id }); delete this.filedownload; }
@ -2124,7 +2141,7 @@ function createMeshCore(agent) {
if (cmd.path == undefined) break;
var filepath = cmd.name ? obj.path.join(cmd.path, cmd.name) : cmd.path;
this.httprequest.uploadFilePath = filepath;
MeshServerLog('Upload: \"' + filepath + '\"', this.httprequest);
MeshServerLogEx(50, [filepath], 'Upload: \"' + filepath + '\"', this.httprequest);
try { this.httprequest.uploadFile = fs.openSync(filepath, 'wbN'); } catch (e) { this.write(Buffer.from(JSON.stringify({ action: 'uploaderror', reqid: cmd.reqid }))); break; }
this.httprequest.uploadFileid = cmd.reqid;
if (this.httprequest.uploadFile) { this.write(Buffer.from(JSON.stringify({ action: 'uploadstart', reqid: this.httprequest.uploadFileid }))); }
@ -2157,7 +2174,7 @@ function createMeshCore(agent) {
// Copy a bunch of files from scpath to dspath
for (var i in cmd.names) {
var sc = obj.path.join(cmd.scpath, cmd.names[i]), ds = obj.path.join(cmd.dspath, cmd.names[i]);
MeshServerLog('Copy: \"' + sc + '\" to \"' + ds + '\"', this.httprequest);
MeshServerLogEx(51, [sc, ds], 'Copy: \"' + sc + '\" to \"' + ds + '\"', this.httprequest);
if (sc != ds) { try { fs.copyFileSync(sc, ds); } catch (e) { } }
}
break;
@ -2166,7 +2183,7 @@ function createMeshCore(agent) {
// Move a bunch of files from scpath to dspath
for (var i in cmd.names) {
var sc = obj.path.join(cmd.scpath, cmd.names[i]), ds = obj.path.join(cmd.dspath, cmd.names[i]);
MeshServerLog('Move: \"' + sc + '\" to \"' + ds + '\"', this.httprequest);
MeshServerLogEx(52, [sc, ds], 'Move: \"' + sc + '\" to \"' + ds + '\"', this.httprequest);
if (sc != ds) { try { fs.copyFileSync(sc, ds); fs.unlinkSync(sc); } catch (e) { } }
}
break;
@ -2279,7 +2296,7 @@ function createMeshCore(agent) {
// Lock the current user out of the desktop
try {
if (process.platform == 'win32') {
MeshServerLog("Locking remote user out of desktop", ws.httprequest);
MeshServerLogEx(53, null, "Locking remote user out of desktop", ws.httprequest);
var child = require('child_process');
child.execFile(process.env['windir'] + '\\system32\\cmd.exe', ['/c', 'RunDll32.exe user32.dll,LockWorkStation'], { type: 1 });
}

View File

@ -576,7 +576,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
if (adminUser.links == null) adminUser.links = {};
adminUser.links[obj.dbMeshKey] = { rights: 0xFFFFFFFF };
db.SetUser(adminUser);
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(obj.dbMeshKey, [adminUser._id, obj.dbNodeKey]), obj, { etype: 'mesh', username: adminUser.name, meshid: obj.dbMeshKey, name: meshname, mtype: 2, desc: '', action: 'createmesh', links: links, msg: 'Mesh created: ' + obj.meshid, domain: domain.id });
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(obj.dbMeshKey, [adminUser._id, obj.dbNodeKey]), obj, { etype: 'mesh', username: adminUser.name, meshid: obj.dbMeshKey, name: meshname, mtype: 2, desc: '', action: 'createmesh', links: links, msgid: 55, msgArgs: [obj.meshid], msg: "Created device group: " + obj.meshid, domain: domain.id });
}
} else {
if ((mesh != null) && (mesh.deleted != null) && (mesh.links)) {
@ -597,7 +597,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
}
// Send out an event indicating this mesh was "created"
parent.parent.DispatchEvent(ids, obj, { etype: 'mesh', meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'createmesh', links: mesh.links, msg: 'Mesh undeleted: ' + mesh._id, domain: domain.id });
parent.parent.DispatchEvent(ids, obj, { etype: 'mesh', meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'createmesh', links: mesh.links, msgid: 56, msgArgs: [mesh._id], msg: "Device group undeleted: " + mesh._id, domain: domain.id });
// Mark the mesh as active
delete mesh.deleted;
@ -813,7 +813,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
// This is a temporary agent, don't log.
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(obj.dbMeshKey, [obj.dbNodeKey]), obj, { etype: 'node', action: 'addnode', node: device, domain: domain.id, nolog: 1 });
} else {
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(obj.dbMeshKey, [obj.dbNodeKey]), obj, { etype: 'node', action: 'addnode', node: device, msg: ('Added device ' + obj.agentInfo.computerName + ' to mesh ' + mesh.name), domain: domain.id });
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(obj.dbMeshKey, [obj.dbNodeKey]), obj, { etype: 'node', action: 'addnode', node: device, msgid: 57, msgArgs: [obj.agentInfo.computerName, mesh.name], msg: ('Added device ' + obj.agentInfo.computerName + ' to device group ' + mesh.name), domain: domain.id });
}
completeAgentConnection3(device, mesh);
@ -1250,6 +1250,9 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
// Log a value in the event log
if ((typeof command.msg == 'string') && (command.msg.length < 4096)) {
var event = { etype: 'node', action: 'agentlog', nodeid: obj.dbNodeKey, domain: domain.id, msg: command.msg };
if (typeof command.msgid == 'number') { event.msgid = command.msgid; }
if (Array.isArray(command.msgArgs)) { event.msgArgs = command.msgArgs; }
if (typeof command.remoteaddr == 'string') { event.remoteaddr = command.remoteaddr; }
var targets = parent.CreateMeshDispatchTargets(obj.dbMeshKey, [obj.dbNodeKey]);
if (typeof command.userid == 'string') {
var loguser = parent.users[command.userid];
@ -1292,7 +1295,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
var signResponse = parent.parent.certificateOperations.signAcmRequest(domain, command, 'admin', amtpassword, obj.remoteaddrport, obj.dbNodeKey, obj.dbMeshKey, obj.agentInfo.computerName, obj.agentInfo.agentId); // TODO: Place account credentials!!!
if ((signResponse != null) && (signResponse.error == null)) {
// Log this activation event
var event = { etype: 'node', action: 'amtactivate', nodeid: obj.dbNodeKey, domain: domain.id, msg: 'Device requested Intel AMT ACM activation, FQDN: ' + command.fqdn, ip: obj.remoteaddrport };
var event = { etype: 'node', action: 'amtactivate', nodeid: obj.dbNodeKey, domain: domain.id, msgid: 58, msgArgs: [command.fqdn], msg: 'Device requested Intel(R) AMT ACM activation, FQDN: ' + command.fqdn, ip: obj.remoteaddrport };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the node. Another event will come.
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(obj.dbMeshKey, [obj.dbNodeKey]), obj, event);
@ -1423,7 +1426,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
//console.log(command);
// Event the session closed compression data.
var event = { etype: 'node', action: 'sessioncompression', nodeid: obj.dbNodeKey, domain: domain.id, sent: command.sent, sentActual: command.sentActual, msg: 'Agent closed session with ' + command.sentRatio + '% agent to server compression. Sent: ' + command.sent + ', Compressed: ' + command.sentActual + '.' };
var event = { etype: 'node', action: 'sessioncompression', nodeid: obj.dbNodeKey, domain: domain.id, sent: command.sent, sentActual: command.sentActual, msgid: 54, msgArgs: [command.sentRatio, command.sent, command.sentActual], msg: 'Agent closed session with ' + command.sentRatio + '% agent to server compression. Sent: ' + command.sent + ', Compressed: ' + command.sentActual + '.' };
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(obj.dbMeshKey, [obj.dbNodeKey]), obj, event);
break;
}
@ -1571,7 +1574,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
db.Set(device);
// Event the node change
var event = { etype: 'node', action: 'changenode', nodeid: obj.dbNodeKey, domain: domain.id, node: parent.CloneSafeNode(device), msg: 'Changed device ' + device.name + ' from group ' + mesh.name + ': ' + changes.join(', ') };
var event = { etype: 'node', action: 'changenode', nodeid: obj.dbNodeKey, domain: domain.id, node: parent.CloneSafeNode(device), msgid: 59, msgArgs: [device.name, mesh.name, changes.join(', ')], msg: 'Changed device ' + device.name + ' from group ' + mesh.name + ': ' + changes.join(', ') };
if (obj.agentInfo.capabilities & 0x20) { event.nolog = 1; } // If this is a temporary device, don't log changes
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the node. Another event will come.
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(device.meshid, [obj.dbNodeKey]), obj, event);

View File

@ -1645,7 +1645,7 @@ function CreateMeshCentralServer(config, args) {
// If the database is not setup, exit now.
if (!obj.db) return;
// Send event to syslog is needed
// Send event to syslog if needed
if (obj.syslog && event.msg) { obj.syslog.log(obj.syslog.LOG_INFO, event.msg); }
if (obj.syslogjson) { obj.syslogjson.log(obj.syslogjson.LOG_INFO, JSON.stringify(event)); }

View File

@ -130,7 +130,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
// Log joining 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, msg: "Joined desktop multiplex session", protocol: 2 };
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, nodeid: obj.nodeid, userid: peer.user._id, username: peer.user.name, msgid: 4, msg: "Joined desktop multiplex session", protocol: 2 };
parent.parent.DispatchEvent(['*', obj.nodeid, peer.user._id, obj.meshid], obj, event);
}
@ -157,7 +157,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
// Log multiplex session start
if ((obj.agent != null) && (obj.viewers.length > 0) && (obj.startTime == null)) {
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, nodeid: obj.nodeid, userid: obj.viewers[0].user._id, username: obj.viewers[0].user.name, msg: "Started desktop multiplex session", protocol: 2 };
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, nodeid: obj.nodeid, userid: obj.viewers[0].user._id, username: obj.viewers[0].user.name, msgid: 6, msg: "Started desktop multiplex session", protocol: 2 };
parent.parent.DispatchEvent(['*', obj.nodeid, obj.viewers[0].user._id, obj.meshid], obj, event);
obj.startTime = Date.now();
}
@ -206,7 +206,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
// 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, msg: "Left the desktop multiplex session", protocol: 2 };
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);
}
@ -243,7 +243,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
// Add a event entry about this recording
var basefile = parent.parent.path.basename(filename);
var event = { etype: 'relay', action: 'recording', domain: domain.id, nodeid: obj.nodeid, msg: "Finished recording session" + (obj.sessionLength ? (', ' + obj.sessionLength + ' second(s)') : ''), filename: basefile, size: obj.recordingFileSize, protocol: 2, icon: obj.icon, name: obj.name, meshid: obj.meshid, userids: obj.userIds, multiplex: true };
var event = { etype: 'relay', action: 'recording', domain: domain.id, nodeid: obj.nodeid, msgid: 7, mshArgs: [obj.sessionLength], msg: "Finished recording session" + (obj.sessionLength ? (', ' + obj.sessionLength + ' second(s)') : ''), filename: basefile, size: obj.recordingFileSize, protocol: 2, icon: obj.icon, name: obj.name, meshid: obj.meshid, userids: obj.userIds, multiplex: true };
var mesh = parent.meshes[obj.meshid];
if (mesh != null) { event.meshname = mesh.name; }
if (obj.sessionStart) { event.startTime = obj.sessionStart; event.lengthTime = obj.sessionLength; }
@ -255,7 +255,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
// Log end of multiplex session
if (obj.startTime != null) {
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, nodeid: obj.nodeid, msg: "Closed desktop multiplex session" + ', ' + Math.floor((Date.now() - obj.startTime) / 1000) + ' second(s)', protocol: 2 };
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, nodeid: obj.nodeid, msgid: 8, msgArgs: [Math.floor((Date.now() - obj.startTime) / 1000)], msg: "Closed desktop multiplex session" + ', ' + Math.floor((Date.now() - obj.startTime) / 1000) + ' second(s)', protocol: 2 };
parent.parent.DispatchEvent(['*', obj.nodeid, obj.meshid], obj, event);
obj.startTime = null;
}

View File

@ -282,11 +282,11 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
// Log the connection
if (sessionUser != null) {
var msg = 'Started relay session';
if (obj.req.query.p == 1) { msg = 'Started terminal session'; }
else if (obj.req.query.p == 2) { msg = 'Started desktop session'; }
else if (obj.req.query.p == 5) { msg = 'Started file management session'; }
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: sessionUser._id, username: sessionUser.name, msg: msg + ' \"' + obj.id + '\" from ' + obj.peer.req.clientIp + ' to ' + req.clientIp, protocol: req.query.p, nodeid: req.query.nodeid };
var msg = 'Started relay session', msgid = 13;
if (obj.req.query.p == 1) { msg = 'Started terminal session'; msgid = 14; }
else if (obj.req.query.p == 2) { msg = 'Started desktop session'; msgid = 15; }
else if (obj.req.query.p == 5) { msg = 'Started file management session'; msgid = 16; }
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: sessionUser._id, username: sessionUser.name, msgid: msgid, msgArgs: [obj.id, obj.peer.req.clientIp, req.clientIp], msg: msg + ' \"' + obj.id + '\" from ' + obj.peer.req.clientIp + ' to ' + req.clientIp, protocol: req.query.p, nodeid: req.query.nodeid };
parent.parent.DispatchEvent(['*', sessionUser._id], obj, event);
}
} else {
@ -388,15 +388,15 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
// Log the disconnection
if (ws.time) {
var msg = 'Ended relay session';
if (obj.req.query.p == 1) { msg = 'Ended terminal session'; }
else if (obj.req.query.p == 2) { msg = 'Ended desktop session'; }
else if (obj.req.query.p == 5) { msg = 'Ended file management session'; }
var msg = 'Ended relay session', msgid = 9;
if (obj.req.query.p == 1) { msg = 'Ended terminal session', msgid = 10; }
else if (obj.req.query.p == 2) { msg = 'Ended desktop session', msgid = 11; }
else if (obj.req.query.p == 5) { msg = 'Ended file management session', msgid = 12; }
if (user) {
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: user._id, username: user.name, msg: msg + ' \"' + obj.id + '\" from ' + obj.req.clientIp + ' to ' + obj.peer.req.clientIp + ', ' + Math.floor((Date.now() - ws.time) / 1000) + ' second(s)', protocol: obj.req.query.p, nodeid: obj.req.query.nodeid };
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: user._id, username: user.name, msgid: msgid, msgArgs: [obj.id, obj.req.clientIp, obj.peer.req.clientIp, Math.floor((Date.now() - ws.time) / 1000)], msg: msg + ' \"' + obj.id + '\" from ' + obj.req.clientIp + ' to ' + obj.peer.req.clientIp + ', ' + Math.floor((Date.now() - ws.time) / 1000) + ' second(s)', protocol: obj.req.query.p, nodeid: obj.req.query.nodeid };
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: peer.user.name, msg: msg + ' \"' + obj.id + '\" from ' + obj.req.clientIp + ' to ' + obj.peer.req.clientIp + ', ' + Math.floor((Date.now() - ws.time) / 1000) + ' second(s)', protocol: obj.req.query.p, nodeid: obj.req.query.nodeid };
var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: peer.user._id, username: peer.user.name, msgid: msgid, msgArgs: [obj.id, obj.req.clientIp, obj.peer.req.clientIp, Math.floor((Date.now() - ws.time) / 1000)], msg: msg + ' \"' + obj.id + '\" from ' + obj.req.clientIp + ' to ' + obj.peer.req.clientIp + ', ' + Math.floor((Date.now() - ws.time) / 1000) + ' second(s)', protocol: obj.req.query.p, nodeid: obj.req.query.nodeid };
parent.parent.DispatchEvent(['*', peer.user._id], obj, event);
}
}

View File

@ -66,6 +66,20 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
const SITERIGHT_ALLEVENTS = 0x00000800;
const SITERIGHT_ADMIN = 0xFFFFFFFF;
// Events
/*
var eventsMessageId = {
1: "Account login",
2: "Account logout",
3: "Changed language from {1} to {2}",
4: "Joined desktop multiplex session",
5: "Left the desktop multiplex session",
6: "Started desktop multiplex session",
7: "Finished recording session, {0} second(s)",
8: "Closed desktop multiplex session, {0} second(s)"
};
*/
var obj = {};
obj.user = user;
obj.domain = domain;
@ -135,7 +149,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (ws.domainid) { delete ws.domainid; }
if (ws.sessionId) { delete ws.sessionId; }
if (ws.HandleEvent) { delete ws.HandleEvent; }
ws.removeAllListeners(["message", "close", "error"]);
ws.removeAllListeners(['message', 'close', 'error']);
};
// Convert a mesh path array into a real path on the server side
@ -1408,9 +1422,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
parent.db.SetUser(user);
// Event the change
var message = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', domain: domain.id };
var message = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', domain: domain.id, msgid: 2, msgArgs: [(oldlang ? oldlang : 'default'), (user.lang ? user.lang : 'default')] };
if (db.changeStream) { message.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
message.msg = 'Changed language of user ' + user.name + ' from ' + (oldlang ? oldlang : 'default') + ' to ' + (user.lang ? user.lang : 'default');
message.msg = 'Changed language from ' + (oldlang ? oldlang : 'default') + ' to ' + (user.lang ? user.lang : 'default');
var targets = ['*', 'server-users', user._id];
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
@ -1585,7 +1599,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
db.Set(parent.cleanDevice(node));
// Event the node change
var event = { etype: 'node', userid: user._id, username: user.name, action: 'changenode', nodeid: node._id, domain: deluserdomain.id, msg: (command.rights == 0) ? ('Removed user device rights for ' + node.name) : ('Changed user device rights for ' + node.name), node: parent.CloneSafeNode(node) }
var event;
if (command.rights == 0) {
event = { etype: 'node', userid: user._id, username: user.name, action: 'changenode', nodeid: node._id, domain: deluserdomain.id, msgid: 60, msgArgs: [node.name], msg: 'Removed user device rights for ' + node.name, node: parent.CloneSafeNode(node) }
} else {
event = { etype: 'node', userid: user._id, username: user.name, action: 'changenode', nodeid: node._id, domain: deluserdomain.id, msgid: 61, msgArgs: [node.name], msg: 'Changed user device rights for ' + node.name, node: parent.CloneSafeNode(node) }
}
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
parent.parent.DispatchEvent(parent.CreateNodeDispatchTargets(node.meshid, node._id), obj, event);
});
@ -1598,7 +1617,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify user group change
change = 'Removed user ' + deluser.name + ' from user group ' + ugroup.name;
var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: ugroup._id, name: ugroup.name, desc: ugroup.desc, action: 'usergroupchange', links: ugroup.links, msg: 'Removed user ' + deluser.name + ' from user group ' + ugroup.name, addUserDomain: deluserdomain.id };
var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: ugroup._id, name: ugroup.name, desc: ugroup.desc, action: 'usergroupchange', links: ugroup.links, msgid: 62, msgArgs: [deluser.name, ugroup.name], msg: 'Removed user ' + deluser.name + ' from user group ' + ugroup.name, addUserDomain: deluserdomain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user group. Another event will come.
parent.parent.DispatchEvent(['*', ugroup._id, user._id, deluser._id], obj, event);
}
@ -1620,7 +1639,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
var targets = ['*', 'server-users'];
if (deluser.groups) { for (var i in deluser.groups) { targets.push('server-users:' + i); } }
parent.parent.DispatchEvent(targets, obj, { etype: 'user', userid: deluserid, username: deluser.name, action: 'accountremove', msg: 'Account removed', domain: deluserdomain.id });
parent.parent.DispatchEvent(targets, obj, { etype: 'user', userid: deluserid, username: deluser.name, action: 'accountremove', msgid: 63, msg: 'Account removed', domain: deluserdomain.id });
parent.parent.DispatchEvent([deluserid], obj, 'close');
if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'deleteuser', responseid: command.responseid, result: 'ok' })); } catch (ex) { } }

View File

@ -36,6 +36,7 @@
"sample-config-advanced.json"
],
"dependencies": {
"archiver": "^4.0.2",
"body-parser": "^1.19.0",
"cbor": "^4.1.5",
"compression": "^1.7.4",
@ -44,10 +45,7 @@
"express": "^4.17.0",
"express-handlebars": "^3.1.0",
"express-ws": "^4.0.0",
"html-minifier": "^4.0.0",
"ipcheck": "^0.1.0",
"jsdom": "^16.4.0",
"minify-js": "0.0.4",
"minimist": "^1.2.0",
"multiparty": "^4.2.1",
"nedb": "^1.8.0",

File diff suppressed because it is too large Load Diff

View File

@ -10556,6 +10556,73 @@
// MY EVENTS
//
// Events
var eventsMessageId = {
1: "Account login",
2: "Account logout",
3: "Changed language from {1} to {2}",
4: "Joined desktop multiplex session",
5: "Left the desktop multiplex session",
6: "Started desktop multiplex session",
7: "Finished recording session, {0} second(s)",
8: "Closed desktop multiplex session, {0} second(s)",
9: "Ended relay session \"{0}\" from {1} to {2}, {3} second(s)",
10: "Ended terminal session \"{0}\" from {1} to {2}, {3} second(s)",
11: "Ended desktop session \"{0}\" from {1} to {2}, {3} second(s)",
12: "Ended file management session \"{0}\" from {1} to {2}, {3} second(s)",
13: "Started relay session \"{0}\" from {1} to {2}",
14: "Started terminal session \"{0}\" from {1} to {2}",
15: "Started desktop session \"{0}\" from {1} to {2}",
16: "Started file management session \"{0}\" from {1} to {2}",
17: "Processing console command: \"{0}\"",
18: "Displaying message box, title=\"{0}\", message=\"{1}\"",
19: "Killing process {0}",
20: "Opening: {0}",
21: "Getting clipboard content, {0} byte(s)",
22: "Setting clipboard content, {0} byte(s)",
23: "Attempting Intel(R) AMT ACM mode activation",
24: "Running commands",
25: "Performing power action={0}, forced={1}",
26: "Displaying toast message, title=\"{0}\", message=\"{1}\"",
27: "Local user accepted remote terminal request",
28: "Local user rejected remote terminal request",
29: "Remote Desktop Connection forcefully closed by local user",
30: "Starting remote desktop after local user accepted",
31: "Remote Desktop Connection Bar Activated/Updated",
32: "Remote Desktop Connection Bar Failed or Not Supported",
33: "Remote Desktop Connection forcefully closed by local user",
34: "Failed to start remote desktop after local user rejected",
35: "Started remote desktop with toast notification",
36: "Started remote desktop without notification",
37: "Remote Desktop Connection Bar Activated/Updated",
38: "Remote Desktop Connection Bar Failed or not Supported",
39: "Remote Desktop Connection forcefully closed by local user",
40: "Starting remote files after local user accepted",
41: "Failed to start remote files after local user rejected",
42: "Started remote files with toast notification",
43: "Started remote files without notification",
44: "Create folder: \"{0}\"",
45: "Delete: \"{0}\"",
46: "Delete recursive: \"{0}\", {1} element(s) removed",
47: "Delete: \"{0}\", {1} element(s) removed",
48: "Rename: \"{0}\" to \"{1}\"",
49: "Download: \"{0}\"",
50: "Upload: \"{0}\"",
51: "Copy: \"{0}\" to \"{1}\"",
52: "Move: \"{0}\" to \"{1}\"",
53: "Locking remote user out of desktop",
54: "Agent closed session with {0}% agent to server compression. Sent: {1}, Compressed: {2}",
55: "Created device group: {0}",
56: "Device group undeleted: {0}",
57: "Added device {0} to device group {1}",
58: "Device requested Intel(R) AMT ACM activation, FQDN: {0}",
59: "Changed device {0} from group {1}: {2}",
60: "Removed user device rights for {0}",
61: "Changed user device rights for {0}",
62: "Removed user {0} from user group {1}",
63: "Account removed"
};
// Highlights the device being hovered
function eventMouseHover(e, over) {
e.children[1].classList.remove('g1s');
@ -10581,7 +10648,14 @@
if (event.etype == 'user') icon = 'm2';
if (event.etype == 'server') icon = 'si3';
var msg = EscapeHtml(event.msg).split('(R)').join('&reg;');
var msg;
if ((event.msgid == null) || (eventsMessageId[event.msgid] == null)) {
msg = EscapeHtml(event.msg).split('(R)').join('&reg;');
} else {
msg = eventsMessageId[event.msgid];
if (event.msgArgs != null) { for (var i in event.msgArgs) { msg = msg.split('{' + i + '}').join(event.msgArgs[i]); } }
msg = 'x' + EscapeHtml(msg).split('(R)').join('&reg;');
}
if (event.nodeid) {
var node = getNodeFromId(event.nodeid);
if (node != null) {
@ -10596,6 +10670,7 @@
msg = EscapeHtml(event.username) + ' &rarr; ' + msg;
}
}
if (event.remoteaddr) { msg += ' (' + event.remoteaddr + ')'; }
if (event.etype == 'relay' || event.action == 'relaylog') icon = 'relayIcon16';
x += '<tr onclick=showEventDetails(' + event.h + ',2) onmouseover=eventMouseHover(this,1) onmouseout=eventMouseHover(this,0) style=cursor:pointer><td style=width:18px><div class=' + icon + '></div></td><td class=g1>&nbsp;</td><td class=style10>' + printTime(time) + ' - ' + msg + '</td><td class=g2>&nbsp;</td></tr><tr style=height:2px></tr>';
}

View File

@ -679,7 +679,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
// Destroy the user's session to log them out will be re-created next request
if (req.session.userid) {
var user = obj.users[req.session.userid];
if (user != null) { obj.parent.DispatchEvent(['*'], obj, { etype: 'user', userid: user._id, username: user.name, action: 'logout', msg: 'Account logout', domain: domain.id }); }
if (user != null) { obj.parent.DispatchEvent(['*'], obj, { etype: 'user', userid: user._id, username: user.name, action: 'logout', msgid: 2, msg: 'Account logout', domain: domain.id }); }
}
req.session = null;
if (req.query.key != null) { res.redirect(domain.url + '?key=' + req.query.key); } else { res.redirect(domain.url); }
@ -1059,7 +1059,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
// Notify account login
var targets = ['*', 'server-users'];
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
obj.parent.DispatchEvent(targets, obj, { etype: 'user', userid: user._id, username: user.name, account: obj.CloneSafeUser(user), action: 'login', msg: 'Account login', domain: domain.id });
obj.parent.DispatchEvent(targets, obj, { etype: 'user', userid: user._id, username: user.name, account: obj.CloneSafeUser(user), action: 'login', msgid: 1, msg: 'Account login', domain: domain.id });
// Regenerate session when signing in to prevent fixation
//req.session.regenerate(function () {