mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #5826] [MERGED] feat(sub): auto-detect subscription format by User-Agent (Updated) #5998
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#5998
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/5826
Author: @Tomilla
Created: 7/6/2026
Status: ✅ Merged
Merged: 7/14/2026
Merged by: @MHSanaei
Base:
main← Head:feat_auto_detect_sub_url📝 Commits (9)
8bb9a8cfeat(settings): add subscription format controls9907245feat(sub): auto-detect subscription formats8a208cefix(xray): validate balancer regexes before savef19df5cRevert "fix(xray): validate balancer regexes before save"c7409bddoc(endpoints): align indent spaces054884aMerge branch 'main' into feat_auto_detect_sub_url612d732doc(settings): improve error message formatting in validateSubUserAgentRegexe53579cMerge branch 'main' into feat_auto_detect_sub_url0944dd4refactor(sub): describe UA auto-detect behavior without naming client apps📊 Changes
40 files changed (+1590 additions, -91 deletions)
View changed files
📝
frontend/public/openapi.json(+87 -0)➕
frontend/src/components/form/GoRegexInput.tsx(+63 -0)📝
frontend/src/components/form/index.ts(+1 -0)📝
frontend/src/generated/examples.ts(+10 -0)📝
frontend/src/generated/schemas.ts(+40 -0)📝
frontend/src/generated/types.ts(+10 -0)📝
frontend/src/generated/zod.ts(+10 -0)📝
frontend/src/models/setting.ts(+5 -0)📝
frontend/src/pages/api-docs/endpoints.ts(+9 -2)📝
frontend/src/pages/settings/SubscriptionFormatsTab.css(+15 -0)📝
frontend/src/pages/settings/SubscriptionFormatsTab.tsx(+70 -6)📝
frontend/src/pages/settings/SubscriptionGeneralTab.tsx(+17 -1)📝
frontend/src/schemas/setting.ts(+5 -0)➕
frontend/src/test/subscription-general-tab.test.tsx(+29 -0)📝
internal/sub/controller.go(+273 -55)📝
internal/sub/controller_test.go(+329 -0)📝
internal/sub/external_only_sub_test.go(+19 -1)📝
internal/sub/host_sub_test.go(+2 -2)📝
internal/sub/json_service.go(+2 -3)📝
internal/sub/sub.go(+54 -5)...and 20 more files
📄 Description
Summary
Adds optional User-Agent detection to serve Clash/Mihomo YAML or Xray JSON from the standard subscription URL.
The panel now exposes JSON and Clash/Mihomo endpoint paths, reverse proxy URLs, auto-detection controls, and configurable Go RE2 User-Agent patterns.
Why
Raw, JSON, and Clash subscriptions currently use separate URLs. This is inconvenient for administrators and users migrating from panels that use one subscription URL and select the response format based on the requesting client.
This change retains every existing endpoint while optionally allowing the standard subscription URL to return the appropriate format.
Auto-detection is disabled by default, preserving existing behavior.
Closes #5570
This PR also fixes a bug: when a user has enabled JSON subscription but has no place to modify the JSON subscription path, a prompt "Default JSON subscription path "/json/" is well-known - change it." is constantly displayed upon saving.
Type of change
Areas affected
How was this tested?
Automated checks:
go build ./...go test ./...npm run typechecknpm run lintnpm run test -- --run— 704 tests passednpm run buildManual subscription checks:
Screenshots / recordings
Subscription settings link
JSON and Clash/Mihomo format settings
User-Agent auto-detection
Go RE2 validation
User-Agent regex:
Breaking changes
None.
Existing subscription URLs and response behavior remain unchanged unless an administrator explicitly enables auto-detection. Existing JSON and Clash/Mihomo endpoints remain available.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.