[PR #7048] feat(reality): find REALITY targets from a device on the users' ISP #6618

Open
opened 2026-11-07 14:34:11 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/7048
Author: @Plus98ir
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: feat/reality-finder


📝 Commits (7)

  • 4db32a8 feat(reality): find REALITY targets from a device on the users' ISP
  • c6feb8e fix(reality): keep the finder's report when the scanner is reopened
  • 4472237 fix(reality): fetch the finder script with a User-Agent
  • 3875728 fix(reality): run only the finder script the panel made, on the inbound's own server
  • 11d03cb Merge remote-tracking branch 'origin/main' into feat/reality-finder
  • cf9ca5b fix(reality): stop reading a dest's TLS alert as an ISP filter
  • 32c5eff chore: merge main into feat/reality-finder

📊 Changes

41 files changed (+4312 additions, -33 deletions)

View changed files

📝 docs/content/docs/en/reference/api/server.mdx (+24 -1)
📝 docs/public/openapi.json (+384 -0)
📝 frontend/public/openapi.json (+384 -0)
📝 frontend/src/generated/examples.ts (+75 -0)
📝 frontend/src/generated/schemas.ts (+239 -0)
📝 frontend/src/generated/types.ts (+57 -0)
📝 frontend/src/generated/zod.ts (+63 -0)
📝 frontend/src/pages/api-docs/endpoints.ts (+16 -0)
📝 frontend/src/pages/inbounds/form/InboundFormModal.tsx (+2 -0)
➕ frontend/src/pages/inbounds/form/security/RealityFinderPanel.tsx (+358 -0)
📝 frontend/src/pages/inbounds/form/security/RealityTargetScannerModal.tsx (+77 -29)
📝 frontend/src/pages/inbounds/form/security/reality.tsx (+15 -1)
📝 frontend/src/pages/inbounds/form/useSecurityActions.ts (+12 -0)
📝 frontend/src/test/inbound-form-blocks.test.tsx (+1 -0)
📝 frontend/src/test/inbound-form-modal.test.tsx (+96 -2)
➕ frontend/src/test/reality-finder-panel.test.tsx (+168 -0)
📝 frontend/src/test/reality-mldsa-cert-chain.test.tsx (+5 -0)
📝 internal/web/controller/api.go (+2 -0)
➕ internal/web/controller/reality_finder.go (+106 -0)
📝 internal/web/controller/util_test.go (+29 -0)

...and 21 more files

📄 Description

Summary

A "From my internet" tab in the REALITY target scanner. It finds targets next to the server and checks them from a device on the users' ISP, including whether the ISP cuts each name as SNI. The panel server sends no probes for it.

REALITY finder

Why

The current scanner probes from the panel's server. It can tell whether a target speaks TLS 1.3 + h2 + X25519, but not whether the users' ISP filters the name as SNI, and in filtered networks that is what decides whether a target works. Scanning many neighbours from a VPS can also be read as network scanning by the host (the concern raised on #6950).

How it works

Like the clean IP scanner's full test (#6950), the panel hands out a one-day command. It runs a standard-library Python script (3.8+) on the admin's phone (Termux) or PC, with the VPN off:

  1. It reads the certificates of the server's neighbours (its /24, /22, /20, announced prefix or whole AS, via RIPEstat) and takes the site names from them.
  2. It checks each name the way REALITY needs it: TLS 1.3, a ClientHello offering only X25519, h2, and a certificate valid for that name.
  3. It sends each name as SNI to the inbound's own port, as a client would. A name the ISP cuts is marked filtered. An SNI router in front of the port (every name cut except the current target) is detected, and the filter result is dropped instead of marking everything filtered.
  4. It scores the targets (open on this ISP, same /24 or AS, not a CDN, DNS points at that IP, handshake time) and reports back with the token alone.

The report appears in the dialog by itself. Use puts target and serverNames into the form, and the admin saves as usual. A report from a VPN or a datacenter network is flagged, because its filter result says nothing about the users.

Abuse / safety

  • The server makes no outbound probes for this. It stores a command and receives reports.
  • Commands live 24 h, at most 50 at a time and 20 reports each. A report keeps at most 100 targets. Every field is validated (IPv4, host-name pattern, clamped numbers, known CDN names, control characters stripped). The report body is capped at 256 KB.
  • The public realityfinder/run/:token/{script.py,report} routes work only with an unexpired token and can only add a report to that token's job.
  • The server value must be a public IPv4 or a host name. It is written into the script as a JSON string literal.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

  • internal/web/service/reality_finder_test.go: rejected servers (private, IPv6, injection attempt), bad port and scope, the values written into the script, the 24 h expiry, report sanitizing and ordering, the report and command caps, and the User-Agent in the command. I broke each guard once to confirm that a test goes red.
  • frontend/src/test/reality-finder-panel.test.tsx: 443 is used for an inbound behind a local listener, the current target name is sent, a report renders and Use gives name:443 + [name], the VPN warning, and the report coming back after the dialog is reopened (not after the command expires). Also mutation-checked.
  • End to end on a local panel built from this branch: made a command in the UI, ran it on Windows against 140.82.121.3 (GitHub /24), 4 targets came back, and Use filled Target and SNI (screenshot above).
  • On two live panels (Iran and Turkey, one behind Cloudflare). This found two bugs that are fixed here:
    • Cloudflare answers Python's default urllib User-Agent with 403 (error 1010), so the command now sends one.
    • Picking a target closed the dialog and lost the report. The command is now kept per inbound in the browser tab until it expires.
  • go test ./..., golangci-lint run (0 issues), npm run lint, npm run typecheck, the vitest unit and components projects (1951 tests), and npm run build all pass. make gen shows no drift, and the docs OpenAPI copy and server.mdx are regenerated.

Breaking changes

None. Existing scanner behavior is unchanged, and no DB or config change is needed.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 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/7048 **Author:** [@Plus98ir](https://github.com/Plus98ir) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/reality-finder` --- ### 📝 Commits (7) - [`4db32a8`](https://github.com/MHSanaei/3x-ui/commit/4db32a88dbb6d4e1c6cbfab235356e28aa557ed9) feat(reality): find REALITY targets from a device on the users' ISP - [`c6feb8e`](https://github.com/MHSanaei/3x-ui/commit/c6feb8ed056d54fd6721bd36ae8da266b6e0535e) fix(reality): keep the finder's report when the scanner is reopened - [`4472237`](https://github.com/MHSanaei/3x-ui/commit/4472237cd40996407001c21ce7af0989825497b5) fix(reality): fetch the finder script with a User-Agent - [`3875728`](https://github.com/MHSanaei/3x-ui/commit/38757284e8f077a6667ed5ea5301699495646bd7) fix(reality): run only the finder script the panel made, on the inbound's own server - [`11d03cb`](https://github.com/MHSanaei/3x-ui/commit/11d03cbf22a5bbdc68e0a4115bdf776b4a8f1af3) Merge remote-tracking branch 'origin/main' into feat/reality-finder - [`cf9ca5b`](https://github.com/MHSanaei/3x-ui/commit/cf9ca5b5bf2c6bde90a964b9dcbb11f5406bb098) fix(reality): stop reading a dest's TLS alert as an ISP filter - [`32c5eff`](https://github.com/MHSanaei/3x-ui/commit/32c5eff75248e7a48b1d2b0aeea5ea71ac67824e) chore: merge main into feat/reality-finder ### 📊 Changes **41 files changed** (+4312 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/en/reference/api/server.mdx` (+24 -1) 📝 `docs/public/openapi.json` (+384 -0) 📝 `frontend/public/openapi.json` (+384 -0) 📝 `frontend/src/generated/examples.ts` (+75 -0) 📝 `frontend/src/generated/schemas.ts` (+239 -0) 📝 `frontend/src/generated/types.ts` (+57 -0) 📝 `frontend/src/generated/zod.ts` (+63 -0) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+16 -0) 📝 `frontend/src/pages/inbounds/form/InboundFormModal.tsx` (+2 -0) ➕ `frontend/src/pages/inbounds/form/security/RealityFinderPanel.tsx` (+358 -0) 📝 `frontend/src/pages/inbounds/form/security/RealityTargetScannerModal.tsx` (+77 -29) 📝 `frontend/src/pages/inbounds/form/security/reality.tsx` (+15 -1) 📝 `frontend/src/pages/inbounds/form/useSecurityActions.ts` (+12 -0) 📝 `frontend/src/test/inbound-form-blocks.test.tsx` (+1 -0) 📝 `frontend/src/test/inbound-form-modal.test.tsx` (+96 -2) ➕ `frontend/src/test/reality-finder-panel.test.tsx` (+168 -0) 📝 `frontend/src/test/reality-mldsa-cert-chain.test.tsx` (+5 -0) 📝 `internal/web/controller/api.go` (+2 -0) ➕ `internal/web/controller/reality_finder.go` (+106 -0) 📝 `internal/web/controller/util_test.go` (+29 -0) _...and 21 more files_ </details> ### 📄 Description ## Summary A "From my internet" tab in the REALITY target scanner. It finds targets next to the server and checks them from a device on the users' ISP, including whether the ISP cuts each name as SNI. The panel server sends no probes for it. ![REALITY finder](https://raw.githubusercontent.com/Plus98ir/3x-ui/db163e74da7bada11626dff3f0e8430236f17878/reality-finder.png) ## Why The current scanner probes from the panel's server. It can tell whether a target speaks TLS 1.3 + h2 + X25519, but not whether the users' ISP filters the name as SNI, and in filtered networks that is what decides whether a target works. Scanning many neighbours from a VPS can also be read as network scanning by the host (the concern raised on #6950). ## How it works Like the clean IP scanner's full test (#6950), the panel hands out a **one-day command**. It runs a standard-library Python script (3.8+) on the admin's phone (Termux) or PC, with the VPN off: 1. It reads the certificates of the server's neighbours (its /24, /22, /20, announced prefix or whole AS, via RIPEstat) and takes the site names from them. 2. It checks each name the way REALITY needs it: TLS 1.3, a ClientHello offering **only X25519**, h2, and a certificate valid for that name. 3. It sends each name as SNI to the inbound's own port, as a client would. A name the ISP cuts is marked filtered. An SNI router in front of the port (every name cut except the current target) is detected, and the filter result is dropped instead of marking everything filtered. 4. It scores the targets (open on this ISP, same /24 or AS, not a CDN, DNS points at that IP, handshake time) and reports back with the token alone. The report appears in the dialog by itself. **Use** puts `target` and `serverNames` into the form, and the admin saves as usual. A report from a VPN or a datacenter network is flagged, because its filter result says nothing about the users. ## Abuse / safety - **The server makes no outbound probes for this.** It stores a command and receives reports. - Commands live 24 h, at most 50 at a time and 20 reports each. A report keeps at most 100 targets. Every field is validated (IPv4, host-name pattern, clamped numbers, known CDN names, control characters stripped). The report body is capped at 256 KB. - The public `realityfinder/run/:token/{script.py,report}` routes work only with an unexpired token and can only add a report to that token's job. - The server value must be a public IPv4 or a host name. It is written into the script as a JSON string literal. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [x] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? - `internal/web/service/reality_finder_test.go`: rejected servers (private, IPv6, injection attempt), bad port and scope, the values written into the script, the 24 h expiry, report sanitizing and ordering, the report and command caps, and the User-Agent in the command. I broke each guard once to confirm that a test goes red. - `frontend/src/test/reality-finder-panel.test.tsx`: 443 is used for an inbound behind a local listener, the current target name is sent, a report renders and **Use** gives `name:443` + `[name]`, the VPN warning, and the report coming back after the dialog is reopened (not after the command expires). Also mutation-checked. - End to end on a local panel built from this branch: made a command in the UI, ran it on Windows against 140.82.121.3 (GitHub /24), 4 targets came back, and **Use** filled Target and SNI (screenshot above). - On two live panels (Iran and Turkey, one behind Cloudflare). This found two bugs that are fixed here: - Cloudflare answers Python's default `urllib` User-Agent with 403 (error 1010), so the command now sends one. - Picking a target closed the dialog and lost the report. The command is now kept per inbound in the browser tab until it expires. - `go test ./...`, `golangci-lint run` (0 issues), `npm run lint`, `npm run typecheck`, the vitest unit and components projects (1951 tests), and `npm run build` all pass. `make gen` shows no drift, and the docs OpenAPI copy and `server.mdx` are regenerated. ## Breaking changes None. Existing scanner behavior is unchanged, and no DB or config change is needed. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [x] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#6618
No description provided.