mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6994] feat(scripts): allow random or custom Web Base Path from menu #6567
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#6567
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/6994
Author: @HamedSanaei
Created: 10/28/2026
Status: 🔄 Open
Base:
main← Head:feat/custom-web-base-path-menu📝 Commits (1)
c5df14bfeat(scripts): support custom web base path in menu📊 Changes
2 files changed (+340 additions, -9 deletions)
View changed files
➕
scripts_menu_base_path_test.go(+242 -0)📝
x-ui.sh(+98 -9)📄 Description
Summary
/path/, preserving capitalization and accepting short/nested paths such as/a/and/private/admin/.Motivation
Option 8 previously always generated a random path. Administrators could not select a memorable or predefined path through the menu, and the handler reported success and restarted even when the CLI failed.
The new input allowlist accepts letters, digits, hyphens and underscores in single-slash-separated segments. It rejects empty/root-only values, traversal/dot segments, repeated separators, whitespace/control characters, query strings, fragments, backslashes and other unsafe characters. An invalid custom value is never replaced with randomness.
Released CLIs can print an error with exit status zero. The handler therefore requires the existing
Base URI path set successfullyacknowledgment and independently verifies the storedwebBasePathfromsetting -show. Settings reads reject missing/duplicate/malformed path records and reported getter/database errors.Compatibility
setting -webBasePathis used for the mutation. Credentials, port, TLS configuration and database settings are preserved.install.shandupdate.shuntouched and does not duplicate that work. Short-path preservation on future updates/reinstalls requires #6964 to be merged; this menu feature alone does not fix that existing bug. The changed files do not overlap.a99be10d499b09278075bd0f2cbf2f3e8fe8163cconfirmed that menu-selected/a/,/ab/,/mypanel/, and/private/admin/survive two consecutive install/update configuration passes without another write, random generation, or path-related restart.Testing
gofmt -w scripts_menu_base_path_test.go— completed.bash -n x-ui.sh— passed.shellcheck --severity=error x-ui.sh— passed with 0.9.0 and 0.11.0.go test -run '^TestMenuWebBasePath$' -count=1 -v .— 79 scenarios passed under Linux/Go 1.27.3.go test -c, then-test.count=1 -test.v) — all 14 test functions passed, including the 79 menu scenarios, as UID/GID65534:65534in a container with a read-only repository mount.go test -race -run '^TestMenuWebBasePath$' -count=1 .— passed.go vet .— passed.golangci-lint run .— passed, 0 issues (v2.15.0).git diff --checkandgit diff --cached --check— passed.The Go tests execute only extracted Bash function definitions, with temporary CLI/state fixtures and a mocked restart. They inspect the actual CLI argument, stored path, write/read/restart order, no-change/cancel behavior, all affirmative forms, unsafe-input retries, random failures, zero-exit errors, malformed settings reads, persistence mismatch, EOF, quoted executable paths, and unchanged unrelated settings. They run automatically in the existing Go CI suite; native Windows skips these POSIX menu tests with instructions to run under Linux/WSL.
No real installer, updater entry point, production panel, network service, or service restart was executed. If a write occurs but subsequent verification fails, the handler reports an error and leaves the running panel untouched; it does not guess the database state or automatically roll it back.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.