[PR #6126] [MERGED] feat(ui): validate the REALITY client version range at save time #6089

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6126
Author: @PathGao
Created: 7/28/2026
Status: ✅ Merged
Merged: 7/28/2026
Merged by: @MHSanaei

Base: main ← Head: fix-reality-clientver-validation


📝 Commits (2)

  • d7be5e0 feat(ui): validate the REALITY client version range at save time
  • e6b0fcb fix(ui): reject untrimmed client versions and revalidate max on min edits

📊 Changes

16 files changed (+171 additions, -1 deletions)

View changed files

📝 frontend/src/lib/xray/stream-wire-normalize.ts (+57 -0)
📝 frontend/src/pages/inbounds/form/security/reality.tsx (+28 -1)
📝 frontend/src/test/stream-wire-normalize.test.ts (+60 -0)
📝 internal/web/translation/ar-EG.json (+2 -0)
📝 internal/web/translation/en-US.json (+2 -0)
📝 internal/web/translation/es-ES.json (+2 -0)
📝 internal/web/translation/fa-IR.json (+2 -0)
📝 internal/web/translation/id-ID.json (+2 -0)
📝 internal/web/translation/ja-JP.json (+2 -0)
📝 internal/web/translation/pt-BR.json (+2 -0)
📝 internal/web/translation/ru-RU.json (+2 -0)
📝 internal/web/translation/tr-TR.json (+2 -0)
📝 internal/web/translation/uk-UA.json (+2 -0)
📝 internal/web/translation/vi-VN.json (+2 -0)
📝 internal/web/translation/zh-CN.json (+2 -0)
📝 internal/web/translation/zh-TW.json (+2 -0)

📄 Description

Summary

Follow-up to #6125, as promised in its review thread: validate the REALITY Min Client Ver / Max Client Ver fields at save time — format matching xray-core's parser, plus a cross-field check that a non-empty max is not below a non-empty min — so an inverted range that rejects every client can no longer be saved.

Why

#6125 documented the client-version gate, but a tooltip only helps a user who hovers it. The automated review on that PR pointed out the remaining hole: nothing stopped a user from saving maxClientVer = 25.9.11 against the effective minimum 26.3.27 — a range that rejects every client, with no feedback at save time and a hard-to-diagnose "clients time out" symptom later.

The validators mirror xray-core's config loader exactly (infra/conf/transport_security.go): up to three dot-separated numeric parts, each 0-255, empty meaning "not set". Short versions are padded before comparison the way the core pads them (26 == 26.0.0). A malformed min is reported by the min field itself and skipped by the max comparison, so each field shows one precise error.

Type of change

  • Bug fix (an impossible version range could be saved silently)

Areas affected

  • Frontend (UI / panel pages)

How was this tested?

  • 9 new unit tests in frontend/src/test/stream-wire-normalize.test.ts covering: core-style accepts (26, 26.3, 26.3.27, 0.0.255), core-style rejects (four parts, part > 255, non-numeric, empty parts), the exact stale-placeholder trap from #6125 (25.9.11 vs 26.3.27), short-version padding, and precedence of format errors over range errors.
  • Local panel end-to-end: filling 26.3.27 / 25.9.11 and pressing Create blocks the save with a field-level "Max Client Ver must not be lower than Min Client Ver"; a malformed value shows the format error; correcting the values and resubmitting saves cleanly.
  • npm run lint, npm run typecheck, npm run test, npm run build pass; both new error keys are present in all 13 locale files (script-asserted).

Screenshots / recordings

The only visible change is a standard field-level validation error under the offending field when saving an invalid version or an inverted range — same presentation as the existing REALITY target validation.

Breaking changes

None. Previously-savable invalid values are now rejected at the form; values already stored in the DB are unaffected.

Behavior notes for reviewers:

  • Validation follows the existing REALITY-target precedent in the same file: pure validators in src/lib/xray/stream-wire-normalize.ts returning i18n keys, wired via rules.validate. Errors surface when the user presses Create (the modal validates via trigger()), matching how every other field in this form behaves.
  • The comparison is only between the two fields when both are non-empty. When min is empty the effective floor is the core's built-in minimum, which depends on the Xray-core build the panel runs — the frontend cannot know it reliably, so that case stays a tooltip/docs concern (#6125) rather than a hard block.

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 (no doc change needed; #6125 already documents the gate).
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🤖 Generated with Claude Code


🔄 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/6126 **Author:** [@PathGao](https://github.com/PathGao) **Created:** 7/28/2026 **Status:** ✅ Merged **Merged:** 7/28/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix-reality-clientver-validation` --- ### 📝 Commits (2) - [`d7be5e0`](https://github.com/MHSanaei/3x-ui/commit/d7be5e0829216b0119e9a38121af62c24d2b4ad6) feat(ui): validate the REALITY client version range at save time - [`e6b0fcb`](https://github.com/MHSanaei/3x-ui/commit/e6b0fcb3384c9ba44f2201dc2858579e423a084c) fix(ui): reject untrimmed client versions and revalidate max on min edits ### 📊 Changes **16 files changed** (+171 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/lib/xray/stream-wire-normalize.ts` (+57 -0) 📝 `frontend/src/pages/inbounds/form/security/reality.tsx` (+28 -1) 📝 `frontend/src/test/stream-wire-normalize.test.ts` (+60 -0) 📝 `internal/web/translation/ar-EG.json` (+2 -0) 📝 `internal/web/translation/en-US.json` (+2 -0) 📝 `internal/web/translation/es-ES.json` (+2 -0) 📝 `internal/web/translation/fa-IR.json` (+2 -0) 📝 `internal/web/translation/id-ID.json` (+2 -0) 📝 `internal/web/translation/ja-JP.json` (+2 -0) 📝 `internal/web/translation/pt-BR.json` (+2 -0) 📝 `internal/web/translation/ru-RU.json` (+2 -0) 📝 `internal/web/translation/tr-TR.json` (+2 -0) 📝 `internal/web/translation/uk-UA.json` (+2 -0) 📝 `internal/web/translation/vi-VN.json` (+2 -0) 📝 `internal/web/translation/zh-CN.json` (+2 -0) 📝 `internal/web/translation/zh-TW.json` (+2 -0) </details> ### 📄 Description ## Summary Follow-up to #6125, as promised in its review thread: validate the REALITY **Min Client Ver** / **Max Client Ver** fields at save time — format matching xray-core's parser, plus a cross-field check that a non-empty max is not below a non-empty min — so an inverted range that rejects every client can no longer be saved. ## Why #6125 documented the client-version gate, but a tooltip only helps a user who hovers it. The automated review on that PR pointed out the remaining hole: nothing stopped a user from saving `maxClientVer = 25.9.11` against the effective minimum `26.3.27` — a range that rejects every client, with no feedback at save time and a hard-to-diagnose "clients time out" symptom later. The validators mirror xray-core's config loader exactly (`infra/conf/transport_security.go`): up to three dot-separated numeric parts, each 0-255, empty meaning "not set". Short versions are padded before comparison the way the core pads them (`26` == `26.0.0`). A malformed min is reported by the min field itself and skipped by the max comparison, so each field shows one precise error. ## Type of change - [x] Bug fix (an impossible version range could be saved silently) ## Areas affected - [x] Frontend (UI / panel pages) ## How was this tested? - 9 new unit tests in `frontend/src/test/stream-wire-normalize.test.ts` covering: core-style accepts (`26`, `26.3`, `26.3.27`, `0.0.255`), core-style rejects (four parts, part > 255, non-numeric, empty parts), the exact stale-placeholder trap from #6125 (`25.9.11` vs `26.3.27`), short-version padding, and precedence of format errors over range errors. - Local panel end-to-end: filling `26.3.27` / `25.9.11` and pressing Create blocks the save with a field-level "Max Client Ver must not be lower than Min Client Ver"; a malformed value shows the format error; correcting the values and resubmitting saves cleanly. - `npm run lint`, `npm run typecheck`, `npm run test`, `npm run build` pass; both new error keys are present in all 13 locale files (script-asserted). ## Screenshots / recordings The only visible change is a standard field-level validation error under the offending field when saving an invalid version or an inverted range — same presentation as the existing REALITY target validation. ## Breaking changes None. Previously-savable invalid values are now rejected at the form; values already stored in the DB are unaffected. Behavior notes for reviewers: - Validation follows the existing REALITY-target precedent in the same file: pure validators in `src/lib/xray/stream-wire-normalize.ts` returning i18n keys, wired via `rules.validate`. Errors surface when the user presses Create (the modal validates via `trigger()`), matching how every other field in this form behaves. - The comparison is only between the two fields when both are non-empty. When min is empty the effective floor is the core's built-in minimum, which depends on the Xray-core build the panel runs — the frontend cannot know it reliably, so that case stays a tooltip/docs concern (#6125) rather than a hard block. ## 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 (no doc change needed; #6125 already documents the gate). - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:16 +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#6089
No description provided.