wgengine/netlog: new package for traffic flow logging (#5864)

The Logger type managers a logtail.Logger for extracting
statistics from a tstun.Wrapper.
So long as Shutdown is called, it ensures that logtail
and statistic gathering resources are properly cleared up.

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
Joe Tsai
2022-10-12 11:57:13 -07:00
committed by GitHub
parent 79755d3ce5
commit 1b4e4cc1e8
3 changed files with 320 additions and 1 deletions

View File

@@ -844,7 +844,9 @@ func (t *Wrapper) Unwrap() tun.Device {
}
// SetStatisticsEnabled enables per-connections packet counters.
// ExtractStatistics must be called periodically to avoid unbounded memory use.
// Disabling statistics gathering does not reset the counters.
// ExtractStatistics must be called to reset the counters and
// be periodically called while enabled to avoid unbounded memory use.
func (t *Wrapper) SetStatisticsEnabled(enable bool) {
t.stats.enabled.Store(enable)
}