mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6514] [CLOSED] feat(settings): randomize subscription port on fresh installations #6322
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#6322
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/6514
Author: @poise52
Created: 9/13/2026
Status: ❌ Closed
Base:
main← Head:feat/random-subport📝 Commits (9)
27056cafeat(settings): randomize subscription port on fresh installationseafbbefdocs: document XUI_SUB_PORT and unattended install variables0543328fix(install): guard subport flag against release skew and fix review findingsa288650Merge branch 'main' into feat/random-subportc9b8452fix(install): gate reported subport and surface XUI_SUB_PORT override1b001a4Merge branch 'main' into feat/random-subportcb336e8Merge branch 'main' into feat/random-subport8d8f944Merge branch 'main' into feat/random-subport581503eMerge branch 'main' into feat/random-subport📊 Changes
36 files changed (+265 additions, -48 deletions)
View changed files
📝
.env.example(+9 -0)📝
CONTRIBUTING.md(+4 -3)📝
deploy/README.md(+1 -1)📝
deploy/cloud-init/README.md(+1 -0)📝
deploy/cloud-init/cloud-init.yaml(+1 -0)📝
deploy/test/smoke-noninteractive.sh(+2 -1)📝
docs/content/docs/en/config/subscription.mdx(+1 -1)📝
docs/content/docs/en/guide/first-login.mdx(+1 -0)📝
docs/content/docs/en/reference/api/subscription-server.mdx(+5 -5)📝
docs/content/docs/en/reference/env-vars.mdx(+3 -0)📝
docs/content/docs/en/reference/ports-firewall.mdx(+1 -1)📝
docs/content/docs/fa/config/subscription.mdx(+1 -1)📝
docs/content/docs/fa/guide/first-login.mdx(+1 -0)📝
docs/content/docs/fa/reference/api/subscription-server.mdx(+5 -5)📝
docs/content/docs/fa/reference/env-vars.mdx(+3 -0)📝
docs/content/docs/fa/reference/ports-firewall.mdx(+1 -1)📝
docs/content/docs/ru/config/subscription.mdx(+1 -1)📝
docs/content/docs/ru/guide/first-login.mdx(+1 -0)📝
docs/content/docs/ru/reference/api/subscription-server.mdx(+6 -5)📝
docs/content/docs/ru/reference/env-vars.mdx(+3 -0)...and 16 more files
📄 Description
Summary
Randomize the default subscription port (
subPort) within the safe non-privileged range (1024-62000) on fresh installations, while ensuring 100% backward compatibility for existing installations.Why
Using a static default port (
2096) makes subscription endpoints easy targets for automated ISP port scanning and censorship blocking (e.g., TSPU/RKN in Russia) and can cause port collisions on single-VPS setups. Generating a distinct random port on fresh installs mitigates fingerprinting and port conflicts without breaking existing setups.Fixes #6447
Type of change
Areas affected
How was this tested?
go test -v -run "TestInitDB" ./internal/database/...— verified that fresh databases receive a randomsubPortin[1024, 62000]and that existing databases preserve their existing port unchanged.go test -v ./internal/util/random/...— verified port generator range and distribution.go test -v -run TestRouteRegistryContract ./internal/web— verified route registry contract.go build ./...— compiled cleanly without errors.cd frontend && npx vitest run src/test/factory-defaults-contract.test.ts— verified factory default contracts pass (138 tests).cd docs && npm run format:check && npm run lint && npm run typecheck && npm test && npm run build— all 269 documentation pages across EN, RU, ZH, FA compiled cleanly.install.shand DB seeder guaranteesubPort != webPort.x-ui setting -subportandupdateSettingreject matching web and sub ports.Screenshots / recordings
N/A (Backend, database seeding, CLI, and installation script changes).
Breaking changes
None. Existing databases are never modified (
FirstOrCreateis gated byisUsersEmpty), and fallback factory defaults remain2096. Existing subscriptions continue to work seamlessly.Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.