mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6874] [Bug]: TUIC inbound currently does not follow per-user routing rules #4567
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#4567
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?
Originally created by @DimkaTsv on GitHub (Oct 19, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6874
Describe the bug
TUIC inbound traffic does not follow routing rules that are based on USER tag.
In other words, if i have this set of rules:
then TUIC traffic will always follow rule 3, ignoring first two, as it does not see user tags.
For comparison, AmneziaWG traffic, while also comes from external module, does follow them properly, even if it does not show actual USER in access logs.
P.S. Also, is it possible to make user from such connection to be shown in access logs? Currently all connections come from 127.0.0.1 without user marking, making it harder to debug rules.
How to reproduce the problem
3.1 USER_1 -> outbound_1
3.2 USER_1 + TUIC / AWG inbounds -> outbound_1
3.3 TUIC / AWG inbounds -> outbound_2
Expected behavior
TUIC should not be an exception from routing rules category.
USER based routing should apply to it as well.
Actual behavior
Currently TUIC ignores any rule that routes based on USER tag. Instead it mostly follows IP/Domain/Inbound rules.
Relevant logs
Screenshots
No response
3x-ui version
3.10.2
Xray-core version
26.10.10
How did you install 3x-ui?
install.sh script
Operating system
Debian 13
Which parts of the panel are affected?
Backend (API endpoints, login, settings)
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
No — direct access
Before submitting
@github-actions[bot] commented on GitHub (Oct 19, 2026):
Confirmed. The source shows exactly what you describe: TUIC traffic reaches Xray through a loopback SOCKS5 inbound set to
"auth":"noauth". Xray never authenticates a user on that connection, souserrouting rules can't match TUIC traffic. Rules that match only the inbound tag, IP or domain still work. AmneziaWG works because its relay inbound uses password auth with one account per peer email.How it happens
The TUIC server already passes each client's email as the SOCKS username, both for TCP (
internal/tuic/server.go:593) and UDP (internal/tuic/udp_associations.go:93):socks5Handshake(internal/tuic/socks_bridge.go:337) offers both "no auth" and "username/password", and accepts whichever one the server picks. The Xray inbound that panel generates for TUIC is noauth (internal/web/service/xray.go:816):Xray therefore picks "no auth" (
case 0x00: // no auth→return nil). The email is never sent, and the session has no user attached.AmneziaWG does this differently.
injectAmneziawgnetSocks(internal/web/service/xray.go:787-797) collects peer emails and callsamneziawgnet.SocksInboundSettings(emails, amneziawgnet.SocksPassword()). The result isauth: passwordwithaccounts[].user = email, so Xray attaches the user anduserrules match.The TUIC package already has the matching helper,
tuic.SocksInboundSettings(internal/tuic/socks_bridge.go:564, "one username/password account per email"), and the relay already holdsSocksPassword()(internal/tuic/manager.go:108). Nothing calls that helper, though.injectTuicSocksnever builds an account list. The per-user plumbing is half built rather than deliberately left out. The only thing pinningnoauthisinternal/web/service/inbound_tuic_test.go:76, which asserts the current value. No comment in the source explains why it would be intended.There's no workaround inside the panel. Until this is fixed, route TUIC traffic with inbound-tag, IP or domain rules, or give the users that need special routing their own TUIC inbound.
Suggested fix: In
injectTuicSocks, generate the inbound the wayinjectAmneziawgnetSocksdoes: calltuic.SocksInboundSettings(emails, tuic.SocksPassword())with the emails of the inbound's enabled clients (the same setDesiredTuicInstanceskeeps). Updateinbound_tuic_test.goto match. One side effect to account for:inboundUsesSocksAccounts(internal/xray/hot_diff.go:408) forces a full Xray restart when an account-carrying SOCKS inbound changes. With this fix, TUIC client edits would restart Xray just as AmneziaWG edits do. The SOCKS account list must also stay in sync with the TUIC registry, or a newly added client would fail the relay handshake.This reply was generated automatically; a maintainer may follow up.