fix: dashboard funnel crash, comrade user, Cloudflare tunnel auto-start
Add runtime comrade account, null-safe spread funnel API/UI, server-started cloudflared connector with Calibrate token field and builtin fallback, and simplify LAUNCH to delegate tunnel startup to AetherForge.
This commit is contained in:
@@ -105,19 +105,11 @@ if not exist "%ROOT%\data\uploads" mkdir "%ROOT%\data\uploads"
|
||||
if not exist "%ROOT%\data\blueprints" mkdir "%ROOT%\data\blueprints"
|
||||
if not exist "%ROOT%\data\preps" mkdir "%ROOT%\data\preps"
|
||||
|
||||
:: ----------------------------------------------------------------
|
||||
:: 5. Configure optional Cloudflare tunnel (foreground process, no service)
|
||||
:: ----------------------------------------------------------------
|
||||
set "CLOUDFLARED_BIN=%ROOT%\tools\cloudflared.exe"
|
||||
set "CF_PID_FILE=%ROOT%\data\cloudflared.pid"
|
||||
set "CF_TUNNEL_TOKEN="
|
||||
if defined AF_TUNNEL_TOKEN set "CF_TUNNEL_TOKEN=%AF_TUNNEL_TOKEN%"
|
||||
if not defined CF_TUNNEL_TOKEN if exist "%ROOT%\data\cloudflared-token.txt" (
|
||||
set /p CF_TUNNEL_TOKEN=<"%ROOT%\data\cloudflared-token.txt"
|
||||
)
|
||||
:: Cloudflare Zero Trust connector starts inside AetherForge.exe when a token is set
|
||||
:: (Calibrate -^> Cloudflare Tunnel Token, or data\cloudflared-token.txt, or AF_TUNNEL_TOKEN).
|
||||
|
||||
:: ----------------------------------------------------------------
|
||||
:: 6. Detect LAN IP for display
|
||||
:: 5. Detect LAN IP for display
|
||||
:: ----------------------------------------------------------------
|
||||
set "SERVER_PORT=8989"
|
||||
for /f "tokens=2 delims=:" %%I in ('ipconfig ^| findstr /i "IPv4" ^| findstr /v "127.0.0.1"') do (
|
||||
@@ -129,7 +121,7 @@ set "LAN_IP=localhost"
|
||||
set "LAN_IP=%LAN_IP: =%"
|
||||
|
||||
:: ----------------------------------------------------------------
|
||||
:: 7. Kill any stale server and tunnel processes
|
||||
:: 6. Kill any stale server and tunnel processes
|
||||
:: ----------------------------------------------------------------
|
||||
taskkill /F /IM AetherForge.exe >nul 2>nul
|
||||
taskkill /F /IM cloudflared.exe >nul 2>nul
|
||||
@@ -143,35 +135,12 @@ echo Local: http://localhost:%SERVER_PORT%
|
||||
echo LAN: http://%LAN_IP%:%SERVER_PORT%
|
||||
echo Data: %ROOT%\data\
|
||||
echo.
|
||||
echo First-run credentials will appear below after server starts.
|
||||
echo Login accounts: admin + comrade ^(passwords below after start^).
|
||||
echo Cloudflare: paste token in Calibrate or data\cloudflared-token.txt — server starts connector.
|
||||
echo Press Ctrl+C to stop.
|
||||
echo ================================================================
|
||||
echo.
|
||||
|
||||
:: Start optional Cloudflare tunnel for this launcher session only.
|
||||
if defined CF_TUNNEL_TOKEN (
|
||||
if not exist "%ROOT%\tools" mkdir "%ROOT%\tools"
|
||||
if not exist "%CLOUDFLARED_BIN%" (
|
||||
echo [Tunnel] Downloading cloudflared.exe...
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "& { [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.exe' -OutFile $env:CLOUDFLARED_BIN }"
|
||||
)
|
||||
if exist "%CLOUDFLARED_BIN%" (
|
||||
del "%CF_PID_FILE%" 2>nul
|
||||
echo [Tunnel] Starting Cloudflare tunnel for this session ^(no service install^).
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "$p = Start-Process -FilePath $env:CLOUDFLARED_BIN -ArgumentList @('tunnel','--no-autoupdate','run','--token',$env:CF_TUNNEL_TOKEN) -WindowStyle Hidden -PassThru; Set-Content -LiteralPath $env:CF_PID_FILE -Value $p.Id"
|
||||
if errorlevel 1 (
|
||||
echo [Tunnel] WARNING: cloudflared failed to start.
|
||||
) else (
|
||||
echo [Tunnel] Tunnel process started. It will stop when this launcher exits.
|
||||
)
|
||||
) else (
|
||||
echo [Tunnel] WARNING: cloudflared.exe unavailable; tunnel skipped.
|
||||
)
|
||||
) else (
|
||||
echo [Tunnel] Disabled. Add token to data\cloudflared-token.txt or set AF_TUNNEL_TOKEN.
|
||||
)
|
||||
echo.
|
||||
|
||||
:: Open browser after short delay
|
||||
start "" powershell -NoProfile -WindowStyle Hidden -Command "Start-Sleep -Seconds 3; Start-Process 'http://localhost:%SERVER_PORT%/'"
|
||||
|
||||
@@ -179,13 +148,6 @@ start "" powershell -NoProfile -WindowStyle Hidden -Command "Start-Sleep -Second
|
||||
"%ROOT%\AetherForge.exe" -port %SERVER_PORT% -data "%ROOT%\data"
|
||||
set "EC=!ERRORLEVEL!"
|
||||
|
||||
if exist "%CF_PID_FILE%" (
|
||||
for /f "usebackq" %%P in ("%CF_PID_FILE%") do (
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "Stop-Process -Id %%P -Force -ErrorAction SilentlyContinue" >nul 2>nul
|
||||
)
|
||||
del "%CF_PID_FILE%" 2>nul
|
||||
)
|
||||
|
||||
echo.
|
||||
if "!EC!"=="0" (
|
||||
echo [Server] Stopped normally.
|
||||
|
||||
Reference in New Issue
Block a user