[GH-ISSUE #5664] [Feature]: Add a subscription-only “shell client” for subscription aggregation #3945

Closed
opened 2026-10-31 20:36:04 +07:00 by bsakaguchi · 2 comments
Owner

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

Yes. Currently, 3x-ui clients are mainly designed around real inbound attachments.

External links and external subscription URLs can be added to a client, but the exported subscription always places local inbound-generated nodes before external links or external subscription nodes.

This makes it impossible to freely mix local panel nodes and external nodes in a custom order, for example:

External node A
Local node 1
External node B
Local node 2

If I add local panel nodes again as external links while the same client is still attached to local inbounds, the nodes become duplicated. If I detach the client from all inbounds, it loses the normal subscription export workflow in the panel UI.

Describe the solution you'd like

I would like 3x-ui to add a subscription-only client mode, or “shell client”.

This client would not be pushed into any Xray inbound and would not create a real Xray user by itself. It would only act as a subscription container.

Expected behavior:

  • The shell client has its own name/email and subId.
  • It can export normal subscription, JSON subscription, and Clash/Mihomo subscription links.
  • It can contain external share links and external subscription URLs.
  • It can also include selected local panel-generated links from existing real clients/inbounds.
  • All subscription items are shown in one unified sortable list.
  • The exported subscription follows that exact order.

Example item order:

  1. External subscription: Provider A
  2. Local generated link: Tokyo inbound / user01
  3. External share link: vless://...
  4. Local generated link: Hong Kong inbound / user01
  5. External subscription: Provider B

Alternatives you've considered

I considered adding local panel nodes as external links manually, but this causes duplicate nodes if the same client is still attached to local inbounds.

I also considered creating a client without inbound attachments and using it as a subscription container, but this does not work well in the current panel workflow because the normal subscription export behavior depends on regular clients.

An external subscription aggregation service could solve this, but it adds another service to deploy and maintain. It would be cleaner if 3x-ui could support this directly.

Concrete use case

I manage multiple 3x-ui panels on different servers.

I want one main panel to export a unified subscription for users. The subscription should include both local panel nodes and nodes from other 3x-ui panels.

The desired order is not simply “all local nodes first, then all external nodes”. I need to mix them manually, for example by region, latency, provider, or priority:

  1. Japan external node
  2. Japan local node
  3. Hong Kong external node
  4. Hong Kong local node
  5. Singapore external node

This would make 3x-ui more useful as a central subscription management panel.

Mockups, screenshots, or examples

A possible UI could be a new client mode:

Client type:

  • Normal client
  • Subscription shell client

For a subscription shell client, the panel could show a sortable list of subscription items:

  • External share link
  • External subscription URL
  • Local generated client link

The final exported subscription should follow the order of this list.

Which parts of the panel would this affect?

Subscription (share links / Clash / JSON), Frontend (UI / panel pages), Backend (API endpoints, login, settings)

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 @drownrat on GitHub (Jun 29, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5664 ### Is your feature request related to a problem? Yes. Currently, 3x-ui clients are mainly designed around real inbound attachments. External links and external subscription URLs can be added to a client, but the exported subscription always places local inbound-generated nodes before external links or external subscription nodes. This makes it impossible to freely mix local panel nodes and external nodes in a custom order, for example: External node A Local node 1 External node B Local node 2 If I add local panel nodes again as external links while the same client is still attached to local inbounds, the nodes become duplicated. If I detach the client from all inbounds, it loses the normal subscription export workflow in the panel UI. ### Describe the solution you'd like I would like 3x-ui to add a subscription-only client mode, or “shell client”. This client would not be pushed into any Xray inbound and would not create a real Xray user by itself. It would only act as a subscription container. Expected behavior: - The shell client has its own name/email and subId. - It can export normal subscription, JSON subscription, and Clash/Mihomo subscription links. - It can contain external share links and external subscription URLs. - It can also include selected local panel-generated links from existing real clients/inbounds. - All subscription items are shown in one unified sortable list. - The exported subscription follows that exact order. Example item order: 1. External subscription: Provider A 2. Local generated link: Tokyo inbound / user01 3. External share link: vless://... 4. Local generated link: Hong Kong inbound / user01 5. External subscription: Provider B ### Alternatives you've considered I considered adding local panel nodes as external links manually, but this causes duplicate nodes if the same client is still attached to local inbounds. I also considered creating a client without inbound attachments and using it as a subscription container, but this does not work well in the current panel workflow because the normal subscription export behavior depends on regular clients. An external subscription aggregation service could solve this, but it adds another service to deploy and maintain. It would be cleaner if 3x-ui could support this directly. ### Concrete use case I manage multiple 3x-ui panels on different servers. I want one main panel to export a unified subscription for users. The subscription should include both local panel nodes and nodes from other 3x-ui panels. The desired order is not simply “all local nodes first, then all external nodes”. I need to mix them manually, for example by region, latency, provider, or priority: 1. Japan external node 2. Japan local node 3. Hong Kong external node 4. Hong Kong local node 5. Singapore external node This would make 3x-ui more useful as a central subscription management panel. ### Mockups, screenshots, or examples A possible UI could be a new client mode: Client type: - Normal client - Subscription shell client For a subscription shell client, the panel could show a sortable list of subscription items: - External share link - External subscription URL - Local generated client link The final exported subscription should follow the order of this list. ### Which parts of the panel would this affect? Subscription (share links / Clash / JSON), Frontend (UI / panel pages), Backend (API endpoints, login, settings) ### 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 - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
bsakaguchi 2026-10-31 20:36:04 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Jun 29, 2026):

This is a well-specified feature request. Here is what the current code supports and where the gap lies.

What already works today

A client in 3x-ui does not require any inbound attachment. The clients table is independent of client_inbounds; a client with a SubID and zero rows in client_inbounds is a fully valid state, confirmed by internal/sub/external_only_sub_test.go. Such a client is exported via getClientExternalLinksBySubId() (internal/sub/external_config.go) and can carry:

  • External share links (ClientExternalLink.Kind = "link")
  • Remote subscription URLs (ClientExternalLink.Kind = "subscription", fetched and expanded at export time)

Each external link has a SortIndex column (internal/database/model/model.go, ClientExternalLink struct) that controls ordering within the set of external links.

The architectural gap

The subscription output function getSubs() (internal/sub/service.go) has a hard-coded two-phase structure:

  1. Local inbound links — collected by getInboundsBySubId(), sorted by Inbound.SubSortIndex ASC then Inbound.Id ASC.
  2. External links — appended after all local links, sorted by client_id ASC, sort_index ASC, id ASC.

There is no unified sort index that spans both phases. The requested interleaving (external A → local 1 → external B → local 2) is structurally impossible under the current model because:

  • External links reference nothing internal; they cannot point to a specific client+inbound pair.
  • The two collections are accumulated in separate passes and concatenated, with no mechanism to inject local-inbound-generated links into the middle.

What this feature would require

To implement the proposed "shell client" fully, the following changes would be needed across the stack:

  1. New model / extended ClientExternalLink: A third kind of entry (e.g. "local_ref") that stores a reference to a specific (ClientRecord.Email, InboundId) pair, so that a shell client can embed the link generated for another real client on a real inbound.

  2. Unified sort index: A single integer column that covers all three item types (external link, external subscription, local reference) within a shell client's subscription list.

  3. Rewritten ordering logic in getSubs(): Instead of two sequential passes, a single ordered pass over a unified set of items (a join across client_external_links and a new local-ref table), resolving each item to its link(s) on the fly.

  4. Database migration in internal/database/db.go.

  5. Frontend UI: A sortable list component on the client detail page, plus a way to select which existing client+inbound combinations to include.

Partial workaround available now

If the ordering constraint is relaxed — all local nodes from a given inbound can appear as a group, with external items appearing before or after that group — you can approximate this today:

  • Use Inbound.SubSortIndex to control where each inbound's group appears relative to others.
  • Use ClientExternalLink.SortIndex to control ordering within the external-link block.
  • External subscriptions from other 3x-ui panels are fetched and expanded verbatim; their internal ordering is preserved.

This allows coarse grouping (e.g. all Japan links first, then all Hong Kong links) if each region's local nodes live on their own inbound, but it cannot interleave individual nodes from different inbounds with external nodes in an arbitrary sequence.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4836137767 --> @github-actions[bot] commented on GitHub (Jun 29, 2026): This is a well-specified feature request. Here is what the current code supports and where the gap lies. **What already works today** A client in 3x-ui does not require any inbound attachment. The `clients` table is independent of `client_inbounds`; a client with a `SubID` and zero rows in `client_inbounds` is a fully valid state, confirmed by `internal/sub/external_only_sub_test.go`. Such a client is exported via `getClientExternalLinksBySubId()` (`internal/sub/external_config.go`) and can carry: - External share links (`ClientExternalLink.Kind = "link"`) - Remote subscription URLs (`ClientExternalLink.Kind = "subscription"`, fetched and expanded at export time) Each external link has a `SortIndex` column (`internal/database/model/model.go`, `ClientExternalLink` struct) that controls ordering within the set of external links. **The architectural gap** The subscription output function `getSubs()` (`internal/sub/service.go`) has a hard-coded two-phase structure: 1. Local inbound links — collected by `getInboundsBySubId()`, sorted by `Inbound.SubSortIndex ASC` then `Inbound.Id ASC`. 2. External links — appended after all local links, sorted by `client_id ASC, sort_index ASC, id ASC`. There is no unified sort index that spans both phases. The requested interleaving (external A → local 1 → external B → local 2) is structurally impossible under the current model because: - External links reference nothing internal; they cannot point to a specific client+inbound pair. - The two collections are accumulated in separate passes and concatenated, with no mechanism to inject local-inbound-generated links into the middle. **What this feature would require** To implement the proposed "shell client" fully, the following changes would be needed across the stack: 1. **New model / extended `ClientExternalLink`**: A third kind of entry (e.g. `"local_ref"`) that stores a reference to a specific `(ClientRecord.Email, InboundId)` pair, so that a shell client can embed the link generated for another real client on a real inbound. 2. **Unified sort index**: A single integer column that covers all three item types (external link, external subscription, local reference) within a shell client's subscription list. 3. **Rewritten ordering logic in `getSubs()`**: Instead of two sequential passes, a single ordered pass over a unified set of items (a join across `client_external_links` and a new local-ref table), resolving each item to its link(s) on the fly. 4. **Database migration** in `internal/database/db.go`. 5. **Frontend UI**: A sortable list component on the client detail page, plus a way to select which existing client+inbound combinations to include. **Partial workaround available now** If the ordering constraint is relaxed — all local nodes from a given inbound can appear as a group, with external items appearing before or after that group — you can approximate this today: - Use `Inbound.SubSortIndex` to control where each inbound's group appears relative to others. - Use `ClientExternalLink.SortIndex` to control ordering within the external-link block. - External subscriptions from other 3x-ui panels are fetched and expanded verbatim; their internal ordering is preserved. This allows coarse grouping (e.g. all Japan links first, then all Hong Kong links) if each region's local nodes live on their own inbound, but it cannot interleave individual nodes from different inbounds with external nodes in an arbitrary sequence. *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@drownrat commented on GitHub (Jun 29, 2026):

Sorry for the noise. I found that this is already supported; I had not enabled the subscription service correctly.

Closing this issue. Thanks.

<!-- gh-comment-id:4836148481 --> @drownrat commented on GitHub (Jun 29, 2026): Sorry for the noise. I found that this is already supported; I had not enabled the subscription service correctly. Closing this issue. Thanks.
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#3945
No description provided.