From 3deccaae00d168fd049f8a8659656664f25ee301 Mon Sep 17 00:00:00 2001 From: wyx2685 Date: Sat, 20 Sep 2025 23:15:58 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20sing/hy2=E5=86=85=E6=A0=B8=E6=B5=81?= =?UTF-8?q?=E9=87=8F=E7=94=A8=E6=88=B7=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/hy2/user.go | 8 ++++++++ core/sing/user.go | 8 ++++++++ core/xray/user.go | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/core/hy2/user.go b/core/hy2/user.go index f473e58..b48ad90 100644 --- a/core/hy2/user.go +++ b/core/hy2/user.go @@ -45,6 +45,10 @@ func (h *Hysteria2) DelUsers(users []panel.UserInfo, tag string, _ *panel.NodeIn var wg sync.WaitGroup for _, user := range users { wg.Add(1) + if v, ok := h.Hy2nodes[tag].TrafficLogger.(*HookServer).Counter.Load(tag); ok { + c := v.(*counter.TrafficCounter) + c.Delete(user.Uuid) + } go func(u panel.UserInfo) { defer wg.Done() h.Auth.mutex.Lock() @@ -76,6 +80,10 @@ func (h *Hysteria2) GetUserTrafficSlice(tag string, reset bool) ([]panel.UserTra traffic.UpCounter.Store(0) traffic.DownCounter.Store(0) } + if h.Auth.usersMap[uuid] == 0 { + c.Delete(uuid) + return true + } trafficSlice = append(trafficSlice, panel.UserTraffic{ UID: h.Auth.usersMap[uuid], Upload: up, diff --git a/core/sing/user.go b/core/sing/user.go index e271b52..8dba10f 100644 --- a/core/sing/user.go +++ b/core/sing/user.go @@ -151,6 +151,10 @@ func (b *Sing) GetUserTrafficSlice(tag string, reset bool) ([]panel.UserTraffic, traffic.UpCounter.Store(0) traffic.DownCounter.Store(0) } + if b.users.uidMap[uuid] == 0 { + c.Delete(uuid) + return true + } trafficSlice = append(trafficSlice, panel.UserTraffic{ UID: b.users.uidMap[uuid], Upload: up, @@ -199,6 +203,10 @@ func (b *Sing) DelUsers(users []panel.UserInfo, tag string, info *panel.NodeInfo b.users.mapLock.Lock() defer b.users.mapLock.Unlock() for i := range users { + if v, ok := b.hookServer.counter.Load(tag); ok { + c := v.(*counter.TrafficCounter) + c.Delete(users[i].Uuid) + } delete(b.users.uidMap, users[i].Uuid) uuids[i] = users[i].Uuid } diff --git a/core/xray/user.go b/core/xray/user.go index a81bcb1..61f383a 100644 --- a/core/xray/user.go +++ b/core/xray/user.go @@ -73,6 +73,10 @@ func (x *Xray) GetUserTrafficSlice(tag string, reset bool) ([]panel.UserTraffic, traffic.UpCounter.Store(0) traffic.DownCounter.Store(0) } + if x.users.uidMap[email] == 0 { + c.Delete(email) + return true + } trafficSlice = append(trafficSlice, panel.UserTraffic{ UID: x.users.uidMap[email], Upload: up,