[PR #6551] [MERGED] docs(limit-ip): correct what the temporary disconnect can actually do #6349

Closed
opened 2026-11-02 04:08:07 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6551
Author: @BlindMaster24
Created: 9/15/2026
Status: ✅ Merged
Merged: 9/15/2026
Merged by: @BlindMaster24

Base: main ← Head: docs/limit-ip-disconnect-scope


📝 Commits (2)

  • baca0f0 docs(limit-ip): correct what the temporary disconnect can actually do
  • e9b31c1 docs(limit-ip): say what the disconnect cycle really does per protocol

📊 Changes

1 file changed (+6 additions, -3 deletions)

View changed files

📝 internal/web/job/check_client_ip_job.go (+6 -3)

📄 Description

What the comment claimed vs what the core does

disconnectClientTemporarily said it "removes and re-adds a client to force disconnect banned connections", and the call site repeated it ("Remove user to disconnect all connections"). Reading the core at the version this repo pins, removal cannot end a live session for any protocol the function's gate admits:

protocol (gate at check_client_ip_job.go:644) what RemoveUser reaches
vless proxy/vless/inbound/inbound.go:245 — RemoveReverse + validator.Del(e)
vmess proxy/vmess/inbound/inbound.go:177 — usersByEmail.Remove(email) + clients.Remove(email)
trojan proxy/trojan/server.go:124 — validator.Del(e)
shadowsocks proxy/shadowsocks/server.go:62 — validator.Del(e)
hysteria proxy/hysteria/server.go:66 → account/config.go:64-76 — deletes the auth and the uuid from two maps

Every one of them touches a credential store. A session was validated once at handshake and lives in its own goroutine afterwards, so it never consults that store again. The core exposes exactly two user operations — AddUserOperation and RemoveUserOperation (app/proxyman/command/command.proto) — and no KickUser, DisconnectUser or CloseUserConnections exists anywhere in the module. There is no API that closes one client's session.

What actually enforces the IP limit is one layer down: the job logs [LIMIT_IP] Email = ... || Disconnecting OLD IP = ... (:561) for the fail2ban failregex documented right above it (:557, installed by x-ui.sh / DockerEntrypoint.sh), so the banned IP is dropped in the kernel. The remove-and-re-add is a nudge at best: it makes new handshakes fail for those 100 ms.

This is the same root as #6533, which I fixed separately in #6550: the panel can only end a session by replacing the process that owns it.

What this PR changes

Comments only — three of them:

  • the function doc now says it drops the credential for a moment so new handshakes are refused, and that fail2ban is what ends live traffic;
  • the call site says RemoveUser only clears the validator, naming the five protocols;
  • "Wait a moment for disconnection to take effect" became "Keep the credential out long enough for the core to apply the removal".

Behaviour, the protocol gate and TestDisconnectClientTemporarilyAllowsHysteria are untouched — that test pins the gate, and its own comment ("the skip left over-limit Hysteria2 sessions alive until the fail2ban ban caught up") is compatible with what I describe here: the ban is what ends the session.

If you want a real immediate disconnect

Three options, my recommendation first:

  1. Leave it to fail2ban and delete the RPC + sleep. The kernel drop is already the enforcement; then disconnectClientTemporarily and its test can go, saving a gRPC round trip and 100 ms per banned client per scan. Needs your say-so because it removes a feature-shaped call.
  2. Restart Xray per violation — this is what #6550 does for a manual disable, but a cron that can fire for several clients per tick makes a full process restart expensive and disruptive, so I did not do it here.
  3. Ask upstream for a kick API. Nothing in the panel can substitute for it.

Verification

  • go test ./internal/web/job — green (local run through a -overlay supplying a pure-Go SQLite driver; the tree's go.mod/go.sum are unchanged), including TestDisconnectClientTemporarilyAllowsHysteria.
  • gofmt -l clean; the change is comment-only, so no runtime behaviour is claimed and no red-first test applies.

Not verified, stated plainly: this is a reading of the pinned xray-core sources, not a reproduction. I have no Xray binary in this environment (XRAY_E2E_BINARY unset), so I did not observe a live session surviving a removal — I observed that nothing in the code path could end one. If you want that settled empirically before deciding between the options above, say so and I will build the test.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6551 **Author:** [@BlindMaster24](https://github.com/BlindMaster24) **Created:** 9/15/2026 **Status:** ✅ Merged **Merged:** 9/15/2026 **Merged by:** [@BlindMaster24](https://github.com/BlindMaster24) **Base:** `main` ← **Head:** `docs/limit-ip-disconnect-scope` --- ### 📝 Commits (2) - [`baca0f0`](https://github.com/MHSanaei/3x-ui/commit/baca0f010079ac082299391b436385a02e98fc32) docs(limit-ip): correct what the temporary disconnect can actually do - [`e9b31c1`](https://github.com/MHSanaei/3x-ui/commit/e9b31c1a302ec8243da075eb274aab5591ef8f58) docs(limit-ip): say what the disconnect cycle really does per protocol ### 📊 Changes **1 file changed** (+6 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/job/check_client_ip_job.go` (+6 -3) </details> ### 📄 Description ## What the comment claimed vs what the core does `disconnectClientTemporarily` said it "removes and re-adds a client to **force disconnect** banned connections", and the call site repeated it ("Remove user to disconnect all connections"). Reading the core at the version this repo pins, removal cannot end a live session for any protocol the function's gate admits: | protocol (gate at `check_client_ip_job.go:644`) | what `RemoveUser` reaches | |---|---| | vless | `proxy/vless/inbound/inbound.go:245` — `RemoveReverse` + `validator.Del(e)` | | vmess | `proxy/vmess/inbound/inbound.go:177` — `usersByEmail.Remove(email)` + `clients.Remove(email)` | | trojan | `proxy/trojan/server.go:124` — `validator.Del(e)` | | shadowsocks | `proxy/shadowsocks/server.go:62` — `validator.Del(e)` | | hysteria | `proxy/hysteria/server.go:66` → `account/config.go:64-76` — deletes the auth and the uuid from two maps | Every one of them touches a credential store. A session was validated once at handshake and lives in its own goroutine afterwards, so it never consults that store again. The core exposes exactly two user operations — `AddUserOperation` and `RemoveUserOperation` (`app/proxyman/command/command.proto`) — and no `KickUser`, `DisconnectUser` or `CloseUserConnections` exists anywhere in the module. There is no API that closes one client's session. What actually enforces the IP limit is one layer down: the job logs `[LIMIT_IP] Email = ... || Disconnecting OLD IP = ...` (`:561`) for the fail2ban `failregex` documented right above it (`:557`, installed by `x-ui.sh` / `DockerEntrypoint.sh`), so the banned IP is dropped in the kernel. The remove-and-re-add is a nudge at best: it makes new handshakes fail for those 100 ms. This is the same root as #6533, which I fixed separately in #6550: the panel can only end a session by replacing the process that owns it. ## What this PR changes Comments only — three of them: * the function doc now says it drops the credential for a moment so new handshakes are refused, and that fail2ban is what ends live traffic; * the call site says `RemoveUser` only clears the validator, naming the five protocols; * "Wait a moment for disconnection to take effect" became "Keep the credential out long enough for the core to apply the removal". Behaviour, the protocol gate and `TestDisconnectClientTemporarilyAllowsHysteria` are untouched — that test pins the *gate*, and its own comment ("the skip left over-limit Hysteria2 sessions alive until the fail2ban ban caught up") is compatible with what I describe here: the ban is what ends the session. ## If you want a real immediate disconnect Three options, my recommendation first: 1. **Leave it to fail2ban and delete the RPC + sleep.** The kernel drop is already the enforcement; then `disconnectClientTemporarily` and its test can go, saving a gRPC round trip and 100 ms per banned client per scan. Needs your say-so because it removes a feature-shaped call. 2. **Restart Xray per violation** — this is what #6550 does for a manual disable, but a cron that can fire for several clients per tick makes a full process restart expensive and disruptive, so I did not do it here. 3. **Ask upstream for a kick API.** Nothing in the panel can substitute for it. ## Verification * `go test ./internal/web/job` — green (local run through a `-overlay` supplying a pure-Go SQLite driver; the tree's `go.mod`/`go.sum` are unchanged), including `TestDisconnectClientTemporarilyAllowsHysteria`. * `gofmt -l` clean; the change is comment-only, so no runtime behaviour is claimed and no red-first test applies. Not verified, stated plainly: this is a reading of the pinned `xray-core` sources, not a reproduction. I have no Xray binary in this environment (`XRAY_E2E_BINARY` unset), so I did not observe a live session surviving a removal — I observed that nothing in the code path could end one. If you want that settled empirically before deciding between the options above, say so and I will build the test. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:08:07 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6349
No description provided.