mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-19 00:27:14 +00:00
fix(clients): list HWID devices when the HWID limit is 0
EnforceHwidForSubID returned before recording anything when a sub had no limit, so the panel's HWID Devices list stayed empty for every unlimited client. Devices are now upserted on the (sub_id, hwid_hash) index without enforcement or X-Hwid-* headers; the write is best-effort and only logs on failure, so tracking can never deny a subscription nothing restricts.
This commit is contained in:
@@ -45,6 +45,23 @@ func TestClientHwidGate(t *testing.T) {
|
||||
if !res.Allowed || res.Active {
|
||||
t.Fatalf("no limit should allow missing HWID without active headers: %+v", res)
|
||||
}
|
||||
|
||||
for _, ua := range []string{"Happ/1.0", "Happ/2.0"} {
|
||||
res, err = svc.EnforceHwidForSubID("sub-hwid", HwidRequest{Hwid: "device-one", UserAgent: ua})
|
||||
if err != nil {
|
||||
t.Fatalf("no-limit gate with HWID: %v", err)
|
||||
}
|
||||
if res != (HwidGateResult{Allowed: true}) {
|
||||
t.Fatalf("no limit should allow HWID without active headers: %+v", res)
|
||||
}
|
||||
}
|
||||
list, err := svc.ListClientHwids("hwid@example.com")
|
||||
if err != nil {
|
||||
t.Fatalf("list HWIDs: %v", err)
|
||||
}
|
||||
if len(list) != 1 || list[0].UserAgent != "Happ/2.0" {
|
||||
t.Fatalf("no limit should still track one device with fresh metadata, got %+v", list)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientHwidGateRegistersAndBlocks(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user