mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6843] [MERGED] fix(sub): pass numeric XMUX counts to Clash reuse-settings #6476
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#6476
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/6843
Author: @PosvdM
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @MHSanaei
Base:
main← Head:fix/clash-xmux-numeric📝 Commits (2)
97c7e40fix(sub): pass numeric XMUX counts to Clash reuse-settingsdf5dfedMerge remote-tracking branch 'origin/main' into pr/6843📊 Changes
2 files changed (+41 additions, -2 deletions)
View changed files
📝
internal/sub/clash_service.go(+9 -2)📝
internal/sub/clash_service_test.go(+32 -0)📄 Description
Summary
The Clash subscription now passes numeric XMUX values into
reuse-settings, so the panel's defaultmaxConnections: 3reaches Clash/mihomo clients.Why
Closes #6841.
buildXhttpClashOpts(internal/sub/clash_service.go) copied an XMUX field intoreuse-settingsonly when it was a string. The schema allows numbers formaxConnectionsandcMaxReuseTimes, andXMUX_FRESH_DEFAULTSstoresmaxConnections: 3as a number, so the default XMUX config producedreuse-settingswithoutmax-connections. mihomo then puts every request on one connection.The loop now uses
nonZeroShareValue, ashKeepAlivePeriodalready does, and writes the value as a string. Stream settings are decoded withjson.Unmarshal, so numbers arrive asfloat64. Those go throughstrconv.FormatFloat, becausefmt.Sprintwould write 1000000 as1e+06.Type of change
Areas affected
How was this tested?
TestBuildXhttpClashOpts_XmuxMapsToReuseSettings/NumericXmuxdecodes the XMUX block from JSON, asstreamDatadoes at runtime:PanelDefaultsuses the values the panel stores when XMUX is turned on. Without the fix it fails:reuse-settingshas onlyh-max-request-timesandh-max-reusable-secs.LargeCountNotExponentfails with"1e+06"if the float branch usesfmt.Sprint.go build ./...andgo test -shuffle=on -count=1 ./...pass (50 packages ok).golangci-lint runreports 0 issues.Breaking changes
None.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass. (no frontend changes)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.