mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6967] feat(inbounds): REALITY watch - replace a dead REALITY target with a tested spare #6550
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#6550
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/6967
Author: @Plus98ir
Created: 10/26/2026
Status: 🔄 Open
Base:
main← Head:feat/reality-watch📝 Commits (8)
efd1a52feat(inbounds): REALITY watch - replace a dead REALITY target with a tested spare4674988fix(inbounds): REALITY watch never replaces a local targetdc6199bfeat(inbounds): REALITY watch shows latency, spares table at full widthd16e975feat(inbounds): set REALITY watch spares while creating the inbound7a50379fix(inbounds): pass the request context to REALITY test port helpersfb2ccf1Merge remote-tracking branch 'origin/main' into feat/reality-watchfee7ed1chore(inbounds): drop an AmneziaWG test leftover from the REALITY watch branch10dd871fix(inbounds): make REALITY watch switches safe around admin edits and Hosts📊 Changes
42 files changed (+3615 additions, -22 deletions)
View changed files
📝
docs/content/docs/en/reference/api/meta.json(+1 -0)➕
docs/content/docs/en/reference/api/reality-watch.mdx(+68 -0)📝
docs/public/openapi.json(+506 -0)📝
frontend/public/openapi.json(+506 -0)📝
frontend/src/generated/examples.ts(+36 -0)📝
frontend/src/generated/schemas.ts(+126 -0)📝
frontend/src/generated/types.ts(+26 -0)📝
frontend/src/generated/zod.ts(+29 -0)📝
frontend/src/pages/api-docs/endpoints.ts(+50 -0)📝
frontend/src/pages/inbounds/form/InboundFormModal.tsx(+31 -6)➕
frontend/src/pages/inbounds/form/security/RealityWatchSection.tsx(+305 -0)📝
frontend/src/pages/inbounds/form/security/reality.tsx(+21 -1)➕
frontend/src/pages/inbounds/form/security/realityWatch.ts(+15 -0)📝
frontend/src/test/__snapshots__/inbound-form-blocks.test.tsx.snap(+2 -0)📝
frontend/src/test/inbound-form-modal.test.tsx(+55 -1)➕
frontend/src/test/reality-watch-draft.test.tsx(+39 -0)➕
frontend/src/test/reality-watch-spares.test.ts(+23 -0)📝
internal/web/controller/api.go(+3 -0)➕
internal/web/controller/reality_watch.go(+93 -0)➕
internal/web/job/reality_watch_job.go(+20 -0)...and 22 more files
📄 Description
Why
The REALITY target scanner finds good targets, but nothing notices when the one in use stops working. Every client then fails until the admin edits the inbound by hand.
What
Each REALITY inbound can keep spare targets, set in a new "Keep REALITY working" section of the REALITY tab. Spares are picked with the existing target scanner.
Every 10 minutes the panel checks each watched target from this server with the scanner's own probe (TLS 1.3 + h2 + X25519 + a valid certificate). A target that has TLS 1.3 but misses the rest of that bar gets the real REALITY test below, and that result decides, so a working target is not replaced for lacking h2. After 3 failed checks in a row, an inbound with Replace automatically on moves to the first spare that passes:
https://<sni>/through them.The probe alone is not enough: a site can pass TLS 1.3 + h2 and still break REALITY's handshake, which would cut every client right after the switch.
Only
targetandserverNameschange, plus any of this inbound's Hosts that use REALITY and pin an old server name. The edit is saved throughUpdateInboundon a fresh copy of the inbound, so it reaches Xray (and the runtime) exactly like an admin's edit, and clients get the new SNI with their next subscription update.In the UI, each spare has a real-test button and a switch-now button. Switch-now runs the same two checks and is refused if either fails. On success the open editor takes the new target and server names, so its Save keeps the switch. The switch history is shown below the spares.
Safety
realityWatch), so the inbound model, the generated Xray config and the share links are untouched, and no migration is needed.API
/panel/api/realityWatch/{list, status/:id, save/:id, switch/:id, test}, documented inendpoints.ts.switch/:idreturns the inbound's new status. The structs are inStructAllow, and the OpenAPI copy and thereality-watch.mdxpage are regenerated.Tests
internal/web/service/reality_watch_test.goruns against a real DB, with the probe and the real test stubbed. It covers:I removed each safeguard once to confirm that a test goes red.
reality_watch_xray_e2e_test.goruns the real test against a real Xray binary, and is skipped unlessXRAY_E2E_BINARYis set. I ran it on a Linux server with xray-linux-amd64:connection reset), so it tests REALITY itself rather than plain TLS.frontend/src/test/reality-watch-spares.test.tscovers spare normalization in the UI.frontend/src/test/inbound-form-modal.test.tsxswitches in the editor, presses Save and checks the update carries the new target.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.