mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-16 01:55:01 +03:00
fix(update): keep Xray-core running until update downloads finish (#7002)
UpdateXray stopped the core before downloading, which also stopped the Panel Traffic Outbound bridge the download needed on servers that reach GitHub only through it, leaving every client offline. The new core is now downloaded, staged and checked with run -test against the current config while the old one serves; only the rename and restart swap it (Windows still stops first). update.sh gets the bridge as XUI_UPDATE_PROXY, installs x-ui.sh from the release archive, and fetches Alpine's x-ui.rc before stopping x-ui.
This commit is contained in:
committed by
GitHub
parent
4d583cebf3
commit
6d9e836d61
@@ -0,0 +1,48 @@
|
||||
package xray
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/util/json_util"
|
||||
)
|
||||
|
||||
// A kernel-TUN WireGuard outbound in `run -test` adds a second wg device and IPv6 policy
|
||||
// rules to the host, and the check exits without removing the rules.
|
||||
func TestCheckConfigKeepsWireGuardOffKernelTun(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("shell fixture is Unix-only")
|
||||
}
|
||||
dir := t.TempDir()
|
||||
checked := filepath.Join(dir, "checked.json")
|
||||
core := filepath.Join(dir, "xray")
|
||||
script := "#!/bin/sh\n[ \"$1 $2 $3\" = 'run -test -c' ] || exit 99\nexec cp \"$4\" '" + checked + "'\n"
|
||||
if err := os.WriteFile(core, []byte(script), 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cfg := &Config{OutboundConfigs: json_util.RawMessage(
|
||||
`[{"protocol":"wireguard","tag":"warp","settings":{"noKernelTun":false,"mtu":1420}}]`)}
|
||||
if err := CheckConfig(core, cfg); err != nil {
|
||||
t.Fatalf("CheckConfig: %v", err)
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(checked)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var got struct {
|
||||
Outbounds []struct {
|
||||
Settings map[string]any `json:"settings"`
|
||||
} `json:"outbounds"`
|
||||
}
|
||||
if err := json.Unmarshal(data, &got); err != nil {
|
||||
t.Fatalf("checked config: %v\n%s", err, data)
|
||||
}
|
||||
if len(got.Outbounds) != 1 || got.Outbounds[0].Settings["noKernelTun"] != true {
|
||||
t.Fatalf("checked outbounds = %+v, want the wireguard outbound on noKernelTun", got.Outbounds)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user