3x-ui/xray
MHSanaei d97ce19f30
fix(windows): clean shutdown, working panel restart, harden kernel32 load
Three Windows-specific issues addressed:

1. Orphaned xray-windows-amd64 after VS Code debugger stop. Delve's
   "Stop" sends TerminateProcess to the Go binary, which is uncatchable
   — our signal handlers never run, so xrayService.StopXray() is skipped
   and xray is left dangling. Spawn xray as a child of a Job Object with
   JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE so the OS kills xray when our
   handle to the job is closed (which happens even on TerminateProcess).
   Also trap os.Interrupt in main so Ctrl+C in the terminal runs the
   graceful path.

2. /panel/setting/restartPanel logged "failed to send SIGHUP signal: not
   supported by windows" because Windows can't deliver arbitrary signals.
   Add a restart hook in web/global; main registers it to push SIGHUP
   into its own signal channel, and RestartPanel calls the hook before
   falling back to the (Unix-only) signal path. Same restart-loop code
   runs in both cases.

3. util/sys/sys_windows.go now uses windows.NewLazySystemDLL so the
   kernel32.dll resolve is pinned to %SystemRoot%\System32 (prevents
   DLL hijacking by a planted DLL next to the binary). Local filetime
   type replaced with windows.Filetime, and the unreliable
   syscall.GetLastError() fallback replaced with a type assertion on the
   errno captured at call time.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 22:57:36 +02:00
..
api.go fix(shadowsocks): generate valid ss2022 keys and per-client method for legacy ciphers 2026-05-18 00:19:09 +02:00
api_test.go test: cover crypto, random, netsafe, sub helpers, xray equals, websocket hub, node service 2026-05-18 10:00:09 +02:00
client_traffic.go refactor(traffic): drop all-time traffic tracking 2026-05-17 09:01:04 +02:00
config.go Remove streamSettings for protocols that don't support it 2026-05-14 23:18:23 +02:00
config_test.go test: cover crypto, random, netsafe, sub helpers, xray equals, websocket hub, node service 2026-05-18 10:00:09 +02:00
inbound.go Remove streamSettings for protocols that don't support it 2026-05-14 23:18:23 +02:00
inbound_test.go test: cover crypto, random, netsafe, sub helpers, xray equals, websocket hub, node service 2026-05-18 10:00:09 +02:00
log_writer.go v3 2026-05-10 02:13:42 +02:00
process.go fix(windows): clean shutdown, working panel restart, harden kernel32 load 2026-05-18 22:57:36 +02:00
process_other.go fix(windows): clean shutdown, working panel restart, harden kernel32 load 2026-05-18 22:57:36 +02:00
process_test.go fix(xray): implement graceful shutdown for xray process and add tests (#4259) 2026-05-11 14:11:40 +02:00
process_windows.go fix(windows): clean shutdown, working panel restart, harden kernel32 load 2026-05-18 22:57:36 +02:00
traffic.go docs: add comments for all functions 2025-09-20 09:35:50 +02:00