mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #5026] [Feature]: Dynamic Inbound Groups for Subscription Scaling with Hybrid Per-Client Overrides #3540
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#3540
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 @zetrock1 on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5026
Is your feature request related to a problem?
Yes. While the panel currently allows adding multiple clients to an inbound at once (bulk actions), this approach remains strictly static.
Once those clients are created, their relationships with the inbounds are permanently hardcoded in the database (client_inbounds table). This creates severe operational bottlenecks as the panel scales:
Tedious Scaling: If I deploy a new node or a backup inbound, I have to manually run bulk-attach operations for all existing clients. If I have 500 clients, this results in huge database write loads (O(N) queries) and easily triggers locks or timeouts, especially on remote nodes.
No Real-Time Inheritance: If a client is created via the bulk menu, they are statically linked. If I need to upgrade a server or change ports, I have to manually edit every single client or rebuild the bulk mapping instead of changing it in one central place.
Multi-Node Transaction Blockers: If a remote sub-node is temporarily offline, attempting to sync client modifications via static bulk-attach fails during GORM transactions, rolling back the database state and preventing any updates even on the main master.
Describe the solution you'd like
We propose a shift from static, hardcoded client-inbound relations to a Dynamic Client Grouping & Hybrid Subscription Resolution Engine (conceptually similar to Remnawave Squads):
Inbound/Subscription Groups Management:
A dedicated tab in the sidebar where admins can create groups (e.g., 'VIP Tier', 'Fallback').
Admins simply check/uncheck which inbounds/nodes belong to this group.
Hybrid Client Assignment:
In the Client Add/Edit modal, the client's unique UUID, email, and unique subId remain fully intact.
Add an optional dropdown field: Subscription Group.
Crucially, keep the existing individual inbound checklist active as 'Extra / Addon Inbounds'.
Dynamic Resolver on /sub/{subId}:
When a client queries their subscription endpoint, the backend dynamically resolves the union of:
[Inbound Group Members] + [Individually Checked Extra/Addon Inbounds].
It automatically generates configuration URLs on the fly, substituting the client's unique UUID, email, and transport-specific parameters.
If any node in the group is offline, the generator gracefully skips generating those specific configuration links instead of aborting the transaction or failing the whole sync.
Alternatives you've considered
Concrete use case
I manage 300 clients across 4 remote nodes, each hosting multiple inbounds (VLESS, Trojan, Hysteria).
The Easy Scaling Scenario: I add Node 5 with 3 new inbounds. Instead of performing a bulk-attach that queries the database thousands of times, I simply add the 3 new inbounds to my 'Standard Group'. All 300 clients instantly receive Node 5 configs on their next subscription update.
The Hybrid Addon Scenario: User 'Ivan' is in the 'Standard Group' (inheriting Germany and France). He pays extra for private access to a US server. I edit Ivan's profile: keep his group as 'Standard Group', and manually check 'US-Reality' in the extra checklist. Ivan's subscription dynamically merges both, giving him 3 configs seamlessly.
Mockups, screenshots, or examples
No response
Which parts of the panel would this affect?
Backend (API endpoints, login, settings), Frontend (UI / panel pages), Subscription (share links / Clash / JSON), Database / migrations
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Jun 6, 2026):
Thank you for the very detailed proposal. Here is an accurate picture of what the codebase currently does and what would need to change to implement this.
What exists today
Client grouping (for clients, not inbounds)
There is already a
client_groupstable (database/model/client.go) withidandnamecolumns, andClientRecordhas agroup_namecolumn. This lets you label/organize clients into named groups. It does not group inbounds together.Static client → inbound membership
Client-inbound membership lives entirely in the
client_inboundsjoin table (client_id,inbound_id,flow_override). TheBulkAttach/BulkDetachoperations inweb/service/clientService.goare the only way to manage this: they write/delete rows in that table and patch thesettingsJSON column of eachinboundrow. This is the static mapping you correctly identified.Subscription generation
sub/subService.go→GetSubs(subId, host)resolves a client's configs by joining:It is a pure point-in-time DB lookup. There is no group-expansion step, no graceful-skip for offline nodes, and no "extra addons" union — whatever rows exist in
client_inboundsat query time are what get returned.What your proposal would require
inbound_groupsid,name,created_at— the group registryinbound_group_membersgroup_id,inbound_id— which inbounds belong to a groupClientRecordschemainbound_group_id(orinbound_group_name) column alongside the existing per-client extra-inbound entries inclient_inboundssub/subService.go(inbounds in client's inbound group) UNION (inbounds in client_inbounds), plus the offline-node graceful-skip logicweb/service/clientService.goAutoMigrateentry for both new tables + the new column onclientsThe existing
client_groups(which groups clients) is a useful analogy but a separate concept — this would need a parallel "inbound groups" system on the other side of the join table.Scope note
This is a non-trivial architectural addition. The subscription resolver, GORM data layer, REST API, and frontend all need coordinated changes. A PR that does this incrementally (data model + migration first, then resolver, then UI) would be the easiest to review and merge safely.
If you do open a PR, the key files to start from are:
database/model/client.go—ClientRecord,ClientInbound,ClientGroupstructssub/subService.go— subscription resolver (theGetSubsfunction)web/service/clientService.go—BulkAttach,SyncInbound, group operationsdatabase/db.go— migration listThe maintainers will need to weigh this against the existing roadmap, but the proposal is well-reasoned and the concrete use-case is clear.