mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #5855] [MERGED] fix(clients): parse only settings.clients across protocols #6009
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#6009
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/5855
Author: @n0ctal
Created: 7/8/2026
Status: ✅ Merged
Merged: 7/8/2026
Merged by: @MHSanaei
Base:
main← Head:upstream-c1-limitip📝 Commits (2)
8ab7d23fix(clients): parse only settings.clients across protocols52508ddfix(clients): reject empty inbound settings📊 Changes
6 files changed (+200 additions, -21 deletions)
View changed files
📝
internal/web/job/check_client_ip_job.go(+4 -6)📝
internal/web/job/check_client_ip_job_test.go(+37 -0)📝
internal/web/service/inbound.go(+1 -11)➕
internal/web/service/inbound_settings_clients.go(+32 -0)➕
internal/web/service/inbound_settings_clients_test.go(+124 -0)📝
internal/web/service/inbound_traffic.go(+2 -4)📄 Description
Summary
Fix the remaining inbound settings readers that decode the whole
settingsJSON object asmap[string][]model.Client.Real protocol settings include scalar protocol fields next to
clients:decryption,encryptionversionThose fields are not
[]model.Client, so decoding the whole object intomap[string][]model.Clientcan fail before callers safely usesettings.clients, or leave them relying on decoder side effects.This PR adds one shared helper that extracts only
settings.clientsthroughjson.RawMessage, then uses it from:InboundService.GetClientsInboundService.SearchClientTrafficWhy
settings.clientsis the only field these paths need. Other protocol settings should not be part of the client-list decode contract.Without this, valid inbounds with scalar protocol fields can make client lookups fail or behave by accident depending on JSON field ordering and whether the caller ignores the decode error.
Scope
ParseInboundSettingsClients.Validation
go test ./internal/web/job ./internal/web/service -count=1go test -race ./internal/web/job ./internal/web/service -run 'TestParseInboundSettingsClientsIgnoresProtocolScalarFields|TestGetClientsIgnoresProtocolScalarFields|TestSearchClientTrafficIgnoresProtocolScalarFields|TestGetInboundByEmailFallbackIgnoresProtocolScalarFields' -count=1go vet ./internal/web/job ./internal/web/servicenpm ci && npm run gen && npm run buildgo build ./...git diff --checkgolangci-lintwas not available in the local environment.Risk
Low. For valid settings, callers receive the same
clientsarray. The change only ignores unrelated protocol fields during client-list extraction. Malformed JSON still returns an error to callers that already handle parse failures.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.