mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-01-24 05:03:14 -05:00
Added inter-user messaging support.
This commit is contained in:
parent
e2774ad0c5
commit
29c34ab5b2
@ -131,8 +131,9 @@
|
||||
"agentAllowedIP": { "type": [ "string", "array" ] },
|
||||
"agentBlockedIP": { "type": [ "string", "array" ] },
|
||||
"authLog": { "type": "string", "default": null, "description": "File path and name of the authentication log to be created. This log can be parsed by Fail2ban." },
|
||||
"manageAllDeviceGroups": { "type": "array", "uniqueItems": true, "items": { "type": "string" } },
|
||||
"manageCrossDomain": { "type": "array", "uniqueItems": true, "items": { "type": "string" } },
|
||||
"InterUserMessaging": { "type": "array", "uniqueItems": true, "items": { "type": "string" }, "description": "Users in this list are allowed to send and receive inter-user messages. This can be used to implement bots or other software where MeshCentral is used as data transport. See \"interuser\" websocket command in the code." },
|
||||
"manageAllDeviceGroups": { "type": "array", "uniqueItems": true, "items": { "type": "string" }, "description": "Users in this list are allowed to see and manage all device groups within their domain." },
|
||||
"manageCrossDomain": { "type": "array", "uniqueItems": true, "items": { "type": "string" }, "description": "Users in this list are allowed to manage all users in all domains." },
|
||||
"localDiscovery": {
|
||||
"type": "object",
|
||||
"description": "When this server is in LAN mode, you may discover this server using a multicast discovery tool. When discovery happens, the name and info fields are sent back to the discovery tool.",
|
||||
|
@ -13,7 +13,7 @@ if (args.proxy != null) { try { require('https-proxy-agent'); } catch (ex) { con
|
||||
|
||||
if (args['_'].length == 0) {
|
||||
console.log("MeshCtrl performs command line actions on a MeshCentral server.");
|
||||
console.log("Information at: https://meshcommander.com/meshcentral");
|
||||
console.log("Information at: https://meshcentral.com");
|
||||
console.log("No action specified, use MeshCtrl like this:\r\n\r\n meshctrl [action] [arguments]\r\n");
|
||||
console.log("Supported actions:");
|
||||
console.log(" Help [action] - Get help on an action.");
|
||||
@ -1139,7 +1139,7 @@ function serverConnect() {
|
||||
}
|
||||
|
||||
const ws = new WebSocket(url, options);
|
||||
console.log('Connecting to ' + url);
|
||||
//console.log('Connecting to ' + url);
|
||||
|
||||
ws.on('open', function open() {
|
||||
//console.log('Connected.');
|
||||
|
27
meshuser.js
27
meshuser.js
@ -618,6 +618,33 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
|
||||
// TODO: Send the message of user sessions connected to other servers.
|
||||
|
||||
break;
|
||||
}
|
||||
case 'interuser':
|
||||
{
|
||||
// Sends data between users only if allowed.
|
||||
if (command.data == null) return;
|
||||
if (typeof command.sessionid == 'string') { var userSessionId = command.sessionid.split('/'); if (userSessionId.length != 4) return; command.userid = userSessionId[0] + '/' + userSessionId[1] + '/' + userSessionId[2]; }
|
||||
if (common.validateString(command.userid, 0, 2014) == false) return;
|
||||
var userSplit = command.userid.split('/');
|
||||
if (userSplit.length == 1) { command.userid = 'user/' + domain.id + '/' + command.userid; userSplit = command.userid.split('/'); }
|
||||
if ((userSplit.length != 3) || (userSplit[0] != 'user') || (userSplit[1] != domain.id) || (parent.users[command.userid] == null)) return; // Make sure the target userid is valid and within the domain
|
||||
const allowed = ((parent.parent.config.settings.interusermessaging === true) || (parent.parent.config.settings.interusermessaging.indexOf(obj.user._id) >= 0) || (parent.parent.config.settings.interusermessaging.indexOf(command.userid) >= 0));
|
||||
if (allowed == false) return;
|
||||
|
||||
// Get sessions
|
||||
var sessions = parent.wssessions[command.userid];
|
||||
if (sessions == null) break;
|
||||
|
||||
// Create the notification message and send on all sessions except our own (no echo back).
|
||||
var notification = JSON.stringify({ action: 'interuser', sessionid: ws.sessionId, data: command.data, scope: (command.sessionid != null)?'session':'user' });
|
||||
for (var i in sessions) {
|
||||
if ((command.sessionid != null) && (sessions[i].sessionId != command.sessionid)) continue; // Send to a specific session
|
||||
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':
|
||||
|
@ -60,6 +60,7 @@
|
||||
"_agentAllowedIP": "192.168.0.100/24",
|
||||
"_agentBlockedIP": "127.0.0.1,::1",
|
||||
"_authLog": "c:\\temp\\auth.log",
|
||||
"_InterUserMessaging": [ "user//admin" ],
|
||||
"_manageAllDeviceGroups": [ "user//admin" ],
|
||||
"_manageCrossDomain": [ "user//admin" ],
|
||||
"_localDiscovery": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user