[GH-ISSUE #5026] [Feature]: Dynamic Inbound Groups for Subscription Scaling with Hybrid Per-Client Overrides #3540

Open
opened 2026-10-31 20:33:10 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @zetrock1 on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5026

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

  1. Using current bulk add/attach actions: This is static. Every time a node goes offline, is replaced, or a new protocol is added, the admin has to repeat the bulk attachment process, which leads to database bloat and sync errors.
  2. External subscription aggregators: Moves subscription logic out of 3x-ui, breaking unified traffic accounting, user lifecycle management, and remaining quota calculations.

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?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
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 1. Using current bulk add/attach actions: This is static. Every time a node goes offline, is replaced, or a new protocol is added, the admin has to repeat the bulk attachment process, which leads to database bloat and sync errors. 2. External subscription aggregators: Moves subscription logic out of 3x-ui, breaking unified traffic accounting, user lifecycle management, and remaining quota calculations. ### 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? - [ ] I'd like to implement this feature myself and open a PR. - [x] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
Author
Owner

@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_groups table (database/model/client.go) with id and name columns, and ClientRecord has a group_name column. 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_inbounds join table (client_id, inbound_id, flow_override). The BulkAttach / BulkDetach operations in web/service/clientService.go are the only way to manage this: they write/delete rows in that table and patch the settings JSON column of each inbound row. This is the static mapping you correctly identified.

Subscription generation

sub/subService.go → GetSubs(subId, host) resolves a client's configs by joining:

inbounds → client_inbounds → clients  WHERE clients.sub_id = ?

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_inbounds at query time are what get returned.


What your proposal would require

Component Change needed
New table inbound_groups id, name, created_at — the group registry
New table inbound_group_members group_id, inbound_id — which inbounds belong to a group
ClientRecord schema Add an optional inbound_group_id (or inbound_group_name) column alongside the existing per-client extra-inbound entries in client_inbounds
sub/subService.go Replace the single join query with a union: (inbounds in client's inbound group) UNION (inbounds in client_inbounds), plus the offline-node graceful-skip logic
web/service/clientService.go Add group CRUD and the "sync group members to inbounds" path
Frontend New "Inbound Groups" management tab; extra dropdown in the client add/edit modal
DB migration GORM AutoMigrate entry for both new tables + the new column on clients

The 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, ClientGroup structs
  • sub/subService.go — subscription resolver (the GetSubs function)
  • web/service/clientService.go — BulkAttach, SyncInbound, group operations
  • database/db.go — migration list

The maintainers will need to weigh this against the existing roadmap, but the proposal is well-reasoned and the concrete use-case is clear.

<!-- gh-comment-id:4640227412 --> @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_groups` table (`database/model/client.go`) with `id` and `name` columns, and `ClientRecord` has a `group_name` column. 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_inbounds` join table (`client_id`, `inbound_id`, `flow_override`). The `BulkAttach` / `BulkDetach` operations in `web/service/clientService.go` are the only way to manage this: they write/delete rows in that table and patch the `settings` JSON column of each `inbound` row. This is the static mapping you correctly identified. ### Subscription generation `sub/subService.go` → `GetSubs(subId, host)` resolves a client's configs by joining: ``` inbounds → client_inbounds → clients WHERE clients.sub_id = ? ``` 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_inbounds` at query time are what get returned. --- ## What your proposal would require | Component | Change needed | |---|---| | **New table `inbound_groups`** | `id`, `name`, `created_at` — the group registry | | **New table `inbound_group_members`** | `group_id`, `inbound_id` — which inbounds belong to a group | | **`ClientRecord` schema** | Add an optional `inbound_group_id` (or `inbound_group_name`) column alongside the existing per-client extra-inbound entries in `client_inbounds` | | **`sub/subService.go`** | Replace the single join query with a union: `(inbounds in client's inbound group) UNION (inbounds in client_inbounds)`, plus the offline-node graceful-skip logic | | **`web/service/clientService.go`** | Add group CRUD and the "sync group members to inbounds" path | | **Frontend** | New "Inbound Groups" management tab; extra dropdown in the client add/edit modal | | **DB migration** | GORM `AutoMigrate` entry for both new tables + the new column on `clients` | The 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`, `ClientGroup` structs - `sub/subService.go` — subscription resolver (the `GetSubs` function) - `web/service/clientService.go` — `BulkAttach`, `SyncInbound`, group operations - `database/db.go` — migration list The maintainers will need to weigh this against the existing roadmap, but the proposal is well-reasoned and the concrete use-case is clear.
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#3540
No description provided.