mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #5314] [Feature]: Auto-rotate Reality SNI/dest on probe failure with live apply #3724
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#3724
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?
Originally created by @Ssentiago on GitHub (Jun 14, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5314
Is your feature request related to a problem?
Yes. When a Reality dest/SNI target becomes unavailable — blocked by IP, domain suspended, or the host stops supporting TLS 1.3/H2 — the inbound stops working for all clients simultaneously. The only recovery is manual: admin notices the outage, finds a new working target, updates the inbound in the panel UI. During this window all clients are down.
Describe the solution you'd like
A fallback SNI list per Reality inbound with automatic health-based switching:
Config fields needed:
Alternatives you've considered
Multiple inbounds with different SNIs — requires clients to have multiple configs and handle failover themselves; not viable for managed deployments where clients are non-technical
Concrete use case
A Reality+VLESS inbound is running with a single dest/SNI target. The target host becomes unreachable from the server's network (IP blocked, domain suspended, or TLS 1.3/H2 support dropped). All connected clients lose connectivity simultaneously. Admin has to manually find a working replacement target via RealiTLScanner, update the inbound, restart xray — typically 30–60 minutes of downtime.
With this feature: probe detects the failure within probe_interval * fail_threshold seconds, automatically switches to the next candidate in the fallback list, applies the change live without interrupting existing connections. Downtime drops to under a minute with zero admin intervention.
Mockups, screenshots, or examples
No response
Which parts of the panel would this affect?
No response
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Jun 14, 2026):
This is a well-scoped request. Below is a technical assessment based on the current source, written to help you get a PR to a mergeable state.
Existing infrastructure you can build on
internal/web/service/xray.go:tryHotApply,internal/xray/hot_diff.goXrayAPI.DelInbound/AddInboundgRPC wrappersinternal/xray/api.go:120–148InboundService.UpdateInbound(persists to DB and triggers reload)internal/web/service/inbound.go:928internal/web/job/outbound_subscription_job.go,check_xray_running_job.gointernal/web/service/outbound/probe_http.gointernal/web/service/tgbot/tgbot_send.go:SendMsgToTgbotAdminsfrontend/src/schemas/protocols/security/reality.tsfrontend/src/pages/inbounds/form/security/reality.tsxThe hot-apply path (
tryHotApply) was introduced in the v3.3.x series (latest release is v3.3.1). A Reality-target change is aStreamSettingsmutation on an existing inbound, which falls into the remove-then-re-add path insidediffInbounds(hot_diff.go:102–134). This means the xray process does not restart, but the inbound handler is replaced — any TCP sessions that were open on that inbound at the moment of the switch are dropped. This is meaningfully better than a full process restart (no disruption to other inbounds), but the request's claim that "existing connections survive" needs to be narrowed to "connections on other inbounds survive."Reality field mapping you need to be aware of
In
frontend/src/schemas/protocols/security/reality.ts:target— the dest host Reality connects to for its TLS handshake (e.g.www.amazon.com:443). This is what a failover must update.serverNames— an array of SNI values clients are allowed to present. For correct failover you also need to updatesettings.serverName(the client-side SNI hint stored underrealitySettings.settings.serverName) to match the new target, otherwise newly-generated share links will carry the old SNI.A fallback candidate must therefore carry both a
targetand a matchingserverName; the existingRealityTargettype infrontend/src/models/reality-targets.tsalready models exactly this pair.Probe implementation note
For Reality you need TLS 1.3 + H2 to be available at the target; a plain TCP dial to port 443 only tests reachability, not TLS 1.3/ALPN support. A more correct probe connects with a TLS 1.3-only dial and checks
ConnectionState().NegotiatedProtocolforh2. The existing outbound prober ininternal/web/service/outbound/probe_http.gohandles TCP dial and full HTTP-through-SOCKS but does not do a TLS handshake health check, so this would be new code.Schema / migration requirements
The
Inboundmodel (internal/database/model/model.go:46) has no fields for fallback state. You would need to either:Inboundtable (reality_fallback_list TEXT,reality_active_idx INT DEFAULT 0, etc.), orinbound_id.Either way a GORM auto-migration entry in
internal/database/is required. Inspect the existing migration pattern before adding columns to understand the ordering constraints.Suggested implementation checklist for a PR
Inbound(or a linked table) + migration — fallback list, active index, probe config, probe state (consecutive failures, last switch time).internal/web/job/following theOutboundSubscriptionJobpattern — loads inbounds with Reality + fallback configured, probes current target, updates DB + triggers hot-apply on threshold breach.internal/web/service/outbound/probe_http.goor in a new file underinternal/web/service/.Tgbot.SendMsgToTgbotAdmins.RealityStreamSettingsSchemawith the new fields, add ordered-list UI infrontend/src/pages/inbounds/form/security/reality.tsx, expose active SNI and last-probe status in the inbound list.The maintainers will have the final say on API surface and DB schema; it is worth opening a draft PR early to get feedback before sinking time into the UI layer.
This reply was generated automatically; a maintainer may follow up with additional guidance.