mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #6512] [Feature]: Add abilty to attach subscription to balancer selector #4379
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#4379
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?
Originally created by @lifufkd on GitHub (Sep 13, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6512
Is your feature request related to a problem?
Hi! It would be great if it can be possible to chose entire subscription (all outbounds from it) in balancer selector. This can eliminate the need to manually change outbounds (on unstable subscriptions, they change very often)
Describe the solution you'd like
On my opinion it can be made like this: when subscriptions are automatically renewed, you need to check to replace outbounds with new ones in each corresponding balancer selector
Alternatives you've considered
No response
Concrete use case
No response
Mockups, screenshots, or examples
No response
Which parts of the panel would this affect?
No response
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Sep 13, 2026):
This already works today — no code change is needed. A balancer selector entry is a tag prefix, and every outbound from one subscription already shares a prefix, so putting that prefix in the selector is "attach the whole subscription to the balancer": servers the provider adds on the next refresh join the balancer automatically, and servers it drops fall out.
How to do it
Open Xray → Outbounds → subscription, and read (or set) the Tag prefix field. Leave it blank and the panel assigns
sub1-,sub2-, … automatically:The prefix is also shown under the subscription in the list (
frontend/src/pages/xray/outbounds/OutboundsTab.tsx:910-911).Open Xray → Balancers → your balancer, and type that prefix — e.g.
sub1-, orhk-if you named it — as a single selector entry, instead of listing the individual outbounds. The field accepts free text; it is an Ant Design tags input, not a closed dropdown:Save. Nothing else to maintain.
Use one prefix per subscription and keep them distinct — matching is a plain string prefix, so
sub1-would also swallow asub1-extra-…tag. Setting afallbackTagon the balancer is worth it too: if the provider ever returns an empty list, the balancer has no members left.Why this holds across refreshes
The refresh loop you describe is already wired end to end:
internal/web/job/outbound_subscription_job.go→RefreshAllEnabled(), thenj.xraySvc.SetToNeedRestart()when anything changed, so Xray reloads with the new outbound set. It runs oncadenceOutboundSub = "@every 5m"(internal/web/web.go:305), gated per subscription by its ownupdateInterval(default600seconds,internal/web/service/outbound_subscription.go:177-179).internal/web/service/xray.go:376-379, never into your saved template.outbound_subscription.go:501-509, vialink.SuggestTag(prefix, remark, i)), which is what makes the prefix selector pick up new servers.This is the documented, intended design rather than an accident — the strategy note at the bottom of
internal/web/service/outbound_subscription.go:642-645says so directly:The panel relies on the same prefix semantics for its own subscription balancers —
internal/sub/json_service.go:537emits"selector": []string{prefix}, andinternal/sub/sub_balancer_test.go:87pins the generated selector to the bare prefix"bal-1-". One caveat on the comment quoted above: everything the panel itself generates uses the bare prefix with no*(see also the golden fixture"selector": []any{"proxy-"}atinternal/web/service/golden_fixtures_xray_test.go:301), so usesub1-, notsub1-*. I could not check the*/ regex form against xray-core's router from this checkout, so I can only vouch for the bare-prefix form.Docs: Outbound subscriptions & balancers —
docs/content/docs/en/operations/outbounds-routing.mdx:127-132covers exactly this.On the duplicate
#5316 ("Subscription LoadBalancer") asked for the same thing, and its "Alternatives you've considered" section proposed the same prefix-expansion idea. It was closed as completed on 2026-06-14 because the mechanism above already covers it. Closing this one the same way — the remaining gap is UX (the panel never points you at the prefix workflow from the balancer form), so if you want to push for that specifically, a request framed as "surface the subscription prefix as a pickable balancer member in the UI" is the one that is still open ground.
Verdict: Duplicate
Duplicate of: #5316 — same request (attach a whole outbound subscription to a balancer), same resolution: a prefix selector entry already expands to the subscription's outbound pool at every Xray reload
Evidence:
internal/web/service/outbound_subscription.go:642-645(design note naming prefix selectors "the recommended way to subscribe to a pool");outbound_subscription.go:166+:501-509(every tag from a subscription carries its prefix);frontend/src/pages/xray/balancers/BalancerFormModal.tsx:250-256(mode="tags"— arbitrary selector text accepted);internal/sub/json_service.go:537andinternal/sub/sub_balancer_test.go:87(the panel emits a bare-prefix selector itself);internal/web/job/outbound_subscription_job.go+internal/web/web.go:305+internal/web/service/xray.go:376-379(refresh → reload → re-merge)Not determined: whether xray-core treats a trailing
*or a regex in a selector entry as a wildcard — the xray-core module source is not present in this checkout. Greppingapp/router/balancing.goupstream would settle it; it does not change the advice above, which uses the bare prefix.This reply was generated automatically; a maintainer may follow up.