mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6304] [MERGED] feat(sub): leastLoad member weights for subscription balancers #6214
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#6214
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/6304
Author: @DIMFLIX
Created: 8/24/2026
Status: ✅ Merged
Merged: 9/2/2026
Merged by: @MHSanaei
Base:
main← Head:feat/sub-balancer-weights📝 Commits (10+)
5ca7b7cfeat(model): add MemberWeights to SubBalancerb46f14bfeat(sub): accept memberWeights on the sub-balancer API7c54352feat(sub): emit leastLoad strategy costs from member weightsa746493feat(sub-balancers): leastLoad member weight inputs2cef3d1docs(api): document memberWeights on sub-balancers6b19963fix(api-docs): use the allowed object ParamType for memberWeightsb7de258fix(sub-balancers): cap the member-weight list height3480dadfix(sub): anchor leastLoad cost matches to exact member tagsbefbf7dfix(sub-balancers): keep member weights across the enabled toggle3d05e8cfix(sub-balancers): address review on member weights📊 Changes
32 files changed (+525 additions, -15 deletions)
View changed files
📝
docs/content/docs/en/reference/api/subscription-balancers.mdx(+6 -4)📝
docs/public/openapi.json(+13 -1)📝
frontend/public/openapi.json(+13 -1)📝
frontend/src/api/queries/useSubBalancerMutations.ts(+12 -4)📝
frontend/src/generated/examples.ts(+1 -0)📝
frontend/src/generated/schemas.ts(+7 -0)📝
frontend/src/generated/types.ts(+1 -0)📝
frontend/src/generated/zod.ts(+1 -0)📝
frontend/src/pages/api-docs/endpoints.ts(+7 -1)📝
frontend/src/pages/settings/SubBalancerFormModal.tsx(+73 -2)📝
frontend/src/pages/settings/SubscriptionBalancersTab.tsx(+1 -0)📝
frontend/src/schemas/subBalancer.ts(+10 -0)📝
frontend/src/test/sub-balancer-form-modal.test.tsx(+72 -0)📝
internal/database/model/model.go(+4 -1)📝
internal/sub/json_service.go(+43 -1)📝
internal/sub/sub_balancer_test.go(+88 -0)📝
internal/web/controller/sub_balancer.go(+11 -0)📝
internal/web/service/sub_balancer.go(+35 -0)📝
internal/web/service/sub_balancer_test.go(+88 -0)📝
internal/web/translation/ar-EG.json(+3 -0)...and 12 more files
📄 Description
Summary
Adds admin-configurable static weights (xray
costs) to sub-balancers, applied only when the strategy isleastLoad— the only strategy whoseStrategySettingsObjectsupports them.SubBalancer.MemberWeights map[int]float64, same gorm json-serializer pattern asInboundIds; AutoMigrate adds the column on every dialect. Absent entries mean weight 1.0; old balancers keep working unchanged.memberWeights":"{"3":0.2}"). Validation: weights with any strategy butleastLoadare rejected (xray would silently ignore them); weights <= 0 are rejected — xray's WeightManager derives a bogus auto-weight from the first digit of the matched tag when value is not > 0; entries for inbounds no longer selected are dropped on save.^bal-N-tag$): xray's plain cost matching is substring-based, so a barebal-1-vlesswould also swallow the deduplicatedbal-1-vless-2. Costs are omitted entirely unless at least one explicit weight survives — no all-1.0 arrays.make gen+ docs copy + gen:api).Testing
make verify) green except the known post-run teardown flake inbalancer-form-modal.test.tsx(all tests pass).Follow-up to #6243.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.