[PR #5699] [CLOSED] feat(clients): per-(client,inbound) XTLS flow override + panel UI (#5689) #5965

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5699
Author: @FZ1010
Created: 6/30/2026
Status: ❌ Closed

Base: main ← Head: feat/per-inbound-flow-override


📝 Commits (6)

  • c57944c feat(clients): writable per-(client,inbound) XTLS flow override
  • 87dfe06 fix(clients): validate flow + register route; drop redundant flow_override write
  • 2a95c1e feat(clients): make per-inbound flow override durable via flowLock
  • c5c9431 feat(clients): add per-inbound flow override UI to the client info modal
  • 7de957f Merge origin/main into feat/per-inbound-flow-override
  • 310ad41 feat(inbounds): move per-client flow override into the inbound edit form

📊 Changes

14 files changed (+494 additions, -4 deletions)

View changed files

📝 frontend/public/openapi.json (+61 -0)
📝 frontend/src/generated/examples.ts (+1 -0)
📝 frontend/src/generated/schemas.ts (+3 -0)
📝 frontend/src/generated/types.ts (+1 -0)
📝 frontend/src/generated/zod.ts (+1 -0)
📝 frontend/src/pages/api-docs/endpoints.ts (+12 -0)
📝 frontend/src/pages/inbounds/form/InboundFormModal.tsx (+58 -1)
📝 internal/database/model/model.go (+3 -2)
📝 internal/web/controller/client.go (+25 -0)
📝 internal/web/service/client_crud.go (+14 -1)
➕ internal/web/service/client_flow_override.go (+52 -0)
➕ internal/web/service/client_flow_override_durability_test.go (+224 -0)
➕ internal/web/service/client_flow_override_test.go (+33 -0)
📝 internal/web/service/inbound_flow_restore.go (+6 -0)

📄 Description

Closes #5689.

Two alternative approaches to #5689 — this one (per-(client,inbound) override) and the inbound-scoped DisableFlow toggle in #5698. Merge whichever fits; the other can be closed.

Problem

A VLESS client attached to multiple inbounds carries a single client-level flow. The panel clamps that flow onto every flow-capable inbound the client is on, so you cannot keep xtls-rprx-vision on a Reality inbound while turning it off on a tunneled XHTTP + VLESS-encryption inbound for the same client. Vision over a CDN/tunneled transport is frequently undesirable, but today it is all-or-nothing.

Approach — writable per-(client,inbound) flow override

A new endpoint sets or clears the XTLS flow for one client on one inbound, independently of its flow on sibling inbounds, with a panel control to drive it.

Backend

  • POST /panel/api/clients/:email/flow → SetInboundClientFlow(inboundId, email, flow) writes the chosen flow into just that inbound's settings. It validates against the recognized-flow allowlist and the inbound's capability (clearing — ""/none — is always allowed; an unknown value or a flow on a non-capable transport is rejected).
  • Durability via a flowLock marker. Without it, restoreVisionFlowForEligibleInbound (runs on every boot and inbound edit) and the whole-client editor (ClientService.Update) both re-homogenize a client's flow across its inbounds and would undo a deliberate clear. flowLock is stored in the inbound's settings JSON (so it survives SyncInbound, which rebuilds flow_override from settings) and is never sent to Xray (GetXrayConfig rebuilds clean client entries, and Xray ignores unknown client fields). SetInboundClientFlow pins the written client; the restore pass and Update skip/preserve flow-locked entries.

Frontend

  • A new Flow tab on the inbound edit modal (Modify Inbound — alongside Basics/Protocol/Stream/Security/Sniffing/Advanced), so the override lives where an operator editing an inbound actually looks for inbound-scoped controls, the same place #5698's DisableFlow switch lives. It only renders when editing an existing inbound that is currently flow-capable (canEnableTlsFlow) and has at least one attached client. Each row lists a client's email with a Select (xtls-rprx-vision / none) that posts to the endpoint above and refreshes the inbound list in place — no page reload, modal stays open so multiple clients can be adjusted in one sitting.
  • Deployed and exercised against a live panel (real VLESS Reality + XHTTP/TLS+vlessenc inbound pair, one client attached to both): the Flow tab appears only on the flow-capable inbound, the dropdown round-trips through the real endpoint, and the saved value persists correctly across modal reopen.

Tests

  • DB-backed: a cleared override survives both MigrationRestoreVisionFlow and a whole-client edit (a regression that fails without the flowLock + Update changes); restoreVisionFlowForEligibleInbound skips a flow-locked client (with an un-pinned control proving the test catches a regression); SetInboundClientFlow validation paths (unknown flow / non-capable inbound / unknown client / valid pin).

make verify — ✅ verify: OK

Ran the full CI-mirroring gate locally (CGO sqlite via MinGW; golangci-lint built for go 1.26.4):

stage result
gen-check clean — no codegen drift
lint (golangci-lint + eslint) 0 issues
typecheck (tsc --noEmit) clean
test — go test -shuffle=on ./... all packages pass, 0 failures
test — frontend vitest 634 passing
build (Vite bundles + go build ./...) OK

No // line comments in committed Go/TS, per the repo guidelines.


🔄 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/5699 **Author:** [@FZ1010](https://github.com/FZ1010) **Created:** 6/30/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/per-inbound-flow-override` --- ### 📝 Commits (6) - [`c57944c`](https://github.com/MHSanaei/3x-ui/commit/c57944cb391892d8521ebd617377aeaa7abdd0db) feat(clients): writable per-(client,inbound) XTLS flow override - [`87dfe06`](https://github.com/MHSanaei/3x-ui/commit/87dfe062c2462b74ac0670baa0d9911250120fff) fix(clients): validate flow + register route; drop redundant flow_override write - [`2a95c1e`](https://github.com/MHSanaei/3x-ui/commit/2a95c1e7e7da4f860bab602a8d22af7b3d13d110) feat(clients): make per-inbound flow override durable via flowLock - [`c5c9431`](https://github.com/MHSanaei/3x-ui/commit/c5c94315cb0e2b1519f9e2ed48d365cd918257d3) feat(clients): add per-inbound flow override UI to the client info modal - [`7de957f`](https://github.com/MHSanaei/3x-ui/commit/7de957f91310e3d274740419c538a8133785e332) Merge origin/main into feat/per-inbound-flow-override - [`310ad41`](https://github.com/MHSanaei/3x-ui/commit/310ad41f7087ecc82b4db2ebad8998080bb84a58) feat(inbounds): move per-client flow override into the inbound edit form ### 📊 Changes **14 files changed** (+494 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `frontend/public/openapi.json` (+61 -0) 📝 `frontend/src/generated/examples.ts` (+1 -0) 📝 `frontend/src/generated/schemas.ts` (+3 -0) 📝 `frontend/src/generated/types.ts` (+1 -0) 📝 `frontend/src/generated/zod.ts` (+1 -0) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+12 -0) 📝 `frontend/src/pages/inbounds/form/InboundFormModal.tsx` (+58 -1) 📝 `internal/database/model/model.go` (+3 -2) 📝 `internal/web/controller/client.go` (+25 -0) 📝 `internal/web/service/client_crud.go` (+14 -1) ➕ `internal/web/service/client_flow_override.go` (+52 -0) ➕ `internal/web/service/client_flow_override_durability_test.go` (+224 -0) ➕ `internal/web/service/client_flow_override_test.go` (+33 -0) 📝 `internal/web/service/inbound_flow_restore.go` (+6 -0) </details> ### 📄 Description Closes #5689. > Two alternative approaches to #5689 — this one (per-(client,inbound) override) and the inbound-scoped `DisableFlow` toggle in #5698. Merge whichever fits; the other can be closed. ## Problem A VLESS client attached to multiple inbounds carries a single client-level `flow`. The panel clamps that flow onto **every** flow-capable inbound the client is on, so you cannot keep `xtls-rprx-vision` on a Reality inbound while turning it off on a tunneled XHTTP + VLESS-encryption inbound for the same client. Vision over a CDN/tunneled transport is frequently undesirable, but today it is all-or-nothing. ## Approach — writable per-(client,inbound) flow override A new endpoint sets or clears the XTLS flow for **one client on one inbound**, independently of its flow on sibling inbounds, with a panel control to drive it. ### Backend - `POST /panel/api/clients/:email/flow` → `SetInboundClientFlow(inboundId, email, flow)` writes the chosen flow into just that inbound's settings. It validates against the recognized-flow allowlist and the inbound's capability (clearing — `""`/`none` — is always allowed; an unknown value or a flow on a non-capable transport is rejected). - **Durability via a `flowLock` marker.** Without it, `restoreVisionFlowForEligibleInbound` (runs on every boot and inbound edit) and the whole-client editor (`ClientService.Update`) both re-homogenize a client's flow across its inbounds and would undo a deliberate clear. `flowLock` is stored in the inbound's settings JSON (so it survives `SyncInbound`, which rebuilds `flow_override` from settings) and is never sent to Xray (`GetXrayConfig` rebuilds clean client entries, and Xray ignores unknown client fields). `SetInboundClientFlow` pins the written client; the restore pass and `Update` skip/preserve flow-locked entries. ### Frontend - A new **Flow** tab on the inbound edit modal (**Modify Inbound** — alongside Basics/Protocol/Stream/Security/Sniffing/Advanced), so the override lives where an operator editing an inbound actually looks for inbound-scoped controls, the same place #5698's `DisableFlow` switch lives. It only renders when editing an existing inbound that is currently flow-capable (`canEnableTlsFlow`) and has at least one attached client. Each row lists a client's email with a `Select` (`xtls-rprx-vision` / `none`) that posts to the endpoint above and refreshes the inbound list in place — no page reload, modal stays open so multiple clients can be adjusted in one sitting. - Deployed and exercised against a live panel (real VLESS Reality + XHTTP/TLS+vlessenc inbound pair, one client attached to both): the Flow tab appears only on the flow-capable inbound, the dropdown round-trips through the real endpoint, and the saved value persists correctly across modal reopen. ### Tests - DB-backed: a cleared override survives both `MigrationRestoreVisionFlow` and a whole-client edit (a regression that fails without the `flowLock` + `Update` changes); `restoreVisionFlowForEligibleInbound` skips a flow-locked client (with an un-pinned control proving the test catches a regression); `SetInboundClientFlow` validation paths (unknown flow / non-capable inbound / unknown client / valid pin). ## `make verify` — ✅ `verify: OK` Ran the full CI-mirroring gate locally (CGO sqlite via MinGW; golangci-lint built for go 1.26.4): | stage | result | |---|---| | `gen-check` | clean — no codegen drift | | `lint` (golangci-lint + eslint) | **0 issues** | | `typecheck` (`tsc --noEmit`) | clean | | `test` — `go test -shuffle=on ./...` | all packages pass, **0 failures** | | `test` — frontend vitest | **634 passing** | | `build` (Vite bundles + `go build ./...`) | OK | No `//` line comments in committed Go/TS, per the repo guidelines. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:05: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#5965
No description provided.