fix(dashboard): Network connections are one entry per player or per connection, not per address

A player on the servers' machine (or behind the same address as other players) was merged with the
servers' own links and everyone else there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-29 19:07:27 -05:00
parent a824ff9914
commit 9b00e437e8
2 changed files with 51 additions and 14 deletions

View File

@@ -110,10 +110,14 @@ namespace NetworkView {
const auto name = label ? label(server) : key;
const auto seconds = std::max<int64_t>(server.connectionsSeconds, 1);
for (const auto& c : server.connections) {
auto& group = groups[c.address];
group.address = c.address;
group.seconds = std::max(group.seconds, seconds);
const std::string kind = c.peer != TrafficStats::Peer::CLIENTS ? "server" : c.http ? "web" : "game";
// One entry per player (their account), else per connection: an address alone is not enough, since the
// servers' own links and players on the same machine or network share it
const std::string groupKey = kind == "game" && c.accountId ? "account:" + std::to_string(c.accountId)
: kind + "|" + c.address + (c.http ? std::string() : ":" + std::to_string(c.port));
auto& group = groups[groupKey];
if (group.address.empty()) group.address = c.address;
group.seconds = std::max(group.seconds, seconds);
if (rank(kind) > rank(group.kind)) group.kind = kind;
if (c.accountId && !group.accountId) {
group.accountId = c.accountId;