[PR #5295] [MERGED] fix(reality): load dest as target alias so existing inbounds aren't wiped #5842

Closed
opened 2026-11-02 04:04:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5295
Author: @volov-de
Created: 6/13/2026
Status: ✅ Merged
Merged: 6/14/2026
Merged by: @MHSanaei

Base: main ← Head: fix/reality-dest-target-alias


📝 Commits (1)

  • 3203129 fix(reality): load dest as target alias so existing inbounds aren't wiped

📊 Changes

2 files changed (+77 additions, -18 deletions)

View changed files

📝 frontend/src/schemas/protocols/security/reality.ts (+41 -18)
📝 frontend/src/test/security.test.ts (+36 -0)

📄 Description

Summary

REALITY inbounds whose realitySettings use the dest key load with an empty Target field in the edit form, and re-saving silently drops the destination. Normalize dest → target on parse so these configs load (and round-trip) correctly.

Why

xray-core accepts both target and dest as the REALITY destination — they are aliases:

// XTLS/Xray-core infra/conf/transport_internet.go — REALITYConfig
Target json.RawMessage `json:"target"`
Dest   json.RawMessage `json:"dest"`

The frontend reads/writes only target:

  • frontend/src/schemas/protocols/security/reality.ts — RealityStreamSettingsSchema defines target only.
  • frontend/src/pages/inbounds/form/security/reality.tsx — the field binds to ['streamSettings','realitySettings','target'].

So an inbound created by an older panel build, an external tool, or the panel's own /panel/api/inbounds API (which commonly write dest) loads with target: '' — Zod ignores the unknown dest. The Target field shows empty with the "required" warning even though xray is running fine.

Worse, re-saving such an inbound serializes the blank target and drops the working dest, so the REALITY inbound has no destination on the next xray restart — a silent break from just opening and saving the edit form.

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?

Manual repro:

  1. Create a VLESS+REALITY inbound whose realitySettings use dest, e.g. { "dest": "example.com:443", "serverNames": ["example.com"], ... } (via the API, or restore an older config).
  2. Open the inbound → Security tab. Before: Target is empty (placeholder example.com:443) with the "required" warning, despite xray running. After: Target loads as example.com:443.

Added unit tests in frontend/src/test/security.test.ts covering the alias on the schema directly (target absent, both keys present, empty target + present dest) and through SecuritySettingsSchema.

Validated locally:

  • cd frontend && npm run test → 513 passed (31 files), no snapshot changes
  • cd frontend && npm run typecheck
  • cd frontend && npm run lint
  • cd frontend && npm run build
  • git diff --check origin/main...HEAD

Screenshots / recordings

No visual/layout change — this is a form-state fix. Symptom: the Target field renders empty (placeholder example.com:443) for a dest-based REALITY inbound; after the fix it loads the configured destination.

Breaking changes

None.

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. — frontend-only change; ran the frontend suite (above).
  • 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. — no docs change needed.
  • 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/5295 **Author:** [@volov-de](https://github.com/volov-de) **Created:** 6/13/2026 **Status:** ✅ Merged **Merged:** 6/14/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/reality-dest-target-alias` --- ### 📝 Commits (1) - [`3203129`](https://github.com/MHSanaei/3x-ui/commit/3203129ce61abb991bfa99638cb1c916a232ca24) fix(reality): load `dest` as `target` alias so existing inbounds aren't wiped ### 📊 Changes **2 files changed** (+77 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/schemas/protocols/security/reality.ts` (+41 -18) 📝 `frontend/src/test/security.test.ts` (+36 -0) </details> ### 📄 Description ## Summary REALITY inbounds whose `realitySettings` use the `dest` key load with an empty **Target** field in the edit form, and re-saving silently drops the destination. Normalize `dest` → `target` on parse so these configs load (and round-trip) correctly. ## Why xray-core accepts both `target` and `dest` as the REALITY destination — they are aliases: ```go // XTLS/Xray-core infra/conf/transport_internet.go — REALITYConfig Target json.RawMessage `json:"target"` Dest json.RawMessage `json:"dest"` ``` The frontend reads/writes only `target`: - `frontend/src/schemas/protocols/security/reality.ts` — `RealityStreamSettingsSchema` defines `target` only. - `frontend/src/pages/inbounds/form/security/reality.tsx` — the field binds to `['streamSettings','realitySettings','target']`. So an inbound created by an older panel build, an external tool, or the panel's own `/panel/api/inbounds` API (which commonly write `dest`) loads with `target: ''` — Zod ignores the unknown `dest`. The Target field shows empty with the "required" warning even though xray is running fine. Worse, re-saving such an inbound serializes the blank `target` and drops the working `dest`, so the REALITY inbound has no destination on the next xray restart — a silent break from just opening and saving the edit form. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] 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? Manual repro: 1. Create a VLESS+REALITY inbound whose `realitySettings` use `dest`, e.g. `{ "dest": "example.com:443", "serverNames": ["example.com"], ... }` (via the API, or restore an older config). 2. Open the inbound → Security tab. Before: Target is empty (placeholder `example.com:443`) with the "required" warning, despite xray running. After: Target loads as `example.com:443`. Added unit tests in `frontend/src/test/security.test.ts` covering the alias on the schema directly (target absent, both keys present, empty `target` + present `dest`) and through `SecuritySettingsSchema`. Validated locally: - `cd frontend && npm run test` → 513 passed (31 files), no snapshot changes - `cd frontend && npm run typecheck` - `cd frontend && npm run lint` - `cd frontend && npm run build` - `git diff --check origin/main...HEAD` ## Screenshots / recordings No visual/layout change — this is a form-state fix. Symptom: the **Target** field renders empty (placeholder `example.com:443`) for a `dest`-based REALITY inbound; after the fix it loads the configured destination. ## Breaking changes None. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [ ] `go build ./...` and the test suite pass locally. — frontend-only change; ran the frontend suite (above). - [x] 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. — no docs change needed. - [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>
bsakaguchi 2026-11-02 04:04:29 +07:00
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#5842
No description provided.