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:
1 parent
4143bf599e
commit
3511a7141c
18 files changed
+434
-17
No files matched your search
+16
-1
@@ -105,7 +105,8 @@ func (s *source) status() store.SourceStatus {
|
||||
// Runner owns the log sources of one instance.
|
||||
type Runner struct {
|
||||
St *store.Store
|
||||
Ignore []netip.Prefix
|
||||
Ignore []netip.Prefix // --ignore and --trusted: their web requests are counted as own traffic only
|
||||
Trusted []netip.Prefix // --trusted: the class "trusted"; the rest of Ignore is "internal"
|
||||
Monitor *regexp.Regexp
|
||||
MonitorFrom []netip.Prefix // when set, monitors are only believed from these networks
|
||||
Enr core.Enricher // optional geo and User-Agent resolver
|
||||
@@ -132,6 +133,9 @@ func NewRunner(c Config, st *store.Store, log *slog.Logger) (*Runner, error) {
|
||||
return nil, err
|
||||
}
|
||||
r := &Runner{St: st, Ignore: ign, DataDir: c.DataDir, Log: log}
|
||||
if r.Trusted, err = core.ParseCIDRs(c.Trusted); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if r.MonitorFrom, err = core.ParseCIDRs(c.MonitorFrom); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -377,6 +381,17 @@ func (r *Runner) handle(s *source) func([]byte) {
|
||||
}
|
||||
s.win.add(false)
|
||||
if core.Ignored(r.Ignore, ev.IP) {
|
||||
// own and trusted origins are counted, never analysed
|
||||
if ev.Source == "traefik" {
|
||||
if _, err := netip.ParseAddr(ev.IP); err == nil {
|
||||
class := store.OwnInternal
|
||||
if core.Ignored(r.Trusted, ev.IP) {
|
||||
class = store.OwnTrusted
|
||||
}
|
||||
s.lastEvent.Store(time.Now().Unix())
|
||||
r.St.Own(ev, class)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
if r.monitorTraffic(&ev) {
|
||||
|
||||
Reference in new issue
Block a user