mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6558] [MERGED] fix(clients): keep a vless reverse client's handler across a re-add #6352
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#6352
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/6558
Author: @BlindMaster24
Created: 9/15/2026
Status: ✅ Merged
Merged: 9/15/2026
Merged by: @BlindMaster24
Base:
main← Head:fix/vless-reverse-survives-readd📝 Commits (2)
a54894ffix(clients): keep a vless reverse client's handler across a re-add67159b6refactor(clients): drop an account map helper nothing calls📊 Changes
6 files changed (+231 additions, -0 deletions)
View changed files
📝
internal/web/service/client_bulk.go(+1 -0)📝
internal/web/service/client_inbound_apply.go(+2 -0)➕
internal/web/service/client_reverse_readd_test.go(+149 -0)📝
internal/web/service/inbound_traffic.go(+1 -0)📝
internal/xray/api.go(+24 -0)➕
internal/xray/api_reverse_test.go(+54 -0)📄 Description
The bug
RemoveUserdoes two things to a VLESS client: it drops the credential, and itdrops the client's reverse outbound handler (
RemoveReverse→outboundManager.RemoveHandler). Every live remove/re-add path in the panelrebuilds the account from a hand-built map, and
buildUserAccountreadid,flow,testseedandtestpre— neverreverse. So a reverse clientthat was removed and added back could still authenticate, but its tunnel stayed
down until Xray restarted, with nothing logged. The account type is what decides
this:
GetReverserefuses withuser … is not allowed to create reverse proxywhen the stored account has no tag.
claude's review of #6553 found the quota path; the same defect is on fourpaths, all of which this PR fixes:
client_inbound_apply.go:1040client_bulk.go:1802inbound_traffic.go:727client_inbound_apply.go:611,runtime/local.goThe LIMIT_IP job is deliberately untouched: it now skips reverse clients entirely
(#6553), so it never removes one.
The fix
buildUserAccountcarries the tag, reading it from either shape a caller canhold — the settings JSON object or the typed client value — via a small
reverseTaghelper. The five account maps those paths build now include theclient's
reverse, and the two identical maps ininternal/web/runtime/local.gobecame one
clientUserMapso a field can no longer be missing from one of themonly.
Not changed, deliberately:
reverse — nothing is sent when the tag is empty.
internal/xray/hot_diff.go, which already refuses tohot-swap any inbound carrying a reverse client and restarts instead.
WireGuard keys). Unifying them would change what a bulk enable sends to a
WireGuard inbound, which is a behaviour change this fix does not need.
Core chain, read from the pinned
xray-coreStatic reading of
xray-core@v1.260327.1-0.20260908222543-52a412d9e2f5:AddUserOperation.ApplyInbound→op.User.ToMemoryUser()(
app/proxyman/command/command.go:38-52).User.GetTypedAccount()deserialises the typed message into the registered*vless.Account(common/protocol/user.go:8-24).vless.Account.AsAccount()copiesReverse: a.Reverseinto theMemoryAccountthe validator stores (proxy/vless/account.go:24).Handler.GetReverserebuilds the handler from the stored account'sReverse.Tagon the client's next reverse-command connection(
proxy/vless/inbound/inbound.go:193-205).No
-test/live-core run backs this:XRAY_E2E_BINARYis set by no CI job, sothe chain is a reading of the module source, not a reproduction.
Red first
Every test fails on the commit before the fix:
The four service tests drive the real service methods (
ClientService.Update,BulkSetEnable,ResetClientTraffic,AddInboundClient) against a real tempDB, with the runtime override recording the maps the panel would push.
Gate
go testoverinternal/xray,internal/web/runtime,internal/web/service,internal/web/job,internal/web/controller— green (the DB-backed servicesuite via an
-overlaysupplying a pure-Go SQLite driver;go.mod/go.sumare unchanged).
gofmtclean, added comment blocks within the 2-line cap.(
postgres-durable-firstis the CI job that would).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.