mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-02 19:25:05 +03:00
fix(clients): re-enable only quota-disabled clients on a traffic reset
Every traffic reset re-enabled its clients unconditionally, in the client record and in the traffic row a master treats as the client's state. A master forwards an inbound's scheduled reset and "reset all" to its nodes through the per-client reset calls, so a client disabled by hand on a node inbound came back on at the next scheduled reset. Each reset now decides, before it zeroes the counters, which of its clients the quota switched off, counting cross-panel usage, and re-enables only those; a client disabled below its quota keeps its record and traffic row off. The reset API docs say so.
This commit is contained in:
@@ -103,12 +103,12 @@ func TestResetTrafficByEmail_LeavesRecordEnableTrue(t *testing.T) {
|
||||
inboundSvc := &InboundService{}
|
||||
|
||||
email := "r-attached@x"
|
||||
c := model.Client{Email: email, ID: "11111111-1111-1111-1111-111111111111", SubID: email, Enable: false}
|
||||
c := model.Client{Email: email, ID: "11111111-1111-1111-1111-111111111111", SubID: email, Enable: false, TotalGB: 30}
|
||||
ib := mkInbound(t, 53003, model.VLESS, clientsSettings(t, []model.Client{c}))
|
||||
if err := svc.SyncInbound(nil, ib.Id, []model.Client{c}); err != nil {
|
||||
t.Fatalf("seed linkage: %v", err)
|
||||
}
|
||||
mkTraffic(t, ib.Id, email, 10, 20, 0, 0, false)
|
||||
mkTraffic(t, ib.Id, email, 10, 20, 30, 0, false)
|
||||
|
||||
if _, err := svc.ResetTrafficByEmail(inboundSvc, email); err != nil {
|
||||
t.Fatalf("ResetTrafficByEmail: %v", err)
|
||||
@@ -142,6 +142,7 @@ func TestResetTrafficByEmail_NoInbound_LeavesRecordEnableTrue(t *testing.T) {
|
||||
t.Fatalf("create record: %v", err)
|
||||
}
|
||||
forceRecordDisabled(t, svc, email)
|
||||
mkTraffic(t, 0, email, 10, 20, 30, 0, false)
|
||||
|
||||
if _, err := svc.ResetTrafficByEmail(inboundSvc, email); err != nil {
|
||||
t.Fatalf("ResetTrafficByEmail: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user