net/tstun: rename statististics method (#5852)

Rename StatisticsEnable as SetStatisticsEnabled to be consistent
with other similarly named methods.

Rename StatisticsExtract as ExtractStatistics to follow
the convention where methods start with a verb.
It was originally named with Statistics as a prefix so that
statistics related methods would sort well in godoc,
but that property no longer holds.

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
Joe Tsai
2022-10-06 10:46:09 -07:00
committed by GitHub
parent dd045a3767
commit 84e8f25c21
2 changed files with 12 additions and 12 deletions

View File

@@ -843,15 +843,15 @@ func (t *Wrapper) Unwrap() tun.Device {
return t.tdev
}
// StatisticsEnable enables per-connections packet counters.
// StatisticsExtract must be called periodically to avoid unbounded memory use.
func (t *Wrapper) StatisticsEnable(enable bool) {
// SetStatisticsEnabled enables per-connections packet counters.
// ExtractStatistics must be called periodically to avoid unbounded memory use.
func (t *Wrapper) SetStatisticsEnabled(enable bool) {
t.stats.enabled.Store(enable)
}
// StatisticsExtract extracts and resets the counters for all active connections.
// ExtractStatistics extracts and resets the counters for all active connections.
// It must be called periodically otherwise the memory used is unbounded.
func (t *Wrapper) StatisticsExtract() map[flowtrack.Tuple]tunstats.Counts {
func (t *Wrapper) ExtractStatistics() map[flowtrack.Tuple]tunstats.Counts {
return t.stats.Extract()
}