Files
LimitlessHPPK 51c53de189 feedback7 G-TOOLS: listen on :: by default so one socket serves IPv6 and IPv4 (PR #291 by @LimitlessHPPK)
Ported only the dual-stack listen from PR #291 (the change accepted as #188). With HOST unset the server binds :: and, if that fails with EAFNOSUPPORT, EADDRNOTAVAIL or EINVAL, retries 0.0.0.0. An explicit HOST, including 0.0.0.0 and 127.0.0.1, is tried once. The boot banner and doctor list shareable IPv6 addresses in brackets, skip fe80::, and keep one URL per /64. An explicit IPv6 literal in the local URL is bracketed. The Windows service listing no longer drops those bracketed lines.

Not ported: /dev/grant, the settings-default migration, and the firewall scripts. The Docker image stays on 0.0.0.0; the alpine fallback was not booted.

Tests: node --test test/ipv6-bind.test.js test/doctor.test.js test/ci.test.js — 20 pass, 0 fail (8 bind, 4 doctor, 8 ci).
2026-10-08 18:53:24 +08:00

20 lines
1.0 KiB
Batchfile

@echo off
rem Runs the server in the background for the scheduled task created by scripts\install-service-windows.ps1.
rem Settings come from scripts\service.env.cmd (written by the installer; NODE_EXE, PORT, HOST, SP_COMBAT, SP_VERIFY).
rem Output goes to logs\server.log (rotated at 10 MB to logs\server.old.log); the server is restarted 5 s after it exits.
setlocal EnableExtensions
cd /d "%~dp0.."
set "NODE_EXE=node"
rem Dual-stack default (IPv6 and IPv4 on one socket). scripts\service.env.cmd may override HOST.
set "HOST=::"
if exist "%~dp0service.env.cmd" call "%~dp0service.env.cmd"
if not exist "logs" mkdir "logs"
:loop
if exist "logs\server.log" for %%A in ("logs\server.log") do if %%~zA GTR 10485760 move /y "logs\server.log" "logs\server.old.log" >nul
echo [%date% %time%] starting: "%NODE_EXE%" server\index.js (PORT=%PORT% HOST=%HOST%) >> "logs\server.log"
"%NODE_EXE%" server\index.js >> "logs\server.log" 2>&1
echo [%date% %time%] server exited with code %errorlevel%, restarting in 5 s >> "logs\server.log"
ping -n 6 127.0.0.1 >nul
goto loop