[PR #5227] [CLOSED] Add client outbound attachment support as external config #5825

Closed
opened 2026-11-02 04:04:21 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5227
Author: @saeedhasani
Created: 6/12/2026
Status: ❌ Closed

Base: main ← Head: main


📝 Commits (5)

  • c9ac0e3 feat: add client outbound attachment support as external config
  • 094ecd1 Merge branch 'main' into main
  • baccfc8 Merge branch 'main' into main
  • 3d576ee Merge branch 'main' into main
  • 942a6b3 fix(frontend): remove unused Option type

📊 Changes

26 files changed (+1233 additions, -34 deletions)

View changed files

📝 frontend/public/openapi.json (+163 -1)
📝 frontend/src/api/queryKeys.ts (+1 -0)
📝 frontend/src/components/form/SelectAllClearButtons.tsx (+6 -10)
📝 frontend/src/hooks/useClients.ts (+42 -1)
📝 frontend/src/lib/xray/outbound-form-adapter.ts (+4 -0)
📝 frontend/src/pages/api-docs/endpoints.ts (+33 -3)
📝 frontend/src/pages/clients/ClientFormModal.tsx (+80 -2)
📝 frontend/src/pages/clients/ClientsPage.tsx (+19 -5)
📝 frontend/src/pages/xray/outbounds/OutboundFormModal.tsx (+8 -0)
📝 frontend/src/schemas/client.ts (+13 -0)
📝 frontend/src/schemas/forms/outbound-form.ts (+1 -0)
📝 internal/database/db.go (+1 -0)
📝 internal/database/migrate_data.go (+1 -0)
📝 internal/database/model/model.go (+8 -0)
📝 internal/sub/json_service.go (+23 -1)
➕ internal/sub/outbound_client.go (+366 -0)
➕ internal/sub/outbound_client_test.go (+110 -0)
📝 internal/sub/service.go (+19 -1)
📝 internal/web/controller/client.go (+54 -1)
📝 internal/web/service/client.go (+10 -7)

...and 6 more files

📄 Description

Summary

This PR adds support for attaching selected outbound configurations to individual clients and exposing them through client subscriptions as external configurations.

A new "Attached Outbounds (External Config)" field has been added to the client create/edit form, supporting multi-select, select-all, and clear-all actions similar to attached inbounds.

Only outbounds explicitly marked with "Use as External Config" are available for client assignment and subscription generation.

Why

Many operators use 3x-ui alongside third-party or provider-managed nodes and would like to distribute those configurations through the same client subscription endpoint.

Before this change, subscriptions could only be generated from attached inbounds. There was no built-in way to include externally imported outbound configurations in a user's subscription feed.

This PR enables:

  • Attaching external outbound configurations directly to clients.
  • Delivering third-party/proxy-provider configurations through standard client subscription links.
  • Supporting multiple protocol types as long as they are represented as supported outbounds (e.g. VLESS, VMess, Trojan, Shadowsocks, and other outbound-based configurations).
  • Supporting clients that rely entirely on external configurations without requiring subscription generation from local inbounds.

Implementation

Backend

  • Added a new client_outbounds model/table for client-to-outbound associations.

  • Added APIs:

    • GET /panel/api/clients/outboundOptions
    • POST /panel/api/clients/:email/attachOutbounds
    • POST /panel/api/clients/:email/detachOutbounds
  • Extended client create/edit flows to persist and hydrate outbound assignments.

  • Updated subscription generation to include attached external outbounds.

  • Updated JSON subscription generation to export selected outbounds as clean client-facing configurations.

  • Internal metadata fields are removed from generated subscription outputs.

Frontend

  • Added Attached Outbounds (External Config) to the client form.
  • Added Use as External Config switch to outbound settings.
  • Reused existing multi-select UX patterns (select all / clear all).

Subscription Output

  • External outbound links now preserve full transport and stream settings, including advanced TLS/Reality parameters when present.
  • Generated subscriptions retain the original outbound credentials and imported configuration details.
  • Metadata used internally by the panel is excluded from exported client configurations.

Verification

Successfully verified with:

go test ./internal/sub ./internal/web/service ./internal/web/controller ./internal/database/model

and

npm run build

git diff --check completed without issues.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5227 **Author:** [@saeedhasani](https://github.com/saeedhasani) **Created:** 6/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (5) - [`c9ac0e3`](https://github.com/MHSanaei/3x-ui/commit/c9ac0e38aa8bc83b1dba8a4817a97c9d4f5e2870) feat: add client outbound attachment support as external config - [`094ecd1`](https://github.com/MHSanaei/3x-ui/commit/094ecd10b7076c2cb04f9664cba917d452f0b8d3) Merge branch 'main' into main - [`baccfc8`](https://github.com/MHSanaei/3x-ui/commit/baccfc85b16a3b2b80f55311de04632557ec9c98) Merge branch 'main' into main - [`3d576ee`](https://github.com/MHSanaei/3x-ui/commit/3d576eeeb7246fb926568d3c3caaba3298eee89b) Merge branch 'main' into main - [`942a6b3`](https://github.com/MHSanaei/3x-ui/commit/942a6b326cfcf4e107b79e122f708549b86d1ffc) fix(frontend): remove unused Option type ### 📊 Changes **26 files changed** (+1233 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `frontend/public/openapi.json` (+163 -1) 📝 `frontend/src/api/queryKeys.ts` (+1 -0) 📝 `frontend/src/components/form/SelectAllClearButtons.tsx` (+6 -10) 📝 `frontend/src/hooks/useClients.ts` (+42 -1) 📝 `frontend/src/lib/xray/outbound-form-adapter.ts` (+4 -0) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+33 -3) 📝 `frontend/src/pages/clients/ClientFormModal.tsx` (+80 -2) 📝 `frontend/src/pages/clients/ClientsPage.tsx` (+19 -5) 📝 `frontend/src/pages/xray/outbounds/OutboundFormModal.tsx` (+8 -0) 📝 `frontend/src/schemas/client.ts` (+13 -0) 📝 `frontend/src/schemas/forms/outbound-form.ts` (+1 -0) 📝 `internal/database/db.go` (+1 -0) 📝 `internal/database/migrate_data.go` (+1 -0) 📝 `internal/database/model/model.go` (+8 -0) 📝 `internal/sub/json_service.go` (+23 -1) ➕ `internal/sub/outbound_client.go` (+366 -0) ➕ `internal/sub/outbound_client_test.go` (+110 -0) 📝 `internal/sub/service.go` (+19 -1) 📝 `internal/web/controller/client.go` (+54 -1) 📝 `internal/web/service/client.go` (+10 -7) _...and 6 more files_ </details> ### 📄 Description ## Summary This PR adds support for attaching selected outbound configurations to individual clients and exposing them through client subscriptions as external configurations. A new **"Attached Outbounds (External Config)"** field has been added to the client create/edit form, supporting multi-select, select-all, and clear-all actions similar to attached inbounds. Only outbounds explicitly marked with **"Use as External Config"** are available for client assignment and subscription generation. ## Why Many operators use 3x-ui alongside third-party or provider-managed nodes and would like to distribute those configurations through the same client subscription endpoint. Before this change, subscriptions could only be generated from attached inbounds. There was no built-in way to include externally imported outbound configurations in a user's subscription feed. This PR enables: * Attaching external outbound configurations directly to clients. * Delivering third-party/proxy-provider configurations through standard client subscription links. * Supporting multiple protocol types as long as they are represented as supported outbounds (e.g. VLESS, VMess, Trojan, Shadowsocks, and other outbound-based configurations). * Supporting clients that rely entirely on external configurations without requiring subscription generation from local inbounds. ## Implementation ### Backend * Added a new `client_outbounds` model/table for client-to-outbound associations. * Added APIs: * `GET /panel/api/clients/outboundOptions` * `POST /panel/api/clients/:email/attachOutbounds` * `POST /panel/api/clients/:email/detachOutbounds` * Extended client create/edit flows to persist and hydrate outbound assignments. * Updated subscription generation to include attached external outbounds. * Updated JSON subscription generation to export selected outbounds as clean client-facing configurations. * Internal metadata fields are removed from generated subscription outputs. ### Frontend * Added **Attached Outbounds (External Config)** to the client form. * Added **Use as External Config** switch to outbound settings. * Reused existing multi-select UX patterns (select all / clear all). ### Subscription Output * External outbound links now preserve full transport and stream settings, including advanced TLS/Reality parameters when present. * Generated subscriptions retain the original outbound credentials and imported configuration details. * Metadata used internally by the panel is excluded from exported client configurations. ## Verification Successfully verified with: ```bash go test ./internal/sub ./internal/web/service ./internal/web/controller ./internal/database/model ``` and ```bash npm run build ``` `git diff --check` completed without issues. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:04:21 +07:00
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#5825
No description provided.