mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-22 22:17:31 +03:00
Added relay session count.
This commit is contained in:
parent
fcb8caa867
commit
137cfcd0ae
@ -25,6 +25,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
||||
obj.remoteaddr = obj.ws._socket.remoteAddress;
|
||||
obj.domain = domain;
|
||||
if (obj.remoteaddr.startsWith('::ffff:')) { obj.remoteaddr = obj.remoteaddr.substring(7); }
|
||||
obj.parent.relaySessionCount++;
|
||||
|
||||
// Mesh Rights
|
||||
const MESHRIGHT_EDITMESH = 1;
|
||||
@ -193,12 +194,14 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
||||
|
||||
// If error, close both sides of the relay.
|
||||
ws.on('error', function (err) {
|
||||
obj.parent.relaySessionErrorCount++;
|
||||
console.log('Relay error from ' + obj.remoteaddr + ', ' + err.toString().split('\r')[0] + '.');
|
||||
closeBothSides();
|
||||
});
|
||||
|
||||
// If the relay web socket is closed, close both sides.
|
||||
ws.on('close', function (req) {
|
||||
obj.parent.relaySessionCount--;
|
||||
closeBothSides();
|
||||
});
|
||||
|
||||
|
10
meshuser.js
10
meshuser.js
@ -181,7 +181,15 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
var os = require('os');
|
||||
var stats = { action: 'serverstats', totalmem: os.totalmem(), freemem: os.freemem() };
|
||||
if (obj.parent.parent.platform != 'win32') { stats.cpuavg = os.loadavg(); } // else { stats.cpuavg = [ 0.2435345, 0.523234234, 0.6435345345 ]; }
|
||||
var serverStats = { "User Accounts": Object.keys(obj.parent.users).length, "Device Groups": Object.keys(obj.parent.meshes).length, "Agent Sessions": Object.keys(obj.parent.wsagents).length, "Connected Users": Object.keys(obj.parent.wssessions).length, "Users Sessions": Object.keys(obj.parent.wssessions2).length };
|
||||
var serverStats = {
|
||||
"User Accounts": Object.keys(obj.parent.users).length,
|
||||
"Device Groups": Object.keys(obj.parent.meshes).length,
|
||||
"Agent Sessions": Object.keys(obj.parent.wsagents).length,
|
||||
"Connected Users": Object.keys(obj.parent.wssessions).length,
|
||||
"Users Sessions": Object.keys(obj.parent.wssessions2).length,
|
||||
"Relay Sessions": obj.parent.relaySessionCount,
|
||||
"Relay Errors": obj.parent.relaySessionErrorCount
|
||||
};
|
||||
if (obj.parent.parent.mpsserver != null) { serverStats['Connected Intel® AMT'] = Object.keys(obj.parent.parent.mpsserver.ciraConnections).length; }
|
||||
stats.values = { "Server State": serverStats }
|
||||
try { ws.send(JSON.stringify(stats)); } catch (ex) { }
|
||||
|
@ -78,6 +78,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
||||
obj.agentBlockedIp = args.agentblockedip; // List of blocked IP addresses for agents
|
||||
obj.tlsSniCredentials = null;
|
||||
obj.dnsDomains = {};
|
||||
obj.relaySessionCount = 0;
|
||||
obj.relaySessionErrorCount = 0;
|
||||
|
||||
// Mesh Rights
|
||||
const MESHRIGHT_EDITMESH = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user