mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #6654] [MERGED] fix(amneziawg): sniff the relay with routeOnly; scope the v6 egress to IPv6 #6399
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#6399
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/6654
Author: @rudenko-ks
Created: 9/26/2026
Status: ✅ Merged
Merged: 9/26/2026
Merged by: @MHSanaei
Base:
main← Head:fix/amneziawg-relay-routeonly📝 Commits (3)
3ca9c20fix(amneziawg): sniff the relay with routeOnlye200037fix(amneziawg): send only IPv6 targets through the peer's v6 egress5adae14Merge branch 'main' into fix/amneziawg-relay-routeonly📊 Changes
2 files changed (+34 additions, -12 deletions)
View changed files
📝
internal/web/service/xray.go(+5 -12)📝
internal/web/service/xray_config_inject_test.go(+29 -0)📄 Description
Summary
Two small fixes to the embedded AmneziaWG relay's Xray config:
routeOnly: true, so the sniffed domain drives routing only and the connection still goes to the IP the peer asked for."ip": ["::/0"]), because itssendThroughis an IPv6 address and cannot dial an IPv4 target.Why
1. Sniffing rewrote the destination.
amneziawgEgressSniffingSettings(added in #6105) turns on sniffing so that domain-based Routing rules can match traffic that arrives as bare IPs. WithoutrouteOnly, it also replaces the dial target with the sniffed SNI/Host. That breaks any client that connects to one IP while presenting another name.Telegram does exactly this. When its main connection drops, its anti-censorship recovery opens FakeTLS to
194.221.250.50:443with SNIwww.google.com. The relay re-addressed that connection towww.google.com, so it reached real Google. Telegram then looped on it: its net log showed 450TLS hash mismatchin 20 minutes while the app sat on "Connecting…" until it was killed.2. The IPv6 egress took IPv4 flows it cannot dial. For a peer with an IPv6 AllowedIP and aliases active,
injectAmneziawgV6Egressroutes all of that peer's traffic (inboundTag+user) to a freedom outbound withsendThrough: <peer v6>. An IPv4 target then fails withdial tcp: address [v6]: mismatched local address type. This already broke every IPv4 flow that sniffing does not recognise, such as DNS to1.1.1.1over UDP or TCP, and SSH. Sniffed TLS/HTTP only worked because of the rewrite in (1): the domain was dialed over IPv6. With (1) fixed, IPv4 HTTPS broke as well. That is why both changes ship together.fakednsstays indestOverride: the dispatcher still maps fake-pool IPs back to their domain regardless ofrouteOnly.Type of change
Areas affected
How was this tested?
Unit tests.
TestInjectAmneziawgnetSocks_SniffingRouteOnly(new) assertsrouteOnly: trueand the exactdestOverridelist.TestInjectAmneziawgV6Egress_CreatesOutboundAndRuleForV6Peernow assertsip: ["::/0"]. Each assertion fails without its fix and passes with it.go build ./...,go test ./internal/web/service -shuffle=on,go vet,gofumptandgolangci-lintare clean.Live test. Setup:
ens3; one peer with10.77.0.2/32plus a public/128alias from that /64.main, commit 1 only, and both commits. Dial targets were read from Xray'sinfolog.main::/0@1.1.1.1UDP / TCP194.221.250.50:443, SNIwww.google.comwww.google.comover v6, reaches real Google194.221.250.50:443from host IPv4Xray log for the FakeTLS check with both commits:
In production: commit 1 on a server behind which the Telegram hang was observed (no IPv6 peers there). Before the change, every net log had hundreds of
TLS hash mismatch. After it, the next hour of logs had none, and the same FakeTLS connection completed (TLS hello complete,connected to 194.221.250.50:443).Breaking changes
None expected. Flows now go to the IP the client resolved, and routing decisions are unchanged.
routeOnlyinbound, a freedom outbound'sdomainStrategyno longer applies to these flows, since their target is an IP.routeOnly, because the dispatcher rewrites fake-pool targets to the domain in any case. WithdomainStrategy: AsIs, such a flow does not match::/0and takes the regular outbound. Onmain, the same flow failed whenever the domain was IPv4-only.Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass. (N/A)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.