mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6527] [MERGED] fix(outbound): read the testability gate's ids like the core #6334
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#6334
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/6527
Author: @BlindMaster24
Created: 9/14/2026
Status: ✅ Merged
Merged: 9/14/2026
Merged by: @BlindMaster24
Base:
main← Head:fix/outbound-testability-gate-case📝 Commits (1)
ab52261fix(outbound): read the probe testability gate's ids like the core📊 Changes
4 files changed (+86 additions, -4 deletions)
View changed files
📝
frontend/src/pages/xray/outbounds/outbounds-tab-helpers.ts(+4 -4)➕
frontend/src/test/outbounds-testability-gate.test.ts(+26 -0)📝
internal/web/service/outbound/probe_http.go(+2 -0)➕
internal/web/service/outbound/probe_testability_gate_test.go(+54 -0)📄 Description
Summary
The outbound probe has one gate that decides an outbound has no tunnel to test at all — direct, dns, loopback, blackhole. It compared the protocol id exactly, while the core lowercases it before resolving the handler, so a case-variant spelling slipped past the gate and the probe measured the panel host's own reachability. Both halves of that gate are fixed here: the batch gate in Go and the row's Test button in the browser.
Why
The core normalises the id —
infra/conf/loader.go,LoadWithID, at the pinned revision52a412d9e2f5:So
"Freedom"runs as freedom, and"DNS","Loopback","Blackhole"run as their lowercase ids. The panel's gate read the raw string instead.Scenario. An operator's template spells an outbound
"Freedom"— pasted from a config, written by another tool, or hand-edited in the template editor. They open the Outbounds page and click Test on that row (or a script callsPOST /panel/api/xray/testOutbounds). Then:isUntestable(frontend/src/pages/xray/outbounds/outbounds-tab-helpers.ts:57) is the only thing gating that button —enqueuein "Test All" already compares case-insensitively since #6523 — and it compared exactly, so the button stays enabled.testOutboundsParsed, whose switch (internal/web/service/outbound/probe_http.go:182-193) also compared exactly, so the outbound is not rejected and joins the HTTP batch.success: true, a real measured delay, and anEgressblock carrying the panel's own IP and country.The operator reads the panel host's own connectivity as a working tunnel. That is the one row where the honest answer is "there is nothing to test here", and a false green is worse than an error — on a DNS row it is the same false green against a resolver that may not exist.
Reproduced before the fix (stub xray process,
EgressTracestub), which is what the new test asserts:Found as a
pre-existingMEDIUM in the review of #6526 and deliberately kept out of that PR so its diff stayed backend-only; this is that finding, delivered separately.What changed
probe_http.go:182folds the id once before the switch. One line, so every comparison in that switch reads it the way the core does.outbounds-tab-helpers.ts:57routesisUntestablethrough the sharedisOutboundProtocolhelper, the same one #6523 introduced for the six other readers.Not changed, deliberately — and one correction to what this description first claimed. The TCP lane's readers (
outboundTransportIsUDPandextractOutboundEndpoints,internal/web/service/outbound/outbound.go) still compare the protocol id exactly. The first version of this paragraph called that harmless, and the review was right to reject that: it is harmless only for the untestable ids. A direct, dns, loopback or blackhole outbound is rejected by the lane gate anyway, so the only difference there isNo testable endpointinstead ofOutbound has no testable endpoint(outbound.go:160), which is why that line is left alone — no test can separate those two.It is not harmless for a working proxy, and this is the part the description got wrong. A row spelled
"VLESS"(or"Trojan","Shadowsocks","Socks","HTTP","VMess") is correctly left testable byisUntestable,isUdpOutboundpasses the mode through astcp,extractOutboundEndpointsmatches nocaseatoutbound.go:251-288and the caller is toldNo testable endpointfor an outbound that tunnels fine — a working tunnel read as broken. That is the same defect in the opposite direction, and it is #6526's subject (open), whereTestTestOutboundsTCPLaneReadsProtocolIDCaseInsensitivelygoes red on exactly this. It is not this diff, so it is not fixed here.One more reader in this family is reported and left alone:
outboundAddresses(frontend/src/pages/xray/outbounds/outbounds-tab-helpers.ts:28) still switches ono.protocolwith exact labels, so a case-variant row renders an empty Address column in all three tables that use it. Display-only and pre-existing; widening this PR for it would be a different change.Type of change
Areas affected
How was this tested?
Two new tests, both confirmed red before the fix and green after — the assertions enumerate the outcome, they do not settle for
err != nil:internal/web/service/outbound/probe_testability_gate_test.go—TestTestOutboundsRejectsCaseVariantUntestableIDsdrives the realTestOutbounds(..., "http")through a stub xray process and anEgressTracestub, over six spellings. Before the fix, five of the six failed withsuccess=true err="" egress=&{IPv4:198.51.100.2 Country:ZZ}; the sixth (freedom) is the control that the canonical path is unchanged. After: all six return the exact rejection string.frontend/src/test/outbounds-testability-gate.test.ts— twelve cases over the same spellings plus proxies that must stay testable (vless,VMess,Trojan,Socks). Before the fix, eight failed (expected false to be true); the four proxy cases passed either way and are the guard against over-correcting the gate. After: 12/12.Local verification, and how. This machine has no C compiler, and
internal/databaseis a dependency of the package, so it does not build withCGO_ENABLED=0on its own —internal/database/db.go:2812calls the cgo-onlysqlite3.SQLiteConn.Backup. I verified withgo test -overlaypointing at a copy ofdb.goin which that one call is replaced by an error return; no file this PR changes is substituted, only that single cgo call. Under that rig:go build ./...— clean.go test ./internal/web/service/outbound/— ok, the pre-existing suite included.gofmt -landgo vet— clean.npm run lint(0 warnings, 0 errors),npm run format:check,npm run typecheck— all clean; theunitvitest project 23/23 including the new file;npm run buildandnpm run build-storybook— both pass, andgen:apileft no generated artefact dirty.Left to CI, honestly: real-CGo compilation,
race(the detector needs cgo, so it cannot run here at all), the Postgres job, and thestorybookvitest project — chromium is not installed in this environment. Thecomponentsproject runs 54 of 55 files green; the one failure isinbound-form-modal.test.tsx › blocks adding TLS without a certificate, a 5s timeout that reproduces only inside the full-suite run and passes when the file is run alone. That file imports nothing this PR touches (zero references toisUntestableoroutbounds-tab-helpers), and the new test is a.test.ts, so it belongs to theunitproject rather thancomponents— a pre-existing load-sensitive timeout, not a finding of this change.Screenshots / recordings
N/A — the visible effect is the row's Test button being disabled instead of returning a green result; the assertions in
outbounds-testability-gate.test.tscover it, and no UI markup changed.Breaking changes
None. Every canonical spelling behaves exactly as before; only templates the core already accepts and the gate previously misread change behaviour, and they change from a wrong answer to the right one. The rejection strings are untouched, and no endpoint, request shape or response field changed.
Checklist
go build ./...and the test suite pass locally. —go build ./...passes under the overlay rig; the CGo build itself needs a C compiler this machine does not have, so CI covers it.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.