[GH-ISSUE #6820] [Bug]: Node still rebuilds Shadowsocks inbounds on every pushed client change (follow-up to #6795) #4540

Closed
opened 2026-10-31 20:40:23 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @tradeahadi-cmyk on GitHub (Oct 14, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6820

Describe the bug

Summary

Thanks for the fix in #6795 (commit 4408333, released in v3.10.0). It works for VLESS: the node now applies pushed client changes in place and nobody on that port drops.

Shadowsocks inbounds are still rebuilt. Every time the master pushes a client change (auto-disable on traffic/expiry, renew, reset, add, edit), the node does DelInbound + AddInbound on the Shadowsocks inbound, the listener closes, and every live connection on that port drops. The same happens on a local (non-node) inbound saved from the Edit Inbound form.

Environment

  • 3x-ui v3.10.0 (also checked current main/dev, f8b72de)
  • Master + node setup, master on PostgreSQL
  • One VLESS (XHTTP) inbound and one multi-user Shadowsocks inbound with the same ~2,600 clients, 600-700 online at once

Steps to reproduce

  1. Master + one node, a multi-user Shadowsocks inbound on the node with some clients.
  2. Connect a few clients to it and keep them connected.
  3. On the master, disable one client (or let one hit its traffic/expiry limit, or add a new client).
  4. Watch the node's log and the connected clients.

Expected

Like VLESS since v3.10.0: only the changed client is removed/added through the Xray API, the listener stays up, other users keep their connections.

Actual

The node logs the inbound being deleted and re-added, and every client on the Shadowsocks port is disconnected. With thousands of clients, auto-disables happen often, so Shadowsocks users drop many times a day while VLESS users on the same node no longer do.

Root cause

internal/xray/hot_diff.go line 237 (same on v3.10.0 and dev):

var userDiffableProtocols = map[string]struct{}{"vless": {}, "vmess": {}, "trojan": {}, "hysteria": {}, "masque": {}}

diffInboundUsers (line 245) returns false for any protocol not in this map, so InboundUserOps fails and applyInboundUserOps in internal/web/service/inbound.go (around lines 2162 and 2238) falls through to rt.DelInbound + rt.AddInbound. ComputeHotDiff (used by tryHotApply in internal/web/service/xray.go) has the same limit. TestComputeHotDiff_ClientChangeFallsBackToReplace in hot_diff_test.go even uses "shadowsocks" as the example of an unsupported protocol.

But per-user Shadowsocks changes are already supported elsewhere in the panel:

  • buildUserAccount in internal/xray/api.go (case "shadowsocks", ~line 657) builds both legacy AEAD and 2022 accounts, with tests in api_shadowsocks_test.go.
  • XrayAPI.AddUser (~line 773) already handles the legacy Shadowsocks duplicate-email case.
  • The Clients page / client APIs already add and remove Shadowsocks users live with rt.AddUser / rt.RemoveUser.
  • Xray-core's multi-user Shadowsocks inbounds (legacy AEAD and shadowsocks_2022 multi-user) implement AddUser/RemoveUser through HandlerService.AlterInbound.

So the hot path is simply not enabled for Shadowsocks.

Suggested fix

  1. Add "shadowsocks" to userDiffableProtocols for multi-user inbounds (settings.clients present). Any change outside settings.clients (method, server password for 2022, network, etc.) is already caught by the oldRest/newRest compare and still rebuilds.
  2. Make sure the user map the diff emits carries the cipher. shadowsocksCipherName reads "cipher" or "method"; HealShadowsocksClientMethods writes "method" onto legacy-cipher clients, but 2022 clients may not have it. Copying the inbound's settings.method into each emitted UserOp.User for shadowsocks would cover both. (If it is missing today, AddUser errors and the code already falls back to a rebuild, so this is safe either way.)
  3. Flip the "unsupported protocol" test case to another protocol and add a Shadowsocks case (legacy + 2022) to the in-place tests and TestXrayAPI_E2E_Users.

Happy to test a build on a node with real load.

How to reproduce the problem

  1. Master + one node, a multi-user Shadowsocks inbound on the node with some clients.
  2. Connect a few clients to it and keep them connected.
  3. On the master, disable one client (or let one hit its traffic/expiry limit, or add a new client).
  4. Watch the node's log and the connected clients.

Expected behavior

Like VLESS since v3.10.0: only the changed client is removed/added through the Xray API, the listener stays up, other users keep their connections.

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.10

Xray-core version

25.10.10

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24

Which parts of the panel are affected?

No response

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

None

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @tradeahadi-cmyk on GitHub (Oct 14, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6820 ### Describe the bug ### Summary Thanks for the fix in #6795 (commit 4408333, released in v3.10.0). It works for VLESS: the node now applies pushed client changes in place and nobody on that port drops. Shadowsocks inbounds are still rebuilt. Every time the master pushes a client change (auto-disable on traffic/expiry, renew, reset, add, edit), the node does DelInbound + AddInbound on the Shadowsocks inbound, the listener closes, and every live connection on that port drops. The same happens on a local (non-node) inbound saved from the Edit Inbound form. ### Environment - 3x-ui v3.10.0 (also checked current main/dev, f8b72de) - Master + node setup, master on PostgreSQL - One VLESS (XHTTP) inbound and one multi-user Shadowsocks inbound with the same ~2,600 clients, 600-700 online at once ### Steps to reproduce 1. Master + one node, a multi-user Shadowsocks inbound on the node with some clients. 2. Connect a few clients to it and keep them connected. 3. On the master, disable one client (or let one hit its traffic/expiry limit, or add a new client). 4. Watch the node's log and the connected clients. ### Expected Like VLESS since v3.10.0: only the changed client is removed/added through the Xray API, the listener stays up, other users keep their connections. ### Actual The node logs the inbound being deleted and re-added, and every client on the Shadowsocks port is disconnected. With thousands of clients, auto-disables happen often, so Shadowsocks users drop many times a day while VLESS users on the same node no longer do. ### Root cause `internal/xray/hot_diff.go` line 237 (same on v3.10.0 and dev): var userDiffableProtocols = map[string]struct{}{"vless": {}, "vmess": {}, "trojan": {}, "hysteria": {}, "masque": {}} `diffInboundUsers` (line 245) returns false for any protocol not in this map, so `InboundUserOps` fails and `applyInboundUserOps` in `internal/web/service/inbound.go` (around lines 2162 and 2238) falls through to `rt.DelInbound` + `rt.AddInbound`. `ComputeHotDiff` (used by `tryHotApply` in `internal/web/service/xray.go`) has the same limit. `TestComputeHotDiff_ClientChangeFallsBackToReplace` in hot_diff_test.go even uses "shadowsocks" as the example of an unsupported protocol. But per-user Shadowsocks changes are already supported elsewhere in the panel: - `buildUserAccount` in `internal/xray/api.go` (case "shadowsocks", ~line 657) builds both legacy AEAD and 2022 accounts, with tests in api_shadowsocks_test.go. - `XrayAPI.AddUser` (~line 773) already handles the legacy Shadowsocks duplicate-email case. - The Clients page / client APIs already add and remove Shadowsocks users live with `rt.AddUser` / `rt.RemoveUser`. - Xray-core's multi-user Shadowsocks inbounds (legacy AEAD and shadowsocks_2022 multi-user) implement AddUser/RemoveUser through HandlerService.AlterInbound. So the hot path is simply not enabled for Shadowsocks. ### Suggested fix 1. Add "shadowsocks" to `userDiffableProtocols` for multi-user inbounds (settings.clients present). Any change outside settings.clients (method, server password for 2022, network, etc.) is already caught by the `oldRest`/`newRest` compare and still rebuilds. 2. Make sure the user map the diff emits carries the cipher. `shadowsocksCipherName` reads "cipher" or "method"; `HealShadowsocksClientMethods` writes "method" onto legacy-cipher clients, but 2022 clients may not have it. Copying the inbound's settings.method into each emitted UserOp.User for shadowsocks would cover both. (If it is missing today, AddUser errors and the code already falls back to a rebuild, so this is safe either way.) 3. Flip the "unsupported protocol" test case to another protocol and add a Shadowsocks case (legacy + 2022) to the in-place tests and TestXrayAPI_E2E_Users. Happy to test a build on a node with real load. ### How to reproduce the problem 1. Master + one node, a multi-user Shadowsocks inbound on the node with some clients. 2. Connect a few clients to it and keep them connected. 3. On the master, disable one client (or let one hit its traffic/expiry limit, or add a new client). 4. Watch the node's log and the connected clients. ### Expected behavior Like VLESS since v3.10.0: only the changed client is removed/added through the Xray API, the listener stays up, other users keep their connections. ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.10 ### Xray-core version 25.10.10 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24 ### Which parts of the panel are affected? _No response_ ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? None ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:40:23 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Oct 14, 2026):

You're right: this is a real bug, and it is still in the code on main (f8b72de9). The in-place client update added for #6795 only runs for a fixed list of protocols, and Shadowsocks is not on it. So any client change on a multi-user Shadowsocks inbound still goes through DelInbound + AddInbound, and every connection on that port drops.

How a pushed client change reaches the rebuild:

  1. The node's UpdateInbound first tries applyInboundUserOps (internal/web/service/inbound.go:2162).
  2. That function returns false as soon as xray.InboundUserOps returns !ok (inbound.go:2239-2241).
  3. InboundUserOps calls diffInboundUsers, which rejects any protocol missing from this map (internal/xray/hot_diff.go:237, :245):
    var userDiffableProtocols = map[string]struct{}{"vless": {}, "vmess": {}, "trojan": {}, "hysteria": {}, "masque": {}}
    ...
    if _, ok := userDiffableProtocols[oldIb.Protocol]; !ok {
    	return false
    }
    
  4. Control then falls through to rt.DelInbound / rt.AddInbound (inbound.go:2166-2172), which closes the listener.

The commit that fixed #6795 (44083338, in v3.10.0) lists only those five protocols ("When only settings.clients differ (vless, vmess, trojan, hysteria, masque)"). Nothing in it says Shadowsocks was left out on purpose. The per-user Shadowsocks API path already exists and other client operations use it:

  • buildUserAccount builds both the 2022 account and the legacy AEAD account (internal/xray/api.go:657-681).
  • XrayAPI.AddUser already handles the legacy duplicate-user case (api.go:773-775).

Your second point is correct too, and it matters for the fix. The user map that diffInboundUsers emits is the raw client object from settings.clients (hot_diff.go:271, :276). For 2022 ciphers, HealShadowsocksClientMethods deliberately removes method from each client (internal/database/model/model.go:626-628). shadowsocksCipherName (api.go:532-541) would then return "" and the account build would fail with unknown cipher. Adding "shadowsocks" to the map alone would therefore keep rebuilding 2022 inbounds. It would not break anything, because a failed AddUser falls back to a rebuild, but it would not fix them. Every other per-user Shadowsocks path already puts the inbound's method into user["cipher"], for example internal/web/service/inbound_traffic.go:374 and client_inbound_apply.go:613.

Verdict: Confirmed bug
Severity: High
Confidence: High
Root cause: internal/xray/hot_diff.go:237 / diffInboundUsers at :245. userDiffableProtocols leaves out shadowsocks, so a multi-user Shadowsocks inbound whose only change is in settings.clients is never diffed per user and gets rebuilt. It came in with e5b56c94 ("fix(xray): reconcile client auto-disable through the API instead of a forced restart"), and 44083338 reused it for the node push path.
Same class: (a) ComputeHotDiff → diffInbounds → diffInboundUsers (hot_diff.go:155): the config-diff hot-apply path also removes and re-adds a Shadowsocks inbound for a client-only change, instead of applying per-user ops. (b) A local inbound saved from the Edit Inbound form takes the same applyInboundUserOps → DelInbound / AddInbound route (inbound.go:2161-2172), as you describe.
Already fixed: Still present on the default branch (f8b72de9) and in v3.10.0.
Duplicate of: Related: #6795 (the same fix, for the other protocols)
Evidence: hot_diff.go:237, :245, :271; inbound.go:2162, :2239-2241, :2166-2172; api.go:532-541, :657-681; model.go:626-628; TestComputeHotDiff_ClientChangeFallsBackToReplace (internal/xray/hot_diff_test.go:243-245) uses "shadowsocks" as its "unsupported protocol" example. That test only uses Shadowsocks as a protocol not on the list; it does not argue that Shadowsocks should be rebuilt.
Not determined: Whether every Xray-core build in use (you report 25.10.10) applies AlterInbound add/remove-user cleanly on a legacy multi-user Shadowsocks inbound. An end-to-end check against a real core settles it, for example a Shadowsocks case in TestXrayAPI_E2E_Users.

Suggested fix: Add shadowsocks to userDiffableProtocols, and have diffInboundUsers copy the inbound's settings.method into each emitted Shadowsocks UserOp.User as cipher. That fixes the node push path, the local edit path and ComputeHotDiff together. Changing method, the 2022 server password or network is already caught by the oldRest/newRest compare and still triggers a rebuild. Without the cipher injection, 2022 inbounds would keep falling back to a rebuild.

@MHSanaei

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:6166122162 --> @github-actions[bot] commented on GitHub (Oct 14, 2026): You're right: this is a real bug, and it is still in the code on `main` (f8b72de9). The in-place client update added for #6795 only runs for a fixed list of protocols, and Shadowsocks is not on it. So any client change on a multi-user Shadowsocks inbound still goes through `DelInbound` + `AddInbound`, and every connection on that port drops. How a pushed client change reaches the rebuild: 1. The node's `UpdateInbound` first tries `applyInboundUserOps` (`internal/web/service/inbound.go:2162`). 2. That function returns `false` as soon as `xray.InboundUserOps` returns `!ok` (`inbound.go:2239-2241`). 3. `InboundUserOps` calls `diffInboundUsers`, which rejects any protocol missing from this map (`internal/xray/hot_diff.go:237`, `:245`): ```go var userDiffableProtocols = map[string]struct{}{"vless": {}, "vmess": {}, "trojan": {}, "hysteria": {}, "masque": {}} ... if _, ok := userDiffableProtocols[oldIb.Protocol]; !ok { return false } ``` 4. Control then falls through to `rt.DelInbound` / `rt.AddInbound` (`inbound.go:2166-2172`), which closes the listener. The commit that fixed #6795 (`44083338`, in v3.10.0) lists only those five protocols ("When only settings.clients differ (vless, vmess, trojan, hysteria, masque)"). Nothing in it says Shadowsocks was left out on purpose. The per-user Shadowsocks API path already exists and other client operations use it: - `buildUserAccount` builds both the 2022 account and the legacy AEAD account (`internal/xray/api.go:657-681`). - `XrayAPI.AddUser` already handles the legacy duplicate-user case (`api.go:773-775`). Your second point is correct too, and it matters for the fix. The user map that `diffInboundUsers` emits is the raw client object from `settings.clients` (`hot_diff.go:271`, `:276`). For 2022 ciphers, `HealShadowsocksClientMethods` deliberately removes `method` from each client (`internal/database/model/model.go:626-628`). `shadowsocksCipherName` (`api.go:532-541`) would then return `""` and the account build would fail with `unknown cipher`. Adding `"shadowsocks"` to the map alone would therefore keep rebuilding 2022 inbounds. It would not break anything, because a failed `AddUser` falls back to a rebuild, but it would not fix them. Every other per-user Shadowsocks path already puts the inbound's method into `user["cipher"]`, for example `internal/web/service/inbound_traffic.go:374` and `client_inbound_apply.go:613`. Verdict: Confirmed bug Severity: High Confidence: High Root cause: `internal/xray/hot_diff.go:237` / `diffInboundUsers` at `:245`. `userDiffableProtocols` leaves out `shadowsocks`, so a multi-user Shadowsocks inbound whose only change is in `settings.clients` is never diffed per user and gets rebuilt. It came in with `e5b56c94` ("fix(xray): reconcile client auto-disable through the API instead of a forced restart"), and `44083338` reused it for the node push path. Same class: (a) `ComputeHotDiff` → `diffInbounds` → `diffInboundUsers` (`hot_diff.go:155`): the config-diff hot-apply path also removes and re-adds a Shadowsocks inbound for a client-only change, instead of applying per-user ops. (b) A local inbound saved from the Edit Inbound form takes the same `applyInboundUserOps` → `DelInbound` / `AddInbound` route (`inbound.go:2161-2172`), as you describe. Already fixed: Still present on the default branch (f8b72de9) and in v3.10.0. Duplicate of: Related: #6795 (the same fix, for the other protocols) Evidence: `hot_diff.go:237`, `:245`, `:271`; `inbound.go:2162`, `:2239-2241`, `:2166-2172`; `api.go:532-541`, `:657-681`; `model.go:626-628`; `TestComputeHotDiff_ClientChangeFallsBackToReplace` (`internal/xray/hot_diff_test.go:243-245`) uses `"shadowsocks"` as its "unsupported protocol" example. That test only uses Shadowsocks as a protocol not on the list; it does not argue that Shadowsocks should be rebuilt. Not determined: Whether every Xray-core build in use (you report 25.10.10) applies `AlterInbound` add/remove-user cleanly on a legacy multi-user Shadowsocks inbound. An end-to-end check against a real core settles it, for example a Shadowsocks case in `TestXrayAPI_E2E_Users`. Suggested fix: Add `shadowsocks` to `userDiffableProtocols`, and have `diffInboundUsers` copy the inbound's `settings.method` into each emitted Shadowsocks `UserOp.User` as `cipher`. That fixes the node push path, the local edit path and `ComputeHotDiff` together. Changing `method`, the 2022 server `password` or `network` is already caught by the `oldRest`/`newRest` compare and still triggers a rebuild. Without the cipher injection, 2022 inbounds would keep falling back to a rebuild. @MHSanaei *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
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#4540
No description provided.