mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6620] [MERGED] feat(sub): bind per-client host rule override for subscription SNI #6383
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6383
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6620
Author: @NethminaYasas
Created: 9/21/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @MHSanaei
Base:
main← Head:feat(client)--add-per-client-host-rule-binding-for-subscription-generation📝 Commits (10+)
7a4be7cfeat(sub): bind per-client host rule override for subscription SNI64b7aeastyle(clients): place host override beside reverse tag at half widthee07347Merge branch 'main' into feat(client)--add-per-client-host-rule-binding-for-subscription-generation3b160e4Merge branch 'main' into feat(client)--add-per-client-host-rule-binding-for-subscription-generationa0d1a72fix(ci): repair Go test comparison, hosts mock type, and stale codegenbcd5b05Merge branch 'main' into feat(client)--add-per-client-host-rule-binding-for-subscription-generatione048aa0Merge remote-tracking branch 'upstream/main' into feat(client)--add-per-client-host-rule-binding-for-subscription-generation34489c1fix(sub): scope per-client host bindings to their inbound8cd08aafix(i18n): translate the client host rule override field04c5fabfix(sub): make host-rule tests fail when the endpoint resolver is stubbed📊 Changes
47 files changed (+1940 additions, -168 deletions)
View changed files
📝
docs/content/docs/en/reference/api/hosts.mdx(+8 -1)📝
docs/public/openapi.json(+109 -0)📝
frontend/package.json(+1 -1)📝
frontend/public/openapi.json(+109 -0)➕
frontend/src/api/queries/useRawHostsQuery.ts(+51 -0)📝
frontend/src/api/queryKeys.ts(+1 -0)📝
frontend/src/generated/examples.ts(+8 -0)📝
frontend/src/generated/schemas.ts(+21 -0)📝
frontend/src/generated/types.ts(+2 -0)📝
frontend/src/generated/zod.ts(+2 -0)📝
frontend/src/pages/api-docs/endpoints.ts(+8 -0)📝
frontend/src/pages/clients/ClientFormModal.tsx(+125 -26)📝
frontend/src/schemas/client.ts(+4 -0)➕
frontend/src/test/client-host-rule-disabled.test.tsx(+77 -0)📝
frontend/src/test/happ-routing-editor.test.tsx(+10 -2)📝
frontend/src/test/setup.components.ts(+5 -3)📝
internal/database/model/client_renewal_merge_test.go(+28 -1)📝
internal/database/model/model.go(+155 -79)📝
internal/database/model/model_test.go(+24 -0)📝
internal/sub/clash_service.go(+22 -6)...and 27 more files
📄 Description
Summary
Adds per-client host rule binding: a client can now be linked to one or more host rules, and that client's subscription (raw links, JSON, Clash) renders only the bound hosts' endpoints instead of the inbound-level hosts.
Why
Host rules previously applied globally or per-inbound only, so all clients on an inbound got identical subscription endpoints. This enables per-client overrides (e.g. different SNI/address per client on the same VLESS TCP TLS inbound on port 443) without touching the host rule model itself.
Type of change
Areas affected
How was this tested?
New tests in
internal/sub/host_sub_test.go(all verified to fail with the resolver stubbed out, pass with it):TestSub_ClientHostRule_SingleBinding— bound client renders 1 link with the bound host's?sni=; unbound client on the same inbound still fans out to every host.TestSub_ClientHostRule_MultipleBindings— client bound to 2 of 3 hosts renders exactly those 2 links.TestSub_ClientHostRule_DeletedFallsBack— binding to a deleted host ID falls back to the inbound rule.TestSub_ClientHostRule_JSONSNI— bound host's SNI/address win in the JSON subscription; unbound host excluded.Plus full local suites:
go test ./internal/sub/ ./internal/web/service/ ./internal/database/... ./internal/web/and frontendvitest(client modal, hosts, openapi contracts, i18n). Manual check: client add/edit modal → "Host Rule Override" multi-select (populated fromGET /panel/api/hosts/raw), save, then fetch/sub/<uuid>and confirm?sni=reflects the bound rule.Screenshots / recordings
Breaking changes
None. New columns (
clients.client_host_rule_id,clients.client_host_rule_ids) are nullable and added via AutoMigrate; clients without a binding render byte-identical subscriptions. New endpointGET /panel/api/hosts/rawis additive. The multi-id update path is nil-guarded, so API callers that omit the field cannot wipe stored bindings.Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.Closes #6618
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.