3x-ui/util
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
..
common test: cover crypto, random, netsafe, sub helpers, xray equals, websocket hub, node service 2026-05-18 10:00:09 +02:00
crypto test: cover crypto, random, netsafe, sub helpers, xray equals, websocket hub, node service 2026-05-18 10:00:09 +02:00
json_util test: cover crypto, random, netsafe, sub helpers, xray equals, websocket hub, node service 2026-05-18 10:00:09 +02:00
ldap chore: apply modernize analyzer fixes across codebase 2026-05-18 12:24:52 +02:00
netsafe test: cover crypto, random, netsafe, sub helpers, xray equals, websocket hub, node service 2026-05-18 10:00:09 +02:00
random chore: apply modernize analyzer fixes across codebase 2026-05-18 12:24:52 +02:00
reflect_util Refactor code and fix linter warnings (#3627) 2026-01-05 05:54:56 +01:00
sys fix(windows): clean shutdown, working panel restart, harden kernel32 load 2026-05-18 22:57:36 +02:00