fix: use MultiUserServerConfig for SS2022 with empty clients array#2
Draft
fix: use MultiUserServerConfig for SS2022 with empty clients array#2
Conversation
… no routing field Fixes XTLS#5748. When passing a valid JSON config file with no "routing" field to `xray api adrules`, `conf.RouterConfig` is nil, causing a panic on dereference. Added a nil check to exit gracefully with a descriptive error message instead. Co-authored-by: odlev <65655276+odlev@users.noreply.github.com>
Copilot stopped work on behalf of
odlev due to an error
March 6, 2026 10:52
Co-authored-by: odlev <65655276+odlev@users.noreply.github.com>
When "clients": [] is explicitly set in Shadowsocks 2022 config, create MultiUserServerConfig instead of single-user ServerConfig. This allows users to be added later via the gRPC API. Previously, both omitting "clients" and setting "clients": [] resulted in the single-user ServerConfig which doesn't implement UserManager, making it impossible to add users via gRPC API. Fixes XTLS#5766 Co-authored-by: odlev <65655276+odlev@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix easy issue in Xray-core fork
fix: use MultiUserServerConfig for SS2022 with empty clients array
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a Shadowsocks 2022 inbound is configured with
"clients": [],buildShadowsocks2022()creates a single-userServerConfig(noUserManager) instead ofMultiUserServerConfig, making it impossible to add users via gRPC API.Root cause:
len(v.Users) == 0is true for both a nil slice (field omitted) and an empty slice ("clients": []). Go's JSON unmarshaler distinguishes these — omitted yieldsnil, empty array yields[].Changes:
len(v.Users) == 0tov.Users == nilso only a truly absentclientsfield produces single-userServerConfiglen(v.Users) == 0 ||beforev.Users[0].Address == nilto prevent index-out-of-range on empty slice and correctly route toMultiUserServerConfigAdded
TestShadowsocks2022ServerConfigParsingcovering both cases.🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.