[PR #6843] [MERGED] fix(sub): pass numeric XMUX counts to Clash reuse-settings #6476

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

📋 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)

  • 97c7e40 fix(sub): pass numeric XMUX counts to Clash reuse-settings
  • df5dfed Merge 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 default maxConnections: 3 reaches Clash/mihomo clients.

Why

Closes #6841.

buildXhttpClashOpts (internal/sub/clash_service.go) copied an XMUX field into reuse-settings only when it was a string. The schema allows numbers for maxConnections and cMaxReuseTimes, and XMUX_FRESH_DEFAULTS stores maxConnections: 3 as a number, so the default XMUX config produced reuse-settings without max-connections. mihomo then puts every request on one connection.

The loop now uses nonZeroShareValue, as hKeepAlivePeriod already does, and writes the value as a string. Stream settings are decoded with json.Unmarshal, so numbers arrive as float64. Those go through strconv.FormatFloat, because fmt.Sprint would write 1000000 as 1e+06.

Type of change

  • Bug fix

Areas affected

  • Subscription (share links / Clash / JSON)

How was this tested?

  • New subtest TestBuildXhttpClashOpts_XmuxMapsToReuseSettings/NumericXmux decodes the XMUX block from JSON, as streamData does at runtime:
    • PanelDefaults uses the values the panel stores when XMUX is turned on. Without the fix it fails: reuse-settings has only h-max-request-times and h-max-reusable-secs.
    • LargeCountNotExponent fails with "1e+06" if the float branch uses fmt.Sprint.
  • go build ./... and go test -shuffle=on -count=1 ./... pass (50 packages ok). golangci-lint run reports 0 issues.

Breaking changes

None.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass. (no frontend changes)
  • I updated the Wiki / README / API docs if user-facing behavior changed. (not needed)
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 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/6843 **Author:** [@PosvdM](https://github.com/PosvdM) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/clash-xmux-numeric` --- ### 📝 Commits (2) - [`97c7e40`](https://github.com/MHSanaei/3x-ui/commit/97c7e40f2c639583c1aa4347e34eec3858a7e140) fix(sub): pass numeric XMUX counts to Clash reuse-settings - [`df5dfed`](https://github.com/MHSanaei/3x-ui/commit/df5dfededf28d3048ade043de2bb2a83fd75de11) Merge remote-tracking branch 'origin/main' into pr/6843 ### 📊 Changes **2 files changed** (+41 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `internal/sub/clash_service.go` (+9 -2) 📝 `internal/sub/clash_service_test.go` (+32 -0) </details> ### 📄 Description ## Summary The Clash subscription now passes numeric XMUX values into `reuse-settings`, so the panel's default `maxConnections: 3` reaches Clash/mihomo clients. ## Why Closes #6841. `buildXhttpClashOpts` (`internal/sub/clash_service.go`) copied an XMUX field into `reuse-settings` only when it was a string. The schema allows numbers for `maxConnections` and `cMaxReuseTimes`, and `XMUX_FRESH_DEFAULTS` stores `maxConnections: 3` as a number, so the default XMUX config produced `reuse-settings` without `max-connections`. mihomo then puts every request on one connection. The loop now uses `nonZeroShareValue`, as `hKeepAlivePeriod` already does, and writes the value as a string. Stream settings are decoded with `json.Unmarshal`, so numbers arrive as `float64`. Those go through `strconv.FormatFloat`, because `fmt.Sprint` would write 1000000 as `1e+06`. ## Type of change - [x] Bug fix ## Areas affected - [x] Subscription (share links / Clash / JSON) ## How was this tested? - New subtest `TestBuildXhttpClashOpts_XmuxMapsToReuseSettings/NumericXmux` decodes the XMUX block from JSON, as `streamData` does at runtime: - `PanelDefaults` uses the values the panel stores when XMUX is turned on. Without the fix it fails: `reuse-settings` has only `h-max-request-times` and `h-max-reusable-secs`. - `LargeCountNotExponent` fails with `"1e+06"` if the float branch uses `fmt.Sprint`. - `go build ./...` and `go test -shuffle=on -count=1 ./...` pass (50 packages ok). `golangci-lint run` reports 0 issues. ## Breaking changes None. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [ ] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. (no frontend changes) - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. (not needed) - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:09:03 +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#6476
No description provided.