mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #7002] [MERGED] fix(update): keep Xray-core running until update downloads finish #6572
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#6572
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/7002
Author: @eric15342335
Created: 10/28/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @MHSanaei
Base:
main← Head:claude/unruffled-sinoussi-682e7e📝 Commits (2)
d6ed9f4fix(xray): download and test new Xray-core before stopping the old onebf08047fix(update): use Panel Traffic Outbound for update.sh's GitHub downloads📊 Changes
8 files changed (+421 additions, -96 deletions)
View changed files
📝
internal/web/service/panel/panel.go(+5 -0)📝
internal/web/service/server.go(+47 -36)➕
internal/web/service/server_xray_update_test.go(+207 -0)📝
internal/web/service/xray.go(+5 -30)➕
internal/xray/kernel_tun.go(+45 -0)📝
internal/xray/process.go(+37 -0)➕
internal/xray/process_check_test.go(+48 -0)📝
update.sh(+27 -30)📄 Description
Summary
On a server that can reach GitHub only through the Panel Traffic Outbound, updating Xray-core from the panel left Xray-core stopped and every client offline, and the panel update failed. With this PR, both updates download through that outbound, and neither stops Xray-core until its downloads are done.
Updating Xray-core (
UpdateXray) now runs in this order:.dgstSHA-256, as before.run -testagainst the panel's current config.If step 1, 2 or 3 fails, the installed binary and the running Xray-core stay as they were. Windows still stops Xray-core just before step 4, because it can't replace a running executable.
Updating the panel (
update.sh):update.shasXUI_UPDATE_PROXY, andupdate.shadds it to its GitHub curl calls.x-ui.shnow comes from the release archive, which ships it from the same commit as the binary, and Alpine'sx-ui.rcdownloads before the stop.Notes:
XUI_UPDATE_PROXYusessocks5h, so GitHub's hostnames resolve through the outbound too. This server's own DNS may be filtered.update.shstay direct, so the banner still shows this server's own address.wginterface and IPv6 policy rules that the test run never removes. The panel's outbound probe already does the same for its temporary instance.Why
Panel Traffic Outbound works through a loopback SOCKS inbound (
panel-egress) that 3x-ui adds to Xray-core's config, so it only works while Xray-core runs.UpdateXraystopped Xray-core before downloading. The download went direct and failed, and Xray-core stayed stopped. The stop counted as manual, soCheckXrayRunningJobdidn't restart it.update.shthrough the outbound but never passed the proxy to the script, so the script's curl calls went direct and failed. With the proxy passed by hand, it still downloadedx-ui.sh(andx-ui.rcon Alpine) after "Stopping x-ui", which takes the proxy down too. The script then failed with the old install already removed, and the panel didn't come back.The setting's description already says it carries "panel/Xray version checks and downloads", so this makes the updates match it.
Type of change
Areas affected
How was this tested?
TestUpdateXrayininternal/web/service/server_xray_update_test.goruns the realUpdateXrayagainst shell-script fake cores and a local server standing in for GitHub:run -testisn't installed. Before this change it was installed.TestCheckConfigKeepsWireGuardOffKernelTunininternal/xray/process_check_test.gochecks that the config given torun -testhasnoKernelTun: trueon WireGuard outbounds. It failed before the fix.make verifypasses on a clean clone of this branch, in Docker with Go 1.27.3, Node 26.12.1 and golangci-lint 2.15.0. The new tests also pass under-race, andshellcheck --severity=errorandbash -npass onupdate.sh.write: operation not permitted, and Xray-core stayed down.EOF, and the running Xray-core was untouched (same PID, same binary).update.shwithXUI_UPDATE_PROXY, on a fresh v3.10.2: upgraded to v3.11.0 with Xray-core 26.10.21. All 6 GitHub connections happened before "Stopping x-ui".x-ui.rcpath (only shellchecked), the Windows swap (the Go test skips on Windows), and the panel's Update button together with the new script. The panel fetchesupdate.shfrom main, so I tested those two halves separately.Breaking changes
None.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass. (No frontend files changed.make verifyran them anyway.)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
[PR #7002] fix(update): keep Xray-core running until update downloads finishto [PR #7002] [MERGED] fix(update): keep Xray-core running until update downloads finish