1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Started work on traffic accounting.

This commit is contained in:
Ylian Saint-Hilaire 2021-05-05 02:24:23 -07:00
parent d17aae0c8f
commit b6e3b51be2
3 changed files with 57 additions and 2 deletions

View file

@ -342,6 +342,18 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
}
obj.getAgentStats = function () { return obj.agentStats; }
// Traffic counters
obj.trafficStats = {
httpRequestCount: 0,
relayCount: {},
relayIn: {},
relayOut: {},
localRelayCount: {},
localRelayIn: {},
localRelayOut: {}
}
obj.getTrafficStats = function () { return obj.trafficStats; }
// Keep a record of the last agent issues.
obj.getAgentIssues = function () { return obj.agentIssues; }
obj.setAgentIssue = function (agent, issue) { obj.agentIssues.push([new Date().toLocaleTimeString(), agent.remoteaddrport, issue]); while (obj.setAgentIssue.length > 50) { obj.agentIssues.shift(); } }
@ -5327,6 +5339,9 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
// Useful for debugging reverse proxy issues
parent.debug('httpheaders', req.method, req.url, req.headers);
// Count the HTTP request
obj.trafficStats.httpRequestCount++;
// Set the real IP address of the request
// If a trusted reverse-proxy is sending us the remote IP address, use it.
var ipex = '0.0.0.0', xforwardedhost = req.headers.host;