[PR #6567] [MERGED] fix(sub): send stable X-HWID on external subscription fetch #6355

Closed
opened 2026-11-02 04:08:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6567
Author: @sdhfsl
Created: 9/16/2026
Status: ✅ Merged
Merged: 9/16/2026
Merged by: @MHSanaei

Base: main ← Head: fix-external-sub-hwid


📝 Commits (7)

  • 959e6fd fix(panel): accept 2FA codes from adjacent TOTP windows
  • f3096bb fix(panel): share TOTP skew tolerance with VerifyTwoFactorCode
  • 198ac75 Merge branch 'main' into main
  • b2762e4 fix(sub): send stable X-HWID on external subscription fetch
  • 227ed81 fix(sub): address review on external X-HWID
  • 6d24fbf Merge branch 'main' into fix-external-sub-hwid
  • 0a8f116 fix(sub): drop the SQL-only X-HWID opt-out

📊 Changes

2 files changed (+110 additions, -4 deletions)

View changed files

➕ internal/sub/external_hwid_test.go (+67 -0)
📝 internal/sub/external_subscription.go (+43 -4)

📄 Description

Problem

Fixes #6559.

A Master panel fetching a donor's subscription link sends no X-HWID header (doFetchSubscriptionLinks sets only User-Agent). When the donor client has an HWID limit, EnforceHwidForSubID rejects the empty HWID (NotSupported, Allowed=false) and the donor answers 404 — Master/Donor aggregation is broken for every HWID-limited client.

Fix

  • doFetchSubscriptionLinks now sends X-HWID from new serverHwid(): a stable per-installation id (3x-ui-server-<uuid>), created once and persisted in the settings table, so the donor registers exactly one device slot for the fetching panel (no per-request randomness burning slots; no header at all when the DB is unreachable).
  • Donor side untouched — it already hashes and tracks the header correctly.

Tests

New TestServerHwidStableAcrossCalls: non-empty, expected prefix, long enough for the donor's minimum length, stable across calls, persisted in settings. Full internal/sub suite passes, go vet and gofmt clean.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6567 **Author:** [@sdhfsl](https://github.com/sdhfsl) **Created:** 9/16/2026 **Status:** ✅ Merged **Merged:** 9/16/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix-external-sub-hwid` --- ### 📝 Commits (7) - [`959e6fd`](https://github.com/MHSanaei/3x-ui/commit/959e6fd62b07efd1038d70ecc18c3bc59ce2e3c2) fix(panel): accept 2FA codes from adjacent TOTP windows - [`f3096bb`](https://github.com/MHSanaei/3x-ui/commit/f3096bb3c1e3091647101d80939da52ab054b21d) fix(panel): share TOTP skew tolerance with VerifyTwoFactorCode - [`198ac75`](https://github.com/MHSanaei/3x-ui/commit/198ac751d71b3b063a61b59efed80d50444febbf) Merge branch 'main' into main - [`b2762e4`](https://github.com/MHSanaei/3x-ui/commit/b2762e4d31d775c6d7bcaabb53c79a8f2227dadf) fix(sub): send stable X-HWID on external subscription fetch - [`227ed81`](https://github.com/MHSanaei/3x-ui/commit/227ed818b97f03b45b5555d8fdf836b14acc33fe) fix(sub): address review on external X-HWID - [`6d24fbf`](https://github.com/MHSanaei/3x-ui/commit/6d24fbfcfbbdf7ff66c98cab41c62e4bef50d50e) Merge branch 'main' into fix-external-sub-hwid - [`0a8f116`](https://github.com/MHSanaei/3x-ui/commit/0a8f116095b7ee4e1ffd5993bb8dcdf2cfe9847e) fix(sub): drop the SQL-only X-HWID opt-out ### 📊 Changes **2 files changed** (+110 additions, -4 deletions) <details> <summary>View changed files</summary> ➕ `internal/sub/external_hwid_test.go` (+67 -0) 📝 `internal/sub/external_subscription.go` (+43 -4) </details> ### 📄 Description ## Problem Fixes #6559. A Master panel fetching a donor's subscription link sends no `X-HWID` header (`doFetchSubscriptionLinks` sets only `User-Agent`). When the donor client has an HWID limit, `EnforceHwidForSubID` rejects the empty HWID (`NotSupported`, `Allowed=false`) and the donor answers 404 — Master/Donor aggregation is broken for every HWID-limited client. ## Fix - `doFetchSubscriptionLinks` now sends `X-HWID` from new `serverHwid()`: a stable per-installation id (`3x-ui-server-<uuid>`), created once and persisted in the settings table, so the donor registers exactly one device slot for the fetching panel (no per-request randomness burning slots; no header at all when the DB is unreachable). - Donor side untouched — it already hashes and tracks the header correctly. ## Tests New `TestServerHwidStableAcrossCalls`: non-empty, expected prefix, long enough for the donor's minimum length, stable across calls, persisted in settings. Full `internal/sub` suite passes, `go vet` and gofmt clean. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:08:10 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6355
No description provided.