Fix traffic init time (#10)

This commit is contained in:
百里(barry) 2024-07-12 12:11:15 +08:00 committed by GitHub
parent e6f3fe7bf8
commit 84de659219
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -457,6 +457,10 @@ func (svr *Service) deleteProxies(w http.ResponseWriter, r *http.Request) {
log.Infof("cleared [%d] offline proxies, total [%d] proxies", cleared, total)
}
func newProxyTraffic() *proxyTraffic {
return &proxyTraffic{lastTrafficTime: time.Now().Unix()}
}
type proxyTraffic struct {
lastTraffic int64
lastTrafficTime int64

View File

@ -749,7 +749,7 @@ func (svr *Service) checkProxyStatusTimer() {
if vv, ok := svr.proxyTraffic.Load(info.Name); ok {
vv.(*proxyTraffic).Set(info.TodayTrafficOut)
} else {
svr.proxyTraffic.Store(info.Name, new(proxyTraffic).Set(info.TodayTrafficOut))
svr.proxyTraffic.Store(info.Name, newProxyTraffic().Set(info.TodayTrafficOut))
}
}