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:
parent
d17aae0c8f
commit
b6e3b51be2
3 changed files with 57 additions and 2 deletions
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue