diff --git a/hub/route/server.go b/hub/route/server.go index f2a52d42..fe827530 100644 --- a/hub/route/server.go +++ b/hub/route/server.go @@ -47,8 +47,10 @@ func SetEmbedMode(embed bool) { } type Traffic struct { - Up int64 `json:"up"` - Down int64 `json:"down"` + Up int64 `json:"up"` + Down int64 `json:"down"` + UpTotal int64 `json:"upTotal"` + DownTotal int64 `json:"downTotal"` } type Memory struct { @@ -380,9 +382,12 @@ func traffic(w http.ResponseWriter, r *http.Request) { for range tick.C { buf.Reset() up, down := t.Now() + upTotal, downTotal := t.Total() if err := json.NewEncoder(buf).Encode(Traffic{ - Up: up, - Down: down, + Up: up, + Down: down, + UpTotal: upTotal, + DownTotal: downTotal, }); err != nil { break } diff --git a/tunnel/statistic/manager.go b/tunnel/statistic/manager.go index 9db4601e..c69746db 100644 --- a/tunnel/statistic/manager.go +++ b/tunnel/statistic/manager.go @@ -72,6 +72,10 @@ func (m *Manager) Now() (up int64, down int64) { return m.uploadBlip.Load(), m.downloadBlip.Load() } +func (m *Manager) Total() (up, down int64) { + return m.uploadTotal.Load(), m.downloadTotal.Load() +} + func (m *Manager) Memory() uint64 { m.updateMemory() return m.memory diff --git a/tunnel/statistic/patch_android.go b/tunnel/statistic/patch_android.go deleted file mode 100644 index f1eee346..00000000 --- a/tunnel/statistic/patch_android.go +++ /dev/null @@ -1,7 +0,0 @@ -//go:build android && cmfa - -package statistic - -func (m *Manager) Total() (up, down int64) { - return m.uploadTotal.Load(), m.downloadTotal.Load() -}