mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-04-22 19:35:43 -04:00
Factorize urlargs, intersession
This commit is contained in:
parent
d1523c3bbf
commit
bb81de62db
38
meshuser.js
38
meshuser.js
@ -631,26 +631,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
// pass through to switch statement until refactoring complete
|
// pass through to switch statement until refactoring complete
|
||||||
|
|
||||||
switch (command.action) {
|
switch (command.action) {
|
||||||
case 'urlargs':
|
|
||||||
{
|
|
||||||
console.log(req.query);
|
|
||||||
console.log(command.args);
|
|
||||||
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 'interuser':
|
case 'interuser':
|
||||||
{
|
{
|
||||||
// Sends data between users only if allowed. Only a user in the "interUserMessaging": [] list, in the settings section of the config.json can receive and send inter-user messages from and to all users.
|
// Sends data between users only if allowed. Only a user in the "interUserMessaging": [] list, in the settings section of the config.json can receive and send inter-user messages from and to all users.
|
||||||
@ -5477,6 +5457,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
'files': serverCommandFiles,
|
'files': serverCommandFiles,
|
||||||
'getnetworkinfo': serverCommandGetNetworkInfo,
|
'getnetworkinfo': serverCommandGetNetworkInfo,
|
||||||
'getsysinfo': serverCommandGetSysInfo,
|
'getsysinfo': serverCommandGetSysInfo,
|
||||||
|
'intersession': serverCommandInterSession,
|
||||||
'lastconnect': serverCommandLastConnect,
|
'lastconnect': serverCommandLastConnect,
|
||||||
'lastconnects': serverCommandLastConnects,
|
'lastconnects': serverCommandLastConnects,
|
||||||
'meshes': serverCommandMeshes,
|
'meshes': serverCommandMeshes,
|
||||||
@ -5491,6 +5472,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
'serverstats': serverCommandServerStats,
|
'serverstats': serverCommandServerStats,
|
||||||
'serverupdate': serverCommandServerUpdate,
|
'serverupdate': serverCommandServerUpdate,
|
||||||
'serverversion': serverCommandServerVersion,
|
'serverversion': serverCommandServerVersion,
|
||||||
|
'urlargs': serverCommandUrlArgs,
|
||||||
'users': serverCommandUsers
|
'users': serverCommandUsers
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -5901,6 +5883,17 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function serverCommandInterSession(command) {
|
||||||
|
// Sends data between sessions of the same user
|
||||||
|
var sessions = parent.wssessions[obj.user._id];
|
||||||
|
if (sessions == null) return;
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
}
|
||||||
|
|
||||||
function serverCommandLastConnect(command) {
|
function serverCommandLastConnect(command) {
|
||||||
if (!validNodeIdAndDomain(command)) return;
|
if (!validNodeIdAndDomain(command)) return;
|
||||||
|
|
||||||
@ -6114,6 +6107,11 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
parent.parent.getServerTags(function (tags, err) { try { ws.send(JSON.stringify({ action: 'serverversion', tags: tags })); } catch (ex) { } });
|
parent.parent.getServerTags(function (tags, err) { try { ws.send(JSON.stringify({ action: 'serverversion', tags: tags })); } catch (ex) { } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function serverCommandUrlArgs(command) {
|
||||||
|
console.log(req.query);
|
||||||
|
console.log(command.args);
|
||||||
|
}
|
||||||
|
|
||||||
function serverCommandUsers(command) {
|
function serverCommandUsers(command) {
|
||||||
// Request a list of all users
|
// Request a list of all users
|
||||||
if ((user.siteadmin & 2) == 0) { if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'users', responseid: command.responseid, result: 'Access denied' })); } catch (ex) { } } return; }
|
if ((user.siteadmin & 2) == 0) { if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'users', responseid: command.responseid, result: 'Access denied' })); } catch (ex) { } } return; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user