mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-02-04 02:15:57 -05:00
Fixed meshcore agent size, user group domains, notification closes across tabs.
This commit is contained in:
parent
c1e658e6c8
commit
238483c645
@ -42,24 +42,20 @@ function createMeshCore(agent) {
|
|||||||
if (process.platform == 'win32' && require('user-sessions').isRoot())
|
if (process.platform == 'win32' && require('user-sessions').isRoot())
|
||||||
{
|
{
|
||||||
// Check the Agent Uninstall MetaData for correctness, as the installer may have written an incorrect value
|
// Check the Agent Uninstall MetaData for correctness, as the installer may have written an incorrect value
|
||||||
var actualSize = require('fs').statSync(process.execPath).size / 1024;
|
var actualSize = Math.floor(require('fs').statSync(process.execPath).size / 1024);
|
||||||
var writtenSize = 0;
|
var writtenSize = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
writtenSize = require('win-registry').QueryKey(require('win-registry').HKEY.LocalMachine, 'Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MeshCentralAgent', 'EstimatedSize');
|
writtenSize = require('win-registry').QueryKey(require('win-registry').HKEY.LocalMachine, 'Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MeshCentralAgent', 'EstimatedSize');
|
||||||
}
|
}
|
||||||
catch(x)
|
catch(x) { }
|
||||||
{
|
|
||||||
}
|
|
||||||
if (writtenSize != actualSize)
|
if (writtenSize != actualSize)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
require('win-registry').WriteKey(require('win-registry').HKEY.LocalMachine, 'Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MeshCentralAgent', 'EstimatedSize', actualSize);
|
require('win-registry').WriteKey(require('win-registry').HKEY.LocalMachine, 'Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MeshCentralAgent', 'EstimatedSize', actualSize);
|
||||||
}
|
}
|
||||||
catch (x2)
|
catch (x2) { }
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1953,7 +1949,7 @@ function createMeshCore(agent) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'agentsize':
|
case 'agentsize':
|
||||||
var actualSize = require('fs').statSync(process.execPath).size / 1024;
|
var actualSize = Math.floor(require('fs').statSync(process.execPath).size / 1024);
|
||||||
if (process.platform == 'win32')
|
if (process.platform == 'win32')
|
||||||
{
|
{
|
||||||
// Check the Agent Uninstall MetaData for correctness, as the installer may have written an incorrect value
|
// Check the Agent Uninstall MetaData for correctness, as the installer may have written an incorrect value
|
||||||
|
48
meshuser.js
48
meshuser.js
@ -376,7 +376,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
const lastLoginTime = parent.users[user._id].pastlogin;
|
const lastLoginTime = parent.users[user._id].pastlogin;
|
||||||
if (lastLoginTime != null) {
|
if (lastLoginTime != null) {
|
||||||
db.GetFailedLoginCount(user.name, user.domain, new Date(lastLoginTime * 1000), function (count) {
|
db.GetFailedLoginCount(user.name, user.domain, new Date(lastLoginTime * 1000), function (count) {
|
||||||
if (count > 0) { try { ws.send(JSON.stringify({ action: 'msg', type: 'notify', title: "Security Warning", tag: 'ServerNotify', value: "There has been " + count + " failed login attempts on this account since the last login." })); } catch (ex) { } delete user.pastlogin; }
|
if (count > 0) { try { ws.send(JSON.stringify({ action: 'msg', type: 'notify', title: "Security Warning", tag: 'ServerNotify', id: Math.random(), value: "There has been " + count + " failed login attempts on this account since the last login." })); } catch (ex) { } delete user.pastlogin; }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,6 +394,20 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
|
|
||||||
switch (command.action) {
|
switch (command.action) {
|
||||||
case 'ping': { try { ws.send(JSON.stringify({ action: 'pong' })); } catch (ex) { } break; }
|
case 'ping': { try { ws.send(JSON.stringify({ action: 'pong' })); } catch (ex) { } break; }
|
||||||
|
case 'intersession':
|
||||||
|
{
|
||||||
|
// Sends data between sessions of the same user
|
||||||
|
var sessions = parent.wssessions[obj.user._id];
|
||||||
|
if (sessions == null) break;
|
||||||
|
|
||||||
|
// Create the notification message and send on all sessions except our own (no echo back).
|
||||||
|
var notification = JSON.stringify(command);
|
||||||
|
for (var i in sessions) { if (sessions[i] != obj.ws) { try { sessions[i].send(notification); } catch (ex) { } } }
|
||||||
|
|
||||||
|
// TODO: Send the message of user sessions connected to other servers.
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'authcookie':
|
case 'authcookie':
|
||||||
{
|
{
|
||||||
// Renew the authentication cookie
|
// Renew the authentication cookie
|
||||||
@ -1054,7 +1068,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
db.GetUserWithVerifiedEmail(domain.id, command.email, function (err, docs) {
|
db.GetUserWithVerifiedEmail(domain.id, command.email, function (err, docs) {
|
||||||
if ((docs != null) && (docs.length > 0)) {
|
if ((docs != null) && (docs.length > 0)) {
|
||||||
// Notify the duplicate email error
|
// Notify the duplicate email error
|
||||||
try { ws.send(JSON.stringify({ action: 'msg', type: 'notify', title: 'Account Settings', tag: 'ServerNotify', value: 'Failed to change email address, another account already using: <b>' + EscapeHtml(command.email) + '</b>.' })); } catch (ex) { }
|
try { ws.send(JSON.stringify({ action: 'msg', type: 'notify', title: 'Account Settings', id: Math.random(), tag: 'ServerNotify', value: 'Failed to change email address, another account already using: <b>' + EscapeHtml(command.email) + '</b>.' })); } catch (ex) { }
|
||||||
} else {
|
} else {
|
||||||
// Update the user's email
|
// Update the user's email
|
||||||
var oldemail = user.email;
|
var oldemail = user.email;
|
||||||
@ -1218,7 +1232,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the notification message
|
// Create the notification message
|
||||||
var notification = { action: 'msg', type: 'notify', domain: domain.id, value: command.msg, title: user.name, icon: 0, tag: 'broadcast' };
|
var notification = { action: 'msg', type: 'notify', domain: domain.id, value: command.msg, title: user.name, icon: 0, tag: 'broadcast', id: Math.random() };
|
||||||
|
|
||||||
// Send the notification on all user sessions for this server
|
// Send the notification on all user sessions for this server
|
||||||
for (var i in parent.wssessions2) {
|
for (var i in parent.wssessions2) {
|
||||||
@ -1268,7 +1282,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
// Account count exceed, do notification
|
// Account count exceed, do notification
|
||||||
|
|
||||||
// Create the notification message
|
// Create the notification message
|
||||||
var notification = { action: "msg", type: "notify", value: "Account limit reached.", title: "Server Limit", userid: user._id, username: user.name, domain: domain.id };
|
var notification = { action: 'msg', type: 'notify', id: Math.random(), value: "Account limit reached.", title: "Server Limit", userid: user._id, username: user.name, domain: domain.id };
|
||||||
|
|
||||||
// Get the list of sessions for this user
|
// Get the list of sessions for this user
|
||||||
var sessions = parent.wssessions[user._id];
|
var sessions = parent.wssessions[user._id];
|
||||||
@ -1356,7 +1370,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
try { ws.send(JSON.stringify({ action: 'adduser', responseid: command.responseid, result: 'maxUsersExceed' })); } catch (ex) { }
|
try { ws.send(JSON.stringify({ action: 'adduser', responseid: command.responseid, result: 'maxUsersExceed' })); } catch (ex) { }
|
||||||
} else {
|
} else {
|
||||||
// Create the notification message
|
// Create the notification message
|
||||||
var notification = { action: "msg", type: "notify", value: "Account limit reached.", title: "Server Limit", userid: user._id, username: user.name, domain: domain.id };
|
var notification = { action: 'msg', type: 'notify', id: Math.random(), value: "Account limit reached.", title: "Server Limit", userid: user._id, username: user.name, domain: domain.id };
|
||||||
|
|
||||||
// Get the list of sessions for this user
|
// Get the list of sessions for this user
|
||||||
var sessions = parent.wssessions[user._id];
|
var sessions = parent.wssessions[user._id];
|
||||||
@ -1486,22 +1500,16 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
{
|
{
|
||||||
// TODO: Return only groups in the same administrative domain?
|
// TODO: Return only groups in the same administrative domain?
|
||||||
if ((user.siteadmin & SITERIGHT_USERGROUPS) == 0) {
|
if ((user.siteadmin & SITERIGHT_USERGROUPS) == 0) {
|
||||||
// We are not user group administrator, return a list with limited data.
|
// We are not user group administrator, return a list with limited data for our domain.
|
||||||
var groups = {}, groupCount = 0;
|
var groups = {}, groupCount = 0;
|
||||||
for (var i in parent.userGroups) { groupCount++; groups[i] = { name: parent.userGroups[i].name }; }
|
for (var i in parent.userGroups) { if (parent.userGroups[i].domain == domain.id) { groupCount++; groups[i] = { name: parent.userGroups[i].name }; } }
|
||||||
try { ws.send(JSON.stringify({ action: 'usergroups', ugroups: groupCount?groups:null, tag: command.tag })); } catch (ex) { }
|
try { ws.send(JSON.stringify({ action: 'usergroups', ugroups: groupCount?groups:null, tag: command.tag })); } catch (ex) { }
|
||||||
} else {
|
} else {
|
||||||
// We are user group administrator, return a full user group list.
|
// We are user group administrator, return a full user group list for our domain.
|
||||||
try { ws.send(JSON.stringify({ action: 'usergroups', ugroups: parent.userGroups, tag: command.tag })); } catch (ex) { }
|
var groups = {}, groupCount = 0;
|
||||||
|
for (var i in parent.userGroups) { if (parent.userGroups[i].domain == domain.id) { groupCount++; groups[i] = parent.userGroups[i]; } }
|
||||||
|
try { ws.send(JSON.stringify({ action: 'usergroups', ugroups: groupCount ? groups : null, tag: command.tag })); } catch (ex) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// Request a list of all user groups this user as rights to
|
|
||||||
if ((user.siteadmin & SITERIGHT_USERGROUPS) == 0) { return; }
|
|
||||||
db.GetAllTypeNoTypeField('ugrp', domain.id, function (err, docs) {
|
|
||||||
try { ws.send(JSON.stringify({ action: 'usergroups', ugroups: common.unEscapeAllLinksFieldName(docs), tag: command.tag })); } catch (ex) { }
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'createusergroup':
|
case 'createusergroup':
|
||||||
@ -1944,7 +1952,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
if ((user.groups != null) && (user.groups.length > 0) && ((chguser.groups == null) || (findOne(chguser.groups, user.groups) == false))) break;
|
if ((user.groups != null) && (user.groups.length > 0) && ((chguser.groups == null) || (findOne(chguser.groups, user.groups) == false))) break;
|
||||||
|
|
||||||
// Create the notification message
|
// Create the notification message
|
||||||
var notification = { action: "msg", type: "notify", value: command.msg, title: user.name, icon: 8, userid: user._id, username: user.name };
|
var notification = { action: 'msg', type: 'notify', id: Math.random(), value: command.msg, title: user.name, icon: 8, userid: user._id, username: user.name };
|
||||||
|
|
||||||
// Get the list of sessions for this user
|
// Get the list of sessions for this user
|
||||||
var sessions = parent.wssessions[command.userid];
|
var sessions = parent.wssessions[command.userid];
|
||||||
@ -1969,7 +1977,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
|
|
||||||
// Create the notification message
|
// Create the notification message
|
||||||
var notification = {
|
var notification = {
|
||||||
"action": "msg", "type": "notify", "value": "Chat Request, Click here to accept.", "title": user.name, "userid": user._id, "username": user.name, "tag": 'meshmessenger/' + encodeURIComponent(command.userid) + '/' + encodeURIComponent(user._id)
|
'action': 'msg', 'type': 'notify', id: Math.random(), 'value': "Chat Request, Click here to accept.", 'title': user.name, 'userid': user._id, 'username': user.name, 'tag': 'meshmessenger/' + encodeURIComponent(command.userid) + '/' + encodeURIComponent(user._id)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get the list of sessions for this user
|
// Get the list of sessions for this user
|
||||||
@ -3442,7 +3450,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Display a notification message for this session only.
|
// Display a notification message for this session only.
|
||||||
function displayNotificationMessage(msg, title, tag) { ws.send(JSON.stringify({ "action": "msg", "type": "notify", "value": msg, "title": title, "userid": user._id, "username": user.name, "tag": tag })); }
|
function displayNotificationMessage(msg, title, tag) { ws.send(JSON.stringify({ 'action': 'msg', 'type': 'notify', id: Math.random(), 'value': msg, 'title': title, 'userid': user._id, 'username': user.name, 'tag': tag })); }
|
||||||
|
|
||||||
// Read the folder and all sub-folders and serialize that into json.
|
// Read the folder and all sub-folders and serialize that into json.
|
||||||
function readFilesRec(path) {
|
function readFilesRec(path) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "meshcentral",
|
"name": "meshcentral",
|
||||||
"version": "0.4.6-x",
|
"version": "0.4.6-z",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Remote Management",
|
"Remote Management",
|
||||||
"Intel AMT",
|
"Intel AMT",
|
||||||
|
@ -1657,6 +1657,10 @@
|
|||||||
displayServerTrace();
|
displayServerTrace();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'intersession' : {
|
||||||
|
if (message.subaction == 'removeNotify') { notificationDelete(message.id); }
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'traceinfo': {
|
case 'traceinfo': {
|
||||||
if (typeof message.traceSources == 'object') {
|
if (typeof message.traceSources == 'object') {
|
||||||
if ((message.traceSources != null) && (message.traceSources.length > 0)) {
|
if ((message.traceSources != null) && (message.traceSources.length > 0)) {
|
||||||
@ -1865,6 +1869,7 @@
|
|||||||
var n = getstore('notifications', 0);
|
var n = getstore('notifications', 0);
|
||||||
if (((n & 8) == 0) && (message.amtMessage != null)) { break; } // Intel AMT desktop & terminal messages should be ignored.
|
if (((n & 8) == 0) && (message.amtMessage != null)) { break; } // Intel AMT desktop & terminal messages should be ignored.
|
||||||
var n = { text: message.value, title: message.title, icon: message.icon };
|
var n = { text: message.value, title: message.title, icon: message.icon };
|
||||||
|
if (message.id != null) { n.id = message.id; }
|
||||||
if (message.nodeid != null) { n.nodeid = message.nodeid; }
|
if (message.nodeid != null) { n.nodeid = message.nodeid; }
|
||||||
if (message.tag != null) { n.tag = message.tag; }
|
if (message.tag != null) { n.tag = message.tag; }
|
||||||
if (message.username != null) { n.username = message.username; }
|
if (message.username != null) { n.username = message.username; }
|
||||||
@ -1900,6 +1905,7 @@
|
|||||||
} else {
|
} else {
|
||||||
if (message.type == 'notify') { // This is a notification message.
|
if (message.type == 'notify') { // This is a notification message.
|
||||||
var n = { text: message.value, title: message.title, icon: message.icon };
|
var n = { text: message.value, title: message.title, icon: message.icon };
|
||||||
|
if (message.id != null) { n.id = message.id; }
|
||||||
if (message.tag != null) { n.tag = message.tag; }
|
if (message.tag != null) { n.tag = message.tag; }
|
||||||
if (message.username != null) { n.username = message.username; }
|
if (message.username != null) { n.username = message.username; }
|
||||||
addNotification(n);
|
addNotification(n);
|
||||||
@ -2538,6 +2544,7 @@
|
|||||||
}
|
}
|
||||||
case 'notify': {
|
case 'notify': {
|
||||||
var n = { text: message.event.value, title: message.event.title, icon: message.event.icon };
|
var n = { text: message.event.value, title: message.event.title, icon: message.event.icon };
|
||||||
|
if (message.id != null) { n.id = message.id; }
|
||||||
if (message.event.tag != null) { n.tag = message.event.tag; }
|
if (message.event.tag != null) { n.tag = message.event.tag; }
|
||||||
addNotification(n);
|
addNotification(n);
|
||||||
break;
|
break;
|
||||||
@ -9881,6 +9888,7 @@
|
|||||||
if (e != null) {
|
if (e != null) {
|
||||||
for (var i in notifications) { if (notifications[i].id == id) { j = i; } }
|
for (var i in notifications) { if (notifications[i].id == id) { j = i; } }
|
||||||
if (j != -1) {
|
if (j != -1) {
|
||||||
|
meshserver.send({ action: 'intersession', subaction: 'removeNotify', id: id }); // Remove the notification in other sessions of the same user.
|
||||||
if (notifications[j].notification) { notifications[j].notification.close(); delete notifications[j].notification; }
|
if (notifications[j].notification) { notifications[j].notification.close(); delete notifications[j].notification; }
|
||||||
notifications.splice(j, 1);
|
notifications.splice(j, 1);
|
||||||
e.parentNode.removeChild(e);
|
e.parentNode.removeChild(e);
|
||||||
|
@ -1154,7 +1154,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
|||||||
render(req, res, getRenderPage('message', req), getRenderArgs({ title3: 'Account Verification', message: 'Verified email <b>' + EscapeHtml(user.email) + '</b> for user account <b>' + EscapeHtml(user.name) + '</b>. <a href="' + domain.url + '">Go to login page</a>.' }, domain));
|
render(req, res, getRenderPage('message', req), getRenderArgs({ title3: 'Account Verification', message: 'Verified email <b>' + EscapeHtml(user.email) + '</b> for user account <b>' + EscapeHtml(user.name) + '</b>. <a href="' + domain.url + '">Go to login page</a>.' }, domain));
|
||||||
|
|
||||||
// Send a notification
|
// Send a notification
|
||||||
obj.parent.DispatchEvent([user._id], obj, { action: 'notify', value: 'Email verified:<br /><b>' + EscapeHtml(user.email) + '</b>.', nolog: 1 });
|
obj.parent.DispatchEvent([user._id], obj, { action: 'notify', value: 'Email verified:<br /><b>' + EscapeHtml(user.email) + '</b>.', nolog: 1, id: Math.random() });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user