feat: record own and trusted web traffic in its own classes instead of dropping it

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Sonnet 5.5 committed 2026-11-23 09:03:57 -03:00
1 parent 4143bf599e
commit 3511a7141c
18 files changed
+434 -17

No files matched your search

+7 -1
View File
@@ -32,6 +32,10 @@ type Totals struct {
ActiveBans int `json:"active_bans"`
Monitoring uint64 `json:"monitoring"`
Counts map[string]uint64 `json:"counts"`
// Own and trusted traffic (see own.go) is NOT in Requests; RequestsAll adds it.
Trusted uint64 `json:"trusted"`
Internal uint64 `json:"internal"`
RequestsAll uint64 `json:"requests_all"`
}
// IPSummary describes one IP. Samples, UAs and Domains are only filled in the
@@ -98,6 +102,7 @@ type Summary struct {
Generated int64 `json:"generated"`
Hosts []HostInfo `json:"hosts"`
Totals Totals `json:"totals"`
Own OwnTraffic `json:"own"` // own and trusted origins, apart from every attack number
Timeline Timeline `json:"timeline"`
Rates Rates `json:"rates"`
IPs []IPSummary `json:"ips"`
@@ -428,6 +433,7 @@ func (s *Store) buildSummary(rg Range) Summary {
tot.Monitoring += uint64(hs.Mon)
}
}
own := s.ownLocked(g, to, &tot)
paths, doms, uas, users, ctry := map[string]uint32{}, map[string]uint32{}, map[string]uint32{}, map[string]uint32{}, map[string]uint32{}
firstHour, lastHour := start/3600, to/3600
for i := range s.hours {
@@ -522,7 +528,7 @@ func (s *Store) buildSummary(rg Range) Summary {
Hosts: []HostInfo{{Name: s.cfg.Name, Self: true, Online: true, Version: s.cfg.Version, LastSeen: nowU,
Requests: tot.Requests, Malicious: tot.Malicious, HostileIPs: tot.HostileIPs, ActiveBans: tot.ActiveBans,
Live: true, Location: s.Location()}},
Totals: tot, Timeline: tl, Rates: rates, IPs: ips,
Totals: tot, Own: own, Timeline: tl, Rates: rates, IPs: ips,
TopPaths: topN(paths, topKeep), TopDomains: topN(doms, topKeep), TopUAs: topUAs, TopUsers: topN(users, topKeep), Countries: topN(ctry, 120),
Recent: recent, Sources: srcs, Attribution: s.attrib,
}