Hysteria server: Fix Unix masquerade socket path - #6705
Merged
Conversation
LjhAUMEM
approved these changes
Sep 1, 2026
Collaborator
|
这里确实同步错了,感谢修复
|
TaiLerV
pushed a commit
to TaiLerV/Xray-core-fix
that referenced
this pull request
Sep 10, 2026
Upstream changes of note: - Finalmask: "udpHop" became a UDP mask of its own (XTLS#6327). UdpHop left transport.internet.QuicParams and transport/internet/hysteria/udphop moved to transport/internet/finalmask/udphop. QuicParams field numbers shifted. - Direct/Freedom: transport.internet.ProxyConfig was removed; dialerProxy is reached through sockopt (XTLS#6058, XTLS#6742). - XHTTP client: upstream fixed the WaitReadCloser data race (XTLS#6694) that this fork had already fixed independently. - Hysteria server: upstream fixed the Unix masquerade socket path (XTLS#6705), the same bug this fork fixed in merge commit 5034aab. Conflict resolutions: - core/core.go, infra/conf/transport_security.go: fork behavior kept. REALITY keeps no built-in minClientVer default; the version stamp is left at 26.9.5-0936 because stamping is a separate release step. - transport/internet/config.proto: upstream layout adopted, dropping the fork's udp_hop=5 numbering. Binary protobuf configs written by earlier fork builds must be regenerated; JSON configs are unaffected. - transport/internet/config_compat_test.go: repinned to upstream's field numbers and re-anchored to a wire blob for the current schema. The previous blob encoded the fork layout and cannot survive the renumbering. - proxy/freedom/freedom.go: upstream's resolution rewrite taken; the fork's matchIP fast path, lazy connection-opened log, and TryCloseWrite handling kept. logFreedomDialDestination and its benchmarks are gone with their call site. - transport/internet/splithttp/client.go: upstream's done.Instance implementation taken over the fork's mutex version; the fork's regression test now drives that API. - transport/internet/hysteria/hub.go: fork's empty-unix-path guard kept on top of upstream's reorder. - proxy/blackhole/blackhole_test.go: upstream's 403 and custom-response assertions kept, both tests moved onto the fork's race-free channel pattern. - transport/internet/finalmask/xdns/config.go: dead UDP() marker dropped with upstream's Udpmask interface; fork's level warnings kept. - Generated protobuf regenerated with protoc-gen-go v1.36.11 / protoc v6.33.5. Validation: go build, go vet, and vformat check are clean. go test ./... matches origin/main exactly. Five failures are reported by the full run (TestChinaSites, TestCompactDomainMatcher_PreservesMixedRuleIndices, TestIPMatcher4CN, TestGeodataConfig, TestWireguard); TestGeodataAssetConfig is a sixth, reached only once TestGeodataConfig is skipped, because its panic aborts the package first. All six reproduce identically on origin/main and are caused by the absent /resources/ geodata assets and by external network use. Race gate green on reality, proxy, vless, singmux, mux, splithttp, blackhole. checkptr=2 green. Linux/amd64 CGO_ENABLED=0 GOAMD64=v1 -trimpath build produces a working static binary. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VGewp7yHhqerRXzd1D9eev
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The current Xray code handles Unix-socket targets in the following order:
The original parsed URL is overwritten before its path is saved:
The replacement URL has an empty
Path, so the next assignment always produces:Consequently, the custom transport effectively attempts:
On Linux, this fails with an error similar to:
The Hysteria masquerade handler then returns
502 Bad Gateway, while Xray logs:This affects all supported Unix-socket target formats, not just one particular URL form, because the parsed socket path is discarded in every case.
Upstream behavior
In the upstream Hysteria implementation, the socket path is saved before constructing the synthetic HTTP target:
Only after that does it return the target used by
httputil.ReverseProxy:The custom transport therefore captures the original socket path:
The incorrect ordering was introduced while adapting this logic in #6565 it is not caused by the upstream Hysteria implementation.
Fix
Save
u.Pathbefore replacinguwith the synthetichttp://localhosttarget:This preserves the original Unix socket address while leaving HTTP and HTTPS masquerade behavior unchanged.