[PR #6979] [CLOSED] fix(sub): restore TUIC links in subscription downloads #6560

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6979
Author: @HamedSanaei
Created: 10/27/2026
Status: ❌ Closed

Base: main ← Head: codex/fix-tuic-cached-subscriptions


📝 Commits (1)

  • ded5910 fix(sub): retain TUIC credentials in subscription bodies

📊 Changes

2 files changed (+145 additions, -3 deletions)

View changed files

📝 internal/sub/service.go (+4 -3)
➕ internal/sub/tuic_settings_cache_test.go (+141 -0)

📄 Description

Summary

Restore TUIC links in raw subscription downloads by retaining TUIC's full inbound settings through the existing protocol-specific cache exception. This also preserves Clash's fallback for legacy TUIC credentials.

Why

The v3.11.0 subscription settings cache removes settings.clients, but TUIC's link generator still needs that array for UUID/password lookup. Browser subscription pages bypass the cache and keep showing the working link, while application downloads omit it.

TUIC accepts both the current id and legacy uuid settings keys. The existing settings parser/client synchronization can leave the normalized UUID empty for the legacy shape; Clash also relies on its existing settings fallback in that case. Keeping the complete TUIC settings, like WireGuard and AmneziaWG, restores both paths without changing credential precedence or URI generation. Other protocols continue using the shared cache.

Closes #6978

Related: #6963 contains an overlapping production fix. This PR adds HTTP-route, plaintext/Base64, legacy-UUID, and subscriber-filtering regression coverage.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

The changed behavior concerns raw and Clash subscriptions; JSON protocol support is unchanged.

How was this tested?

Regression tests use a real temporary database, the existing client synchronization service, and the actual Gin subscription controller with its default settings cache enabled.

Before the fix, the browser page contains TUIC while both plaintext and Base64 application responses drop it; the legacy-UUID Clash regression also fails. After the fix, the tests check:

  • Current id and legacy uuid settings, plaintext and Base64 responses.
  • Consecutive requests with v2rayN and Shadowrocket user agents.
  • TUIC UUID/password, reserved-character escaping, address, port, congestion control, ALPN, SNI, UDP relay mode, and TLS verification option.
  • Subscriber isolation, disabled-client exclusion, and preservation of a VLESS member in the same subscription.
  • Legacy TUIC UUID fallback in consecutive Clash downloads.

Validation:

  • Targeted TUIC/cache regression tests: passed.
  • go vet -p=2 ./...: passed.
  • FuzzParseLink and FuzzDecodeCertPin: passed, 30 seconds each.
  • make verify: passed, including Go tests/build/lint, 2,018 frontend tests, typecheck, frontend/Storybook production builds, and generation checks.
  • make race: passed across Go packages.

Manual reproduction:

  1. Create an enabled TUIC inbound and an enabled client with a subscription ID.
  2. Download /sub/<id> as a standard subscription, with automatic JSON/Clash routing disabled. Decode Base64 if configured.
  3. Confirm the tuic:// entry remains present and has the same credentials/options as the browser page.
  4. Repeat the download; confirm TUIC and other subscribed protocols remain present.

Actual v2rayN/Shadowrocket applications and live TUIC connections were not exercised locally; the regression tests cover the server responses through their production routes.

Breaking changes

None. No route, API schema, database migration, UI, dependency, or link-format changes. TUIC uses the existing full-settings read path on each subscription request; the shared client-less cache remains enabled for the other eligible protocols.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass. No frontend changes; these checks still ran.
  • I updated the Wiki / README / API docs if user-facing behavior changed. N/A: this restores the existing subscription contract; the cache-policy comment is updated.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 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/6979 **Author:** [@HamedSanaei](https://github.com/HamedSanaei) **Created:** 10/27/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `codex/fix-tuic-cached-subscriptions` --- ### 📝 Commits (1) - [`ded5910`](https://github.com/MHSanaei/3x-ui/commit/ded591028af58c0ba3352ec6efe22843ff21bca7) fix(sub): retain TUIC credentials in subscription bodies ### 📊 Changes **2 files changed** (+145 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `internal/sub/service.go` (+4 -3) ➕ `internal/sub/tuic_settings_cache_test.go` (+141 -0) </details> ### 📄 Description ## Summary Restore TUIC links in raw subscription downloads by retaining TUIC's full inbound settings through the existing protocol-specific cache exception. This also preserves Clash's fallback for legacy TUIC credentials. ## Why The v3.11.0 subscription settings cache removes `settings.clients`, but TUIC's link generator still needs that array for UUID/password lookup. Browser subscription pages bypass the cache and keep showing the working link, while application downloads omit it. TUIC accepts both the current `id` and legacy `uuid` settings keys. The existing settings parser/client synchronization can leave the normalized UUID empty for the legacy shape; Clash also relies on its existing settings fallback in that case. Keeping the complete TUIC settings, like WireGuard and AmneziaWG, restores both paths without changing credential precedence or URI generation. Other protocols continue using the shared cache. Closes #6978 Related: #6963 contains an overlapping production fix. This PR adds HTTP-route, plaintext/Base64, legacy-UUID, and subscriber-filtering regression coverage. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [ ] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [ ] Xray config generation - [x] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot The changed behavior concerns raw and Clash subscriptions; JSON protocol support is unchanged. ## How was this tested? Regression tests use a real temporary database, the existing client synchronization service, and the actual Gin subscription controller with its default settings cache enabled. Before the fix, the browser page contains TUIC while both plaintext and Base64 application responses drop it; the legacy-UUID Clash regression also fails. After the fix, the tests check: - Current `id` and legacy `uuid` settings, plaintext and Base64 responses. - Consecutive requests with v2rayN and Shadowrocket user agents. - TUIC UUID/password, reserved-character escaping, address, port, congestion control, ALPN, SNI, UDP relay mode, and TLS verification option. - Subscriber isolation, disabled-client exclusion, and preservation of a VLESS member in the same subscription. - Legacy TUIC UUID fallback in consecutive Clash downloads. Validation: - Targeted TUIC/cache regression tests: passed. - `go vet -p=2 ./...`: passed. - `FuzzParseLink` and `FuzzDecodeCertPin`: passed, 30 seconds each. - `make verify`: passed, including Go tests/build/lint, 2,018 frontend tests, typecheck, frontend/Storybook production builds, and generation checks. - `make race`: passed across Go packages. Manual reproduction: 1. Create an enabled TUIC inbound and an enabled client with a subscription ID. 2. Download `/sub/<id>` as a standard subscription, with automatic JSON/Clash routing disabled. Decode Base64 if configured. 3. Confirm the `tuic://` entry remains present and has the same credentials/options as the browser page. 4. Repeat the download; confirm TUIC and other subscribed protocols remain present. Actual v2rayN/Shadowrocket applications and live TUIC connections were not exercised locally; the regression tests cover the server responses through their production routes. ## Breaking changes None. No route, API schema, database migration, UI, dependency, or link-format changes. TUIC uses the existing full-settings read path on each subscription request; the shared client-less cache remains enabled for the other eligible protocols. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. No frontend changes; these checks still ran. - [x] I updated the Wiki / README / API docs if user-facing behavior changed. N/A: this restores the existing subscription contract; the cache-policy comment is updated. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi changed title from [PR #6979] fix(sub): restore TUIC links in subscription downloads to [PR #6979] [CLOSED] fix(sub): restore TUIC links in subscription downloads 2026-11-07 14:33:59 +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#6560
No description provided.