mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6923] [MERGED] feat(sub): support multiple SNIs with randomized per-config and shared selection #6524
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#6524
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/6923
Author: @Pejman-Yousefi-Official
Created: 10/24/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @MHSanaei
Base:
main← Head:feat/multi-sni📝 Commits (5)
443f1c4feat(sub): support multiple SNIs with randomized per-config and shared selectioncb0b349fix(sub): address PR review findings on host security, REST SNI sync, and tests4f82b02Merge remote-tracking branch 'origin/main' into pr/6923bc93dfdrefactor(hosts): one shared-SNI switch for a multi-SNI pool1a9ee84Merge remote-tracking branch 'origin/main' into pr/6923📊 Changes
33 files changed (+675 additions, -13 deletions)
View changed files
📝
docs/public/openapi.json(+49 -0)📝
frontend/public/openapi.json(+49 -0)📝
frontend/src/generated/examples.ts(+8 -0)📝
frontend/src/generated/schemas.ts(+21 -0)📝
frontend/src/generated/types.ts(+4 -0)📝
frontend/src/generated/zod.ts(+4 -0)📝
frontend/src/lib/hosts/host-link.ts(+17 -2)📝
frontend/src/pages/hosts/HostFormModal.tsx(+57 -4)📝
frontend/src/schemas/api/host.ts(+4 -0)📝
frontend/src/test/host-link.test.ts(+95 -1)📝
internal/database/db.go(+1 -0)📝
internal/database/model/model.go(+2 -0)📝
internal/sub/host_order.go(+1 -1)📝
internal/sub/host_sub.go(+52 -4)📝
internal/sub/host_sub_test.go(+170 -0)📝
internal/sub/service.go(+2 -0)📝
internal/web/entity/entity.go(+2 -0)📝
internal/web/service/host.go(+47 -1)📝
internal/web/service/host_test.go(+76 -0)📝
internal/web/translation/ar-EG.json(+1 -0)...and 13 more files
📄 Description
Summary
Add support for configuring multiple Server Name Indication (SNI) domains for Host entries in Security settings. When multiple SNIs are specified, operators can choose between two mutually exclusive randomization modes:
sniRandomizePerConfig, default): Each generated subscription endpoint / config receives an independently chosen random SNI from the pool on every fetch.sniSharedRandom): A single random SNI is selected from the pool and applied consistently across all endpoints and expanded CIDR addresses in that host group for that subscription fetch, re-randomized on subsequent fetches.Why
Operators and reverse-proxy frontends frequently rely on multiple SNI domains to distribute TLS fingerprints, balance traffic across CDN edge domains, and enhance censorship resistance against domain-specific SNI blocking. Previously, Host entries only accepted a single static SNI, requiring operators to duplicate host entries and configuration groups to use multiple SNIs. Supporting multi-SNI tags with configurable per-config or shared randomization allows dynamic domain rotation across client subscriptions without database or UI bloat.
Type of change
Areas affected
How was this tested?
Unit tests:
internal/sub/host_sub_test.gocoveringTestSub_HostMultiSNI_RandomizePerConfig,TestSub_HostMultiSNI_SharedRandom, andTestSub_HostMultiSNI_Overrides.internal/web/service/host_test.gocoveringTestHostGroup_MultiSNIRoundTripand validation of mutual exclusivity enforcement.frontend/src/test/host-link.test.tsasserting multi-SNI per-config and shared random resolution in client link generators.go test ./internal/sub/... ./internal/web/service/...andnpm test.Manual verification:
example.com) — confirmed randomization switches remain hidden to avoid UI clutter.domain1.com,domain2.com) — confirmed both switches dynamically appear with smooth animation, defaulting to "Randomize per config"./sub/...raw share links, Clash YAML proxies, and Xray JSON outbounds):tools/openapigen,npm run gen:api, anddocs/public/openapi.json).internal/web/translation/*.json).npm run lint,npm run typecheck, andnpm run buildpass with 0 errors.Breaking changes
None. Existing database records retain their single
snifield, and the newsnisJSON column seamlessly defaults to empty/single SNI. Hosts with <= 1 SNI retain identical legacy behavior.Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.