[PR #6365] [CLOSED] feat(inbounds): add automatic REALITY short ID rotation #6235

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6365
Author: @nickshiro
Created: 8/30/2026
Status: ❌ Closed

Base: main ← Head: feat/reality-shortid-rotation


📝 Commits (4)

  • cc03bc9 feat(inbounds): add automatic REALITY short ID rotation
  • 9166002 Merge branch 'main' into feat/reality-shortid-rotation
  • 59691df Merge branch 'main' into feat/reality-shortid-rotation
  • 5420d71 fix(inbounds): repair REALITY short ID rotation review findings

📊 Changes

43 files changed (+2111 additions, -19 deletions)

View changed files

📝 docs/public/openapi.json (+72 -0)
📝 frontend/public/openapi.json (+72 -0)
📝 frontend/src/generated/examples.ts (+9 -0)
📝 frontend/src/generated/schemas.ts (+54 -0)
📝 frontend/src/generated/types.ts (+10 -0)
📝 frontend/src/generated/zod.ts (+12 -0)
📝 frontend/src/lib/xray/inbound-form-adapter.ts (+16 -0)
📝 frontend/src/models/dbinbound.ts (+12 -0)
📝 frontend/src/pages/inbounds/form/InboundFormModal.tsx (+2 -0)
📝 frontend/src/pages/inbounds/form/security/reality.tsx (+60 -2)
📝 frontend/src/pages/inbounds/form/useSecurityActions.ts (+3 -0)
📝 frontend/src/schemas/forms/inbound-form.ts (+4 -0)
📝 frontend/src/test/__snapshots__/inbound-form-blocks.test.tsx.snap (+4 -0)
📝 frontend/src/test/inbound-form-adapter.test.ts (+24 -0)
📝 frontend/src/test/inbound-form-blocks.test.tsx (+7 -0)
📝 internal/database/db.go (+46 -0)
📝 internal/database/model/model.go (+12 -0)
➕ internal/database/reality_shortid_rotation_schema_test.go (+118 -0)
📝 internal/sub/clash_service.go (+6 -6)
📝 internal/sub/json_service.go (+10 -6)

...and 23 more files

📄 Description

Summary

Add configurable automatic rotation of REALITY shortIds for VLESS inbounds.

  • Configure a rotation interval per inbound
  • Replace a subset or all active Short IDs
  • Keep replaced IDs temporarily available during a grace period
  • Publish only active IDs in raw, JSON, and Clash subscriptions
  • Apply rotations to local and remote node runtimes

Why

Feature request in #6014

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?

  • Two days of coding

Backend tests:

go test ./internal/database ./internal/web/service ./internal/web/job ./internal/sub -count=1
go test ./internal/web -run '^$' -count=1

The tests cover:

  • Full and partial Short ID rotation
  • Round-robin subset selection
  • Cryptographically secure Short ID generation
  • Grace-period retirement
  • Preservation of scheduling state during ordinary inbound edits
  • Resetting the schedule after manual Short ID changes
  • SQLite legacy-schema migration
  • Raw, JSON, and Clash subscription filtering
  • Local runtime updates
  • Remote node runtime dispatch and durable reconciliation

Frontend tests:

  npm run lint
  npm run typecheck
  npm run format:check
  npm test -- --testTimeout=10000
  npm run build

Result: 126 test files and 1213 tests passed.

Screenshots / recordings

image

Breaking changes

None.

Rotation is disabled by default, so existing inbounds retain their current behavior. New database columns are added automatically through the existing migration system.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior.
  • go build ./... and the complete Go test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the generated API schemas and OpenAPI documentation.
  • 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/6365 **Author:** [@nickshiro](https://github.com/nickshiro) **Created:** 8/30/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/reality-shortid-rotation` --- ### 📝 Commits (4) - [`cc03bc9`](https://github.com/MHSanaei/3x-ui/commit/cc03bc90a41e9e3c3f09f4cb6b5a1589175b3a32) feat(inbounds): add automatic REALITY short ID rotation - [`9166002`](https://github.com/MHSanaei/3x-ui/commit/9166002e3a462520fad39987bfc5bd46d8ed7a09) Merge branch 'main' into feat/reality-shortid-rotation - [`59691df`](https://github.com/MHSanaei/3x-ui/commit/59691df78dfd4d40accf6366f852d93e833febe9) Merge branch 'main' into feat/reality-shortid-rotation - [`5420d71`](https://github.com/MHSanaei/3x-ui/commit/5420d719cb0f8a14f25554365702f7a7ad84413c) fix(inbounds): repair REALITY short ID rotation review findings ### 📊 Changes **43 files changed** (+2111 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `docs/public/openapi.json` (+72 -0) 📝 `frontend/public/openapi.json` (+72 -0) 📝 `frontend/src/generated/examples.ts` (+9 -0) 📝 `frontend/src/generated/schemas.ts` (+54 -0) 📝 `frontend/src/generated/types.ts` (+10 -0) 📝 `frontend/src/generated/zod.ts` (+12 -0) 📝 `frontend/src/lib/xray/inbound-form-adapter.ts` (+16 -0) 📝 `frontend/src/models/dbinbound.ts` (+12 -0) 📝 `frontend/src/pages/inbounds/form/InboundFormModal.tsx` (+2 -0) 📝 `frontend/src/pages/inbounds/form/security/reality.tsx` (+60 -2) 📝 `frontend/src/pages/inbounds/form/useSecurityActions.ts` (+3 -0) 📝 `frontend/src/schemas/forms/inbound-form.ts` (+4 -0) 📝 `frontend/src/test/__snapshots__/inbound-form-blocks.test.tsx.snap` (+4 -0) 📝 `frontend/src/test/inbound-form-adapter.test.ts` (+24 -0) 📝 `frontend/src/test/inbound-form-blocks.test.tsx` (+7 -0) 📝 `internal/database/db.go` (+46 -0) 📝 `internal/database/model/model.go` (+12 -0) ➕ `internal/database/reality_shortid_rotation_schema_test.go` (+118 -0) 📝 `internal/sub/clash_service.go` (+6 -6) 📝 `internal/sub/json_service.go` (+10 -6) _...and 23 more files_ </details> ### 📄 Description ## Summary Add configurable automatic rotation of REALITY `shortIds` for VLESS inbounds. - Configure a rotation interval per inbound - Replace a subset or all active Short IDs - Keep replaced IDs temporarily available during a `grace` period - Publish only active IDs in raw, JSON, and Clash subscriptions - Apply rotations to local and remote node runtimes ## Why Feature request in #6014 ## 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 - [x] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [x] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [x] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? <!-- Concrete steps the reviewer can repeat. For UI changes: which page, which actions, which browser. For backend: which endpoint, which payload, which response. Mention any new unit/integration tests added. --> - Two days of coding Backend tests: ```bash go test ./internal/database ./internal/web/service ./internal/web/job ./internal/sub -count=1 go test ./internal/web -run '^$' -count=1 ``` The tests cover: - Full and partial Short ID rotation - Round-robin subset selection - Cryptographically secure Short ID generation - Grace-period retirement - Preservation of scheduling state during ordinary inbound edits - Resetting the schedule after manual Short ID changes - SQLite legacy-schema migration - Raw, JSON, and Clash subscription filtering - Local runtime updates - Remote node runtime dispatch and durable reconciliation Frontend tests: ```bash npm run lint npm run typecheck npm run format:check npm test -- --testTimeout=10000 npm run build ``` Result: 126 test files and 1213 tests passed. ## Screenshots / recordings <!-- Required for UI changes. Drag images or GIFs here. Remove if N/A. --> <img width="1917" height="965" alt="image" src="https://github.com/user-attachments/assets/65dae90c-297c-4e7f-a63c-901dcd735ada" /> ## Breaking changes <!-- Does this change require existing users to update their config, run a migration, or change their API calls? If yes, describe the migration path. Write "None" if there are no breaking changes. --> None. Rotation is disabled by default, so existing inbounds retain their current behavior. New database columns are added automatically through the existing migration system. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior. - [x] go build ./... and the complete Go test suite pass locally. - [x] For frontend changes: npm run lint, npm run typecheck, and npm run build pass. - [x] I updated the generated API schemas and OpenAPI documentation. - [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:07:17 +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#6235
No description provided.