mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-03-05 13:37:30 +00:00
chore: add upTotal and downTotal data to /traffic restful api
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user