[PR #5691] [CLOSED] feat(clients): writable per-(client,inbound) XTLS flow override (#5689) #5963

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

📋 Pull Request Information

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

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


📝 Commits (4)

  • 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

📊 Changes

14 files changed (+469 additions, -6 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/info/InboundInfoModal.tsx (+33 -3)
📝 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

Implements approach (1) from #5689 — a writable per-(client, inbound) XTLS flow, so a client can keep Vision on some flow-capable inbounds and an empty flow on others in the same subscription.

Why

A client delivered on both a Reality inbound (Vision wanted) and a tunneled XHTTP+vlessenc inbound (Vision not wanted) currently gets xtls-rprx-vision on both — the single client-level flow is clamped per inbound by capability, but there's no way to clear it on one capable inbound while keeping it on another. See #5689.

What this does

The relational per-membership store already exists (client_inbounds.flow_override) and is resolved by EffectiveFlow / EffectiveFlowsByEmails. This PR makes it settable:

  • New service method ClientService.SetInboundClientFlow(inboundSvc, inboundId, email, flow) — sets the flow for one client on one inbound, bypassing the clientWithInboundFlow capability clamp. It writes the inbound settings.clients[].flow (what subscription generation reads) via the existing UpdateInboundClient, then mirrors the value onto client_inbounds.flow_override.
  • New endpoint POST …/clients/:email/flow with body { "inboundId": <id>, "flow": "xtls-rprx-vision" | "" }.
  • A pure helper clientWithFlow (returns a copy with the flow applied) so the core is unit-testable without a DB.

Open question for maintainers (the one design decision)

An explicit empty flow set here can be re-populated by restoreVisionFlowForEligibleInbound (#4792) if the inbound is later edited into a newly flow-eligible state, since that path treats an empty settings flow as "restore the intended Vision from a sibling". Making an explicit clear durable across such edits needs a small marker — e.g. a sentinel flow_override value ("none") meaning explicitly off, or a per-membership lock flag. I left that out deliberately because it's a model/semantics choice that's yours to make; happy to implement whichever you prefer.

Verification

  • go build ./internal/web/service/... ./internal/web/controller/... — clean.
  • go test ./internal/web/service -run TestClientWithFlow — passes (covers the override-clears-on-one-inbound and missing-email cases).
  • Couldn't run the DB-integration paths locally (CGO_ENABLED=0) or boot a panel — so this is draft pending runtime verification.

Status — draft

  • Frontend: a per-inbound flow control in the client form (the API endpoint works in the meantime).
  • Maintainer decision on the explicit-clear durability (above).
  • Runtime verification on a live panel.

Alternative to #5690 (the inbound-level DisableFlow toggle) — both close part of #5689; pick whichever fits the design.


🔄 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/5691 **Author:** [@FZ1010](https://github.com/FZ1010) **Created:** 6/30/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/per-inbound-flow-override` --- ### 📝 Commits (4) - [`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 ### 📊 Changes **14 files changed** (+469 additions, -6 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/info/InboundInfoModal.tsx` (+33 -3) 📝 `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 Implements **approach (1)** from #5689 — a writable per-`(client, inbound)` XTLS flow, so a client can keep Vision on some flow-capable inbounds and an empty flow on others in the same subscription. ### Why A client delivered on both a Reality inbound (Vision wanted) and a tunneled XHTTP+vlessenc inbound (Vision **not** wanted) currently gets `xtls-rprx-vision` on both — the single client-level flow is clamped per inbound by capability, but there's no way to clear it on one *capable* inbound while keeping it on another. See #5689. ### What this does The relational per-membership store already exists (`client_inbounds.flow_override`) and is resolved by `EffectiveFlow` / `EffectiveFlowsByEmails`. This PR makes it **settable**: - New service method `ClientService.SetInboundClientFlow(inboundSvc, inboundId, email, flow)` — sets the flow for one client on **one** inbound, bypassing the `clientWithInboundFlow` capability clamp. It writes the inbound `settings.clients[].flow` (what subscription generation reads) via the existing `UpdateInboundClient`, then mirrors the value onto `client_inbounds.flow_override`. - New endpoint `POST …/clients/:email/flow` with body `{ "inboundId": <id>, "flow": "xtls-rprx-vision" | "" }`. - A pure helper `clientWithFlow` (returns a copy with the flow applied) so the core is unit-testable without a DB. ### Open question for maintainers (the one design decision) An explicit **empty** flow set here can be re-populated by `restoreVisionFlowForEligibleInbound` (#4792) if the inbound is later edited into a newly flow-eligible state, since that path treats an empty settings flow as "restore the intended Vision from a sibling". Making an explicit clear durable across such edits needs a small marker — e.g. a sentinel `flow_override` value (`"none"`) meaning *explicitly off*, or a per-membership lock flag. I left that out deliberately because it's a model/semantics choice that's yours to make; happy to implement whichever you prefer. ### Verification - `go build ./internal/web/service/... ./internal/web/controller/...` — clean. - `go test ./internal/web/service -run TestClientWithFlow` — passes (covers the override-clears-on-one-inbound and missing-email cases). - Couldn't run the DB-integration paths locally (`CGO_ENABLED=0`) or boot a panel — so this is **draft** pending runtime verification. ### Status — draft - [ ] Frontend: a per-inbound flow control in the client form (the API endpoint works in the meantime). - [ ] Maintainer decision on the explicit-clear durability (above). - [ ] Runtime verification on a live panel. Alternative to #5690 (the inbound-level `DisableFlow` toggle) — both close part of #5689; pick whichever fits the design. --- <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:20 +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#5963
No description provided.