mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6992] [MERGED] fix(install): handle yes responses and validate panel ports #6566
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#6566
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/6992
Author: @HamedSanaei
Created: 10/28/2026
Status: ✅ Merged
Merged: 11/3/2026
Merged by: @MHSanaei
Base:
main← Head:fix/installer-panel-port-validation📝 Commits (4)
d7dd280fix(install): accept yes and validate custom panel portfb7685ftest(amneziawg): avoid fixed ports in forwarding lifecycle testsc7338b9Merge remote-tracking branch 'origin/main' into pr/699230941dftest(scripts): give the base-path script test the port helpers it now calls📊 Changes
4 files changed (+407 additions, -25 deletions)
View changed files
📝
.github/workflows/ci.yml(+7 -1)➕
deploy/test/installer-panel-port.sh(+304 -0)📝
install.sh(+83 -21)📝
scripts_base_path_test.go(+13 -3)📄 Description
Problem
The panel-port confirmation accepts only
y/Y: typingyes,Yes, orYESunexpectedly selects a random port. Empty, nonnumeric, and out-of-range custom ports reachx-ui settingwithout validation, and the installer continues to SSL setup and a success banner even when configuration fails.Background: #3896 describes the related validation problem but is already closed. Closed PR #6904 included an overlapping fix among broader script/Docker changes; this PR focuses on panel-port selection and configuration failure handling.
Solution
y/yesandn/no, trimming surrounding whitespace. Enter defaults to No, displayed as[y/N]; other answers retry. EOF aborts instead of silently selecting a default or looping forever.1–65535is supplied. Never replace a custom choice with a random port. Strip leading zeros as decimal before passing the port to Go's flag parser; validate digits/length before arithmetic to avoid octal interpretation, overflow, or expression evaluation.ss/netstatparsing: the old awkEND {exit 1}overrode a successful match, and the netstat pattern expected whitespace inside$4. Keep the existing random range1024–62000, retry occupied candidates, and fail after 100 attempts or a generator error.XUI_PANEL_PORTis validated, including availability; an unset variable selects a random port. An explicitly empty or otherwise invalid value fails clearly.$?is insufficient: also require the existing port, credential, and base-path success acknowledgments. Those messages are present in the inspected v3.10.2 and v3.11.0 CLI sources.shell-lint, and include installer/test changes in the CI path filters.Testing
All executions below completed successfully on the final change unless explicitly marked as the regression baseline:
bash deploy/test/installer-panel-port.sh— 59 passed, 0 failed, in an Ubuntu 24.04 container as UID/GID65534:65534, with a read-only repository mount. The same suite against unmodified upstreammainreports 15 passed, 44 failed, reproducing the confirmation, validation, availability, and configuration-failure bugs.bash -n install.shandbash -n deploy/test/installer-panel-port.sh— passed.--severity=styleforDockerInit.sh,DockerEntrypoint.sh,deploy/test/smoke-noninteractive.sh, and the new test;--severity=errorforinstall.sh,update.sh, andx-ui.sh— passed with ShellCheck 0.9.0.--severity=styleand installer at--severity=error— also passed with ShellCheck 0.11.0.go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.12 -color -shellcheck=— passed.is_port_in_use, opened an ephemeral localhost listener with socat, verified detection throughss, closed it, and verified that the port became free — passed.git diff --checkandgit diff --cached --check— passed.shell-lint— passed, including actionlint, ShellCheck, and the new installer regression suite. Every initial CI job passed exceptgo-test, which encountered the unrelated fixed-port collision described below.The suite extracts only named function definitions from the installer and mocks the panel CLI, network discovery, SSL setup, randomness, and persistence. It checks actual configuration arguments and recorded results, all requested response forms, retries, decimal normalization, numeric boundaries/invalid strings, all three availability backends, random exhaustion, noninteractive inputs, EOF, nonzero CLI failures, and zero-exit database/partial-setting failures. It does not execute the installer entry point, download/install a panel, require root, or contact external services.
Compatibility
No database migration or new dependencies. Existing valid noninteractive installations remain supported, and the username/password generation, database selection, SSL configuration flow, and WebBasePath behavior are unchanged. Only port selection, the shared TCP-listener lookup, and the fresh-install settings-success guard change.
Port availability is checked using the existing
ss/netstat/lsoftools when available; it cannot reserve the socket until the panel starts. Configuration success checking intentionally depends on the existing CLI acknowledgments so zero-exit failures are not reported as success. No real installation or production deployment was performed.CI fixture follow-up
The initial
go-testfailure wasTestPortForwardSetReconcileOpensAndClosesListeners: its hardcoded TCP port58910was already in use on the runner, leaving only the UDP listener open. This fixture predates the installer changes. Re-running the failed upstream job was denied because the connected account lacks repository admin rights.The follow-up changes only
internal/amneziawgnet/portfwd_test.go: both listener-lifecycle fixtures now select an OS-allocated port and probe availability on both TCP and UDP. The intentional TCP collision test still keeps its blocker open and verifies that the other three listeners work. Cleanup now closes the forwarding sets even after a fatal assertion. No assertions were removed, and no production AWG or installer behavior changed in this follow-up.Validation:
58910–58912) on TCP and UDP. Both original fixtures failed; both modified fixtures passed with those same sockets still occupied.go test ./internal/amneziawgnet -shuffle=on -count=1— passed.go test -race ./internal/amneziawgnet -run '^TestPortForwardSetReconcile' -shuffle=on -count=100— passed (100 runs of each lifecycle test).golangci-lint run ./internal/amneziawgnet/...— passed, 0 issues.gofmtandgit diff --check— passed.fb7685f0— all 11 jobs passed, includinggo-test,race, the installer regressions inshell-lint, frontend, PostgreSQL checks, and master/node end-to-end tests.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
[PR #6992] fix(install): handle yes responses and validate panel portsto [PR #6992] [MERGED] fix(install): handle yes responses and validate panel ports