mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6522] [MERGED] fix(panel): read an outbound protocol id the way the core does #6329
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#6329
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/6522
Author: @BlindMaster24
Created: 9/14/2026
Status: ✅ Merged
Merged: 9/14/2026
Merged by: @MHSanaei
Base:
main← Head:fix/outbound-protocol-case📝 Commits (3)
dd7963cfix(panel): read an outbound protocol id the way the core doesf1e3a99fix(panel): never leave the direct tag on two outboundsf77f4c9fix(panel): disable the freedom controls when direct is held elsewhere📊 Changes
6 files changed (+150 additions, -21 deletions)
View changed files
📝
frontend/src/lib/xray/outbound-form-adapter.ts(+3 -1)📝
frontend/src/pages/xray/basics/BasicsTab.tsx(+14 -10)📝
frontend/src/pages/xray/basics/helpers.ts(+28 -10)📝
frontend/src/test/basics-freedom-strategy.test.ts(+35 -0)➕
frontend/src/test/basics-tab-direct-tag.test.tsx(+44 -0)📝
frontend/src/test/outbound-form-adapter.test.ts(+26 -0)📄 Description
Summary
xray-core lowercases a protocol id before it looks the handler up, so a template that spells the direct outbound
Freedomis that outbound — but the panel matched the id exactly. The outbound editor rendered it as an empty vless server, and the Basics tab could not find it and appended a second outbound taggeddirect.Why
infra/conf/loader.goin the pinned core:infra/conf/xray.go:329hands itc.Protocolfor every outbound, so the spelling never changes which handler runs. Two panel paths disagreed:The Basics tab could append a duplicate tag and stop xray from starting.
setDirectFreedomStrategyand the happy-eyeballs setter both look the direct outbound up witho?.protocol === 'freedom' && o?.tag === 'direct'and, on a miss,push({ protocol: 'freedom', tag: 'direct', settings: {} }). On a template spelledFreedomthe lookup always missed, so changing the Freedom Protocol Strategy select (or the happy-eyeballs toggle) added a seconddirectoutbound. The core rejects that outright —app/proxyman/outbound/outbound.go:115:So the panel's own settings page could leave the box unable to start xray, and every routing rule pointing at
directwould then resolve to the wrong handler.The outbound editor rendered the same outbound as an empty vless server.
rawOutboundToFormValuesswitched on the raw string and fell throughdefault:to the vless branch, so the outbounds list showed a vless server with no address; the required-address rule then refused to save it, and saving from the JSON tab would have rewritten the outbound as vless.User story: a user pastes their config into Xray Settings → JSON (or imports one) with
"protocol": "Freedom"for the direct outbound — the core accepts it and keeps running, so nothing warns. Then they open Xray → Basics and change Freedom Protocol Strategy, and the panel saves a duplicatedirect. The next restart fails withexisting tag found: direct.Type of change
Areas affected
How was this tested?
frontend/src/test/basics-freedom-strategy.test.ts— a template whose direct outbound isFreedomwithsockopt.domainStrategy: UseIPv6must reportUseIPv6and must still hold one outbound aftersetDirectFreedomStrategy(t, 'UseIPv4'), with the value landing on that outbound. Reverting the predicate to the exact match reddens exactly this test (verified by mutating it back).frontend/src/test/outbound-form-adapter.test.ts—"Freedom"parses as freedom with its settings intact and saves back as the canonical id, and"VLESS"keeps its flat vless settings. Removing the normalisation reddens this test only (1 failed | 34 passed).npm run typecheck,npm run lintandoxfmt --checkpass on the touched files.Honest note: the local
unitsuite is1155 passed, 1 failed, and the failure issrc/test/input-number-guard.test.ts, which is unrelated to this change — it also fails with my files stashed, so it is a local-environment difference in the oxlint CLI, not a regression here.Screenshots / recordings
N/A — the change is how an id is compared; the visible difference needs a config spelled
Freedom.Breaking changes
None. Nothing is rewritten on load; the editor simply reads the id the way the core does, and saving writes the canonical lowercase id the core would have used anyway.
Checklist
go build ./...and the test suite pass locally. (no Go change in this PR)npm run lintandnpm run typecheckpass, and the Vite build succeeds (npx vite build— thenpm run buildwrapper also runsgen:api, which this PR does not touch).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.