mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-11-10 05:59:40 -05:00
Started work on traffic accounting.
This commit is contained in:
15
webserver.js
15
webserver.js
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user