mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-19 16:30:07 +08:00
chore: add upTotal and downTotal data to /traffic restful api
This commit is contained in:
parent
9df8392c65
commit
d8dcaa7500
@ -49,6 +49,8 @@ func SetEmbedMode(embed bool) {
|
|||||||
type Traffic struct {
|
type Traffic struct {
|
||||||
Up int64 `json:"up"`
|
Up int64 `json:"up"`
|
||||||
Down int64 `json:"down"`
|
Down int64 `json:"down"`
|
||||||
|
UpTotal int64 `json:"upTotal"`
|
||||||
|
DownTotal int64 `json:"downTotal"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Memory struct {
|
type Memory struct {
|
||||||
@ -380,9 +382,12 @@ func traffic(w http.ResponseWriter, r *http.Request) {
|
|||||||
for range tick.C {
|
for range tick.C {
|
||||||
buf.Reset()
|
buf.Reset()
|
||||||
up, down := t.Now()
|
up, down := t.Now()
|
||||||
|
upTotal, downTotal := t.Total()
|
||||||
if err := json.NewEncoder(buf).Encode(Traffic{
|
if err := json.NewEncoder(buf).Encode(Traffic{
|
||||||
Up: up,
|
Up: up,
|
||||||
Down: down,
|
Down: down,
|
||||||
|
UpTotal: upTotal,
|
||||||
|
DownTotal: downTotal,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,6 +72,10 @@ func (m *Manager) Now() (up int64, down int64) {
|
|||||||
return m.uploadBlip.Load(), m.downloadBlip.Load()
|
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 {
|
func (m *Manager) Memory() uint64 {
|
||||||
m.updateMemory()
|
m.updateMemory()
|
||||||
return m.memory
|
return m.memory
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
//go:build android && cmfa
|
|
||||||
|
|
||||||
package statistic
|
|
||||||
|
|
||||||
func (m *Manager) Total() (up, down int64) {
|
|
||||||
return m.uploadTotal.Load(), m.downloadTotal.Load()
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user