修复流量统计

This commit is contained in:
qaq
2025-06-27 11:56:59 +08:00
parent a5e7062c15
commit a5d7be8405
24 changed files with 431 additions and 685 deletions
+7 -8
View File
@@ -57,21 +57,20 @@ func (s *Stats) Get(kind stats.Kind) uint64 {
case stats.KindCurrentConns:
return s.currentConns.Load()
case stats.KindInputBytes:
if s.resetTraffic {
return s.inputBytes.Swap(0)
}
return s.inputBytes.Load()
return s.inputBytes.Load() // 只获取,不自动清零
case stats.KindOutputBytes:
if s.resetTraffic {
return s.outputBytes.Swap(0)
}
return s.outputBytes.Load()
return s.outputBytes.Load() // 只获取,不自动清零
case stats.KindTotalErrs:
return s.totalErrs.Load()
}
return 0
}
func (s *Stats) ResetTraffic(reportedInputBytes, reportedOutputBytes uint64) {
s.inputBytes.Store(reportedInputBytes)
s.outputBytes.Store(reportedOutputBytes)
}
func (s *Stats) Reset() {
s.updated.Store(false)
s.totalConns.Store(0)