mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #6553] [MERGED] fix(limit-ip): leave a reverse client out of the temporary disconnect #6350
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#6350
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/6553
Author: @BlindMaster24
Created: 9/15/2026
Status: ✅ Merged
Merged: 9/15/2026
Merged by: @BlindMaster24
Base:
main← Head:fix/limit-ip-skip-reverse-clients📝 Commits (2)
234d479fix(limit-ip): leave a reverse client out of the temporary disconnecte696699style(limit-ip): keep the reverse-client comment within the 2-line cap📊 Changes
2 files changed (+44 additions, -2 deletions)
View changed files
📝
internal/web/job/check_client_ip_job.go(+11 -2)📝
internal/web/job/limit_ip_disconnect_test.go(+33 -0)📄 Description
What breaks today
disconnectClientTemporarilyhandles an over-limit client by removing it from the running Xray and adding it back 100 ms later (internal/web/job/check_client_ip_job.go:669-685). For a vless client with a reverse config that cycle cannot be undone:RemoveUser→proxy/vless/inbound/inbound.go:246→RemoveReverse(:219-226) →outboundHandlerManager.RemoveHandler(a.Reverse.Tag)(app/proxyman/outbound/outbound.go:131-146): the reverse outbound handler is deleted from the tag table.AddUser→buildUserAccount(internal/xray/api.go:544-579) buildsvless.Account{Id, Flow, Testseed, Testpre}— noReverse, even though the client config carries one.GetReverse(inbound.go:193-201) reads the account from the validator, finds no reverse and fails with "reverse: user … is not allowed to create reverse proxy"; the handler is never rebuilt, so the tunnel stays down until Xray restarts.inbound.go:542-544rejects forward-proxy use "for safety reasons" only whileaccount.Reverse != nil, so after step 2 that guard no longer fires for this client either.Reachable without unusual steps: the reverse handshake goes through
dispatcher.WrapLink, which callstrackOnlineIPwith the user's email and source IP — the same online-IP data this job scans — so a reverse client with Limit IP set is a normal candidate for a temporary disconnect.The repo already encodes this constraint elsewhere:
internal/xray/hot_diff.go:124-127refuses to hot-swap an inbound wheninboundHasReverseClientand forces a full restart, with a comment saying why. This job had no equivalent gate.The change
Skip the cycle for a client whose config carries
reverse, and log the skip instead of doing it silently:What this trades, explicitly: for a reverse client the limit violation stays until the fail2ban ban catches up, which is what actually ends live traffic anyway (the removal only refuses new handshakes for 100 ms). Breaking a tunnel that needs an Xray restart to come back is the worse of the two, and it was silent.
The alternative — carrying
reversethroughbuildUserAccountso the re-added account keeps it — is not in this PR: the removed outbound handler is not rebuilt by an account field alone, so that fix needs the core's behaviour verified against a live Xray (XRAY_E2E_BINARY), and it would change the account shape for every vless add.Red first, with the exact output
TestDisconnectClientTemporarilySkipsReverseClientdrives the function with a DB and a vless client carryingreverse, then asserts on the log: with the skip neutralised it fails because the client is removed and re-added:Green after the change, and it asserts the skip is reported (
Not disconnecting <email>), not silent — the existingTestDisconnectClientTemporarilyAllowsHysteriastill passes, so the protocol gate is untouched.Gate
go test ./internal/web/job -shuffle=on— green, 9.9 s (local run through an-overlaysupplying a pure-Go SQLite driver;go.mod/go.sumare unchanged).gofmtclean; both comment blocks within the 2-line cap.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.