model: per-port top source addresses and the span a report's stats cover

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
VeillaxandClaude Sonnet 5.5 committed 2026-10-27 16:53:56 -06:00
1 parent 6663b268c8
commit cb07e08e7b
2 files changed
+66 -10

No files matched your search

+16
View File
@@ -23,3 +23,19 @@ func TestRedirectLocation(t *testing.T) {
t.Error("IsRedirect is wrong")
}
}
func TestTopSources(t *testing.T) {
all := map[string]*SourceStat{
"a": {IP: "a", Conns: 1, BytesIn: 10, BytesOut: 5},
"b": {IP: "b", Conns: 9, BytesIn: 1},
"c": {IP: "c", Conns: 2, BytesIn: 100},
"d": {IP: "d", Conns: 3, BytesIn: 1},
}
got := TopSources(all, 3)
if len(got) != 3 || got[0].IP != "c" || got[1].IP != "a" || got[2].IP != "b" {
t.Fatalf("order: %+v", got) // c most bytes, a next, then b beats d on connections
}
if got := TopSources(all, 10); len(got) != 4 {
t.Fatalf("all: %+v", got)
}
}