mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6530] [MERGED] fix(xray): read the last two inboundTag protocol ids like the core #6336
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#6336
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/6530
Author: @BlindMaster24
Created: 9/14/2026
Status: ✅ Merged
Merged: 9/14/2026
Merged by: @BlindMaster24
Base:
main← Head:fix/protocol-id-readers-red-first📝 Commits (1)
71b49e4fix(xray): read the last two inboundTag protocol ids like the core📊 Changes
4 files changed (+102 additions, -3 deletions)
View changed files
📝
internal/web/service/outbound/outbound.go(+1 -1)📝
internal/web/service/outbound/probe_protocol_case_test.go(+31 -0)📝
internal/web/service/xray_setting_routing_sync.go(+3 -2)📝
internal/web/service/xray_setting_routing_sync_test.go(+67 -0)📄 Description
Summary
Two Go readers identify an outbound by comparing its
protocolid exactly, where the core lowercases that id before resolving it. Both now compare case-insensitively.Why
An outbound's protocol id is not case-sensitive. The pinned core normalizes it —
infra/conf/loader.go,LoadWithID:id = strings.ToLower(id)— so an outbound written"Loopback"is the same outbound as"loopback"and gets the sameproxy/loopbackhandler. Two places in the panel disagreed with that, and both are reachable from the config template an operator edits.1. A renamed or deleted inbound leaves a stale
inboundTagon the loopback outboundreplaceInboundTagInOutboundsandremoveInboundTagFromOutbounds(internal/web/service/xray_setting_routing_sync.go) both open withif proto != "loopback" { continue }. A loopback outbound spelled"Loopback"is skipped by both.User story — the panel's own workflow:
vless-realityand a loopback outbound whosesettings.inboundTagpoints at it.vless-main(or delete it).settings.inboundTagstill readsvless-reality.What breaks downstream is quiet rather than loud.
infra/conf/loopback.go:15copiesinboundTaginto the generated config andproxy/loopback/loopback.go:43uses it as the inbound identity for traffic that returns through that outbound. So the config still loads — but every routing rule written againstvless-mainstops matching traffic that comes back through the loopback outbound, because that traffic is announced under a tag that no longer exists. The operator sees a rule that looks correct and does not fire.2. The probe lane's "nothing to test here" gate reports a different message for the same outbound
testOutboundTCP(internal/web/service/outbound/outbound.go:160) rejectedprotocol == "blackhole" || protocol == "freedom"exactly. A"Freedom"outbound fell through to the generic endpoint check, so the operator gotNo testable endpointwhere the canonical spelling getsOutbound has no testable endpoint— two spellings of the same outbound taking different paths to the same rejection. Both reject, so this one is message precision, not a wrong result; it is fixed here because it is the same comparison and the same file family as the rest of this series.This is the last of the readers found by auditing every place the panel reads a protocol id against the core's normalization. The panel now reads the id the way the core does in all of: the outbound test tier and endpoint extractor (#6526), the Outbounds row's testability gate and Address column (#6527, #6528), and these two.
Not changed, deliberately
server.go'sGetDefaultLogOutboundTagshas the same class of exactswitch obMap["protocol"], but it scans the embeddedconfig.json(//go:embedinsetting.go:35), whose protocols are canonical by construction — an operator cannot put"Freedom"there. No test can distinguish a case-insensitive read from an exact one on that input, so it is left alone rather than patched without evidence.internal/sub'sclash_external.goandjson_service.goare canonical by construction too: they read the map built byparseExternalLink→link.ParseLink, which assigns the literals"vmess","vless","trojan","shadowsocks","hysteria","wireguard".Type of change
Areas affected
How was this tested?
Both fixes are red-first — the test was written and watched to fail against the current code before the fix was applied, and both were re-run with the fix reverted to confirm the red is real and not incidental.
Test 1 —
TestReplaceInboundTagInOutbounds_ReadsTheProtocolIDLikeTheCore/TestRemoveInboundTagFromOutbounds_ReadsTheProtocolIDLikeTheCore(internal/web/service/xray_setting_routing_sync_test.go, table-driven, no DB):"loopback""Loopback"changed = false, tag staysold-tagchanged = true, tag isnew-tag"LOOPBACK"changed = false, tag staysold-tagchanged = true, tag isnew-tag"vmess"(control)The removal case asserts the same three spellings clear
inboundTagand that"vmess"keeps it (want the key gonevs the retained value).Test 2 —
TestTestOutboundsRejectsUntestableIDsInAnyCase(internal/web/service/outbound/probe_protocol_case_test.go), drivingTestOutboundswith a batch payload over the real code path:Reproduce the red locally:
git stashthe two non-test files, run the four tests, and the case variants fail with exactly the messages above; restore and they pass.Local gate.
gofmt -lclean on all four files,go vetclean,go build ./...clean,go test ./internal/web/service/outbound/ok, and the four new tests green. This machine has no C compiler, so the DB-backed tests ininternal/web/serviceand the CGo build itself are CI's (the panel package's DB tests cannot run locally at all — that is environmental, not this change: it fails identically on unmodifiedmain).Screenshots / recordings
N/A — backend and config-generation only, no UI change.
Breaking changes
None. Both comparisons only widen which outbounds the panel recognizes as loopback outbounds and which ids the probe gate rejects; the canonical spellings behave exactly as before, which the control cases in both tables pin.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.go build ./...passes here; the fullgo test ./...needs a C compiler for the SQLite driver, which CI has and this machine does not — same caveat as my previous PRs.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.