mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6526] [MERGED] fix(outbound): read the probe protocol id and transport name like the core #6332
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#6332
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/6526
Author: @BlindMaster24
Created: 9/14/2026
Status: ✅ Merged
Merged: 9/14/2026
Merged by: @BlindMaster24
Base:
main← Head:fix/outbound-probe-protocol-case📝 Commits (2)
f7907aafix(outbound): read the probe protocol id and transport name like the corea82476cfix(outbound): read the batch probe protocol id like the core📊 Changes
3 files changed (+161 additions, -4 deletions)
View changed files
📝
internal/web/service/outbound/outbound.go(+16 -2)📝
internal/web/service/outbound/probe_http.go(+2 -2)➕
internal/web/service/outbound/probe_protocol_case_test.go(+143 -0)📄 Description
Summary
The outbound probe decides between its dial-only TCP lane and the real xray handshake probe by reading the protocol id and the stream transport name. Both readers compared those strings exactly, so a template the core is running was probed as if it were a different protocol.
Follow-up to a review finding on #6525, where the same reader was fixed in the browser.
Why
The core normalises both names before it resolves them —
infra/conf/loader.golowercases the protocol id, andTransportProtocol.Build(infra/conf/transport_internet.go:16-17) lowercases the transport name and additionally resolves both"kcp"and"mkcp"to mKCP.Scenario. An operator's config spells an outbound
"WireGuard"— pasted, or hand-edited, or written by another tool — and the core runs it without a word. Someone callsPOST /panel/api/xray/testOutboundwithmode=tcp(ortestOutbounds), as the panel itself did before #6525 and as a script polling the API still does. Then:outboundTransportIsUDPcompares"WireGuard"against"wireguard", getsfalse, and keeps the outbound in the dial-only TCP lane — the lane it exists to keep UDP transports out of, because a bare dial neither proves reachability nor measures latency for a protocol that ignores unauthenticated packets.extractOutboundEndpointsswitches on the raw protocol string, matches nocase, and returns nothing.No testable endpointfor an outbound that is passing traffic right now.The transport-name half has the same shape and an extra edge:
"network": "mkcp"is a spelling the core accepts and builds mKCP from, and it was not recognised at all. The endpoint's own documented contract (frontend/src/pages/api-docs/endpoints.ts) states thatmode=tcpgives fast dial-only probes with UDP-transport outbounds still probed over HTTP — the first step above is where that promise was broken.What changed
outboundTransportIsUDPmatches the proxy protocols and the transport names case-insensitively, and recognises themkcpalias.extractOutboundEndpointslowercases the protocol id before its switch.Not changed, deliberately — and one correction to what this description first claimed. The literal comparisons at
probe_http.go:184-188(theblackhole/loopback/freedom/dnsrejections) are still exact in this PR, and this diff stays backend-only. An earlier version of this paragraph said the panel never reaches them with a different spelling, because the frontend skips those outbounds before the request leaves the browser. That is wrong, and this PR's own review disproved it.isUntestable(frontend/src/pages/xray/outbounds/outbounds-tab-helpers.ts:57) is the only gate on the row's Test button and it compares the id exactly as well, so a"Freedom"outbound is probed through the direct outbound and the API answerssuccess: truewith the panel host's own country and delay — the operator reads the panel's own reachability as a working tunnel. That is a separate, pre-existing bug, fixed in #6527 rather than here. Theblackhole/freedomcheck intestOutboundTCP(outbound.go:160) stays exact too: it is message precision only, sinceextractOutboundEndpointsfinds no endpoint for those ids either way.Type of change
Areas affected
How was this tested?
Three new tests in
internal/web/service/outbound/, all confirmed red before the fix and green after:TestTestOutboundsTCPModeForcesCoreSpelledUDPToHTTPProbedrives the realTestOutbounds(..., "tcp")through a stub xray process and asserts the result comes back from the HTTP probe. Before:Success:false Error:"No testable endpoint" Mode:"tcp".TestOutboundTransportIsUDPMatchesTheCoreis a table over both readers' spellings —WireGuard,HYSTERIA,KCP,mkcp,MKCPmust be UDP;tcp,wsand a plainvlessmust not. Five substests fail before the fix.TestTestOutboundsTCPLaneReadsProtocolIDCaseInsensitivelyputs a"SOCKS"outbound in the TCP lane against a real local listener, so it fails on the extractor alone rather than through the lane gate.Local verification, and one honest caveat about 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 test ./internal/web/service/outbound/passes in full (the pre-existing suite included),gofmt -lis clean andgo vetis clean. Real-CGo compilation,race, the Postgres job and the build matrix are left to CI.Screenshots / recordings
N/A — backend only.
Breaking changes
None. Canonical spellings behave exactly as before; only templates the core already accepts and the probe previously misread change behaviour, and they change from a wrong answer to the right one.
Checklist
go build ./...itself needs CGo on this machine.go build ./...and the test suite pass locally. — Blocked by the missing C compiler here; CI covers it.npm run lint,npm run typecheck, andnpm run buildpass. — No frontend file is touched.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.