Files
web-vnc/run.bat
T
Codex b89477fb87 feat: web-vnc single-binary browser VNC gateway with password access
- Go stdlib-only gateway: serves noVNC client, password auth, WS<->TCP relay
- auth: PBKDF2-HMAC-SHA256 password hash, HMAC session cookies, login rate limit
- relay: hand-written RFC 6455 WebSocket + transparent RFB bridge
- vncspawner: cross-OS VNC server detection/launch (Windows/Linux/macOS)
- server: /login /logout /vnc /api/status routes, session middleware, embed.FS
- scripts: get-novnc, get-vnc (zip-verified), list-ips, open-firewall
- run.bat: one-click launcher (asks only password), lists access IPs
- README/AGENTS.md (Russian), .gitignore (root-anchored binaries)
2026-07-30 17:40:31 +03:00

121 lines
3.8 KiB
Batchfile
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@echo off
REM ============================================================
REM web-vnc launcher - § ¯ã᪠¢ ®¤¨­ ª«¨ª. ‘¯à è¨¢ ¥â ⮫쪮 ¯ à®«ì.
REM ============================================================
chcp 866 >nul
cd /d "%~dp0"
echo.
echo === web-vnc: VNC ¢ ¡à ã§¥à¥ ===
echo.
REM --- 1. ¨­ à­¨ª ---
if exist "web-vnc.exe" goto havebin
where go >nul 2>nul
if not errorlevel 1 goto dogobuild
echo [®è¨¡ª ] web-vnc.exe ­¥ ­ ©¤¥­,   Go ­¥ ãáâ ­®¢«¥­.
echo “áâ ­®¢¨â¥ Go á https://go.dev/dl/ «¨¡® ¯®«®¦¨â¥ ᮡ࠭­ë© web-vnc.exe à冷¬.
echo.
pause
exit /b 1
:dogobuild
echo ‘®¡¨à î web-vnc.exe ...
go build -o web-vnc.exe .\cmd\web-vnc
if errorlevel 1 goto buildfail
:havebin
REM --- 2. noVNC-ª«¨¥­â ---
if exist "internal\server\static\core\rfb.js" goto havenovnc
echo noVNC-ª«¨¥­â ¥éñ ­¥ ¢áâ஥­. ëâ îáì ᪠ç âì ...
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\get-novnc.ps1"
if errorlevel 1 goto novncfail
echo ¥à¥á®¡¨à î á noVNC ...
go build -o web-vnc.exe .\cmd\web-vnc
goto havenovnc
:novncfail
echo [¯à¥¤ã¯à¥¦¤¥­¨¥] ¥ 㤠«®áì ᪠ç âì noVNC (­¥â ¨­â¥à­¥â ?).
echo ‚ ¡à ã§¥à¥ ®âªà®¥âáï áâà ­¨æ  á ¯®¤áª §ª®©. ®¢â®à¨â¥ ¯®§¦¥: scripts\get-novnc.ps1
echo.
:havenovnc
REM --- 3. VNC-á¥à¢¥à (¯®¨áª/§ £à㧪 ) ---
set "SPAWNARGS="
set "SPAWN_CMD="
if exist "vnc\winvnc.exe" goto uselocalvnc
if exist "vnc\tvnserver.exe" goto uselocalvnc
if exist "C:\Program Files\UltraVNC\winvnc.exe" goto autodetectvnc
if exist "C:\Program Files (x86)\UltraVNC\winvnc.exe" goto autodetectvnc
if exist "C:\Program Files\uvnc bvba\UltraVNC\winvnc.exe" goto autodetectvnc
if exist "C:\Program Files (x86)\uvnc bvba\UltraVNC\winvnc.exe" goto autodetectvnc
if exist "C:\Program Files\TightVNC\tvnserver.exe" goto autodetectvnc
if exist "C:\Program Files (x86)\TightVNC\tvnserver.exe" goto autodetectvnc
echo VNC-á¥à¢¥à ­¥ ­ ©¤¥­. ëâ îáì ᪠ç âì ¯®àâ â¨¢­ë© UltraVNC ...
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\get-vnc.ps1"
if errorlevel 1 goto novncserver
if exist "vnc\winvnc.exe" goto uselocalvnc
if exist "vnc\tvnserver.exe" goto uselocalvnc
goto novncserver
:uselocalvnc
if exist "vnc\winvnc.exe" set "SPAWN_CMD=vnc\winvnc.exe -run"
if exist "vnc\tvnserver.exe" if not defined SPAWN_CMD set "SPAWN_CMD=vnc\tvnserver.exe -run"
set "SPAWNARGS=--spawn-command "%SPAWN_CMD%""
echo  ©¤¥­ «®ª «ì­ë© VNC-á¥à¢¥à: %SPAWN_CMD%
goto vncdone
:autodetectvnc
echo VNC-á¥à¢¥à ­ ©¤¥­ ¢ á¨á⥬¥ ( ¢â®-®¯à¥¤¥«¥­¨¥ ¯à¨ § ¯ã᪥).
goto vncdone
:novncserver
echo [¯à¥¤ã¯à¥¦¤¥­¨¥] VNC-á¥à¢¥à ­¥ 㤠«®áì ¯®«ãç¨âì.
echo ¥§ VNC-á¥à¢¥à  à ¡®ç¨© á⮫ ­¥ ¡ã¤¥â â࠭᫨஢ âìáï.
echo “áâ ­®¢¨â¥ UltraVNC/TightVNC ¢àãç­ãî ¨«¨ ¯®¢â®à¨â¥: scripts\get-vnc.ps1
echo.
:vncdone
REM --- 4.  à®«ì ---
:getpw
set "PW="
set /p "PW=‚¢¥¤¨â¥ ¯ à®«ì ¤®áâ㯠: "
if "%PW%"=="" goto emptypw
goto gotpw
:emptypw
echo  à®«ì ­¥ ¬®¦¥â ¡ëâì ¯ãáâë¬.
goto getpw
:gotpw
REM --- 5. •íè ¯ à®«ï + â®â ¦¥ ¯ à®«ì ¤«ï VNC-á¥à¢¥à  ---
echo ƒ¥­¥à¨àãî åíè ¯ à®«ï ...
for /f "delims=" %%i in ('web-vnc.exe --gen-hash "%PW%"') do set "HASH=%%i"
if "%HASH%"=="" goto hashfail
REM ’®â ¦¥ ¯ à®«ì ¡ã¤¥â  ¢â®¬ â¨ç¥áª¨ ¯¥à¥¤ ­ noVNC ¤«ï  ¢â®à¨§ æ¨¨ ­  VNC-á¥à¢¥à¥.
set "WEBVNC_VNC_PASSWORD=%PW%"
set "PW="
REM --- 6. „®áâã¯­ë¥  ¤à¥á  ---
echo.
echo === €¤à¥á  ¤«ï ¯®¤ª«î祭¨ï (¯®àâ 8080) ===
echo http://localhost:8080
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\list-ips.ps1"') do echo http://%%a:8080
echo.
echo …᫨ á ¤à㣮© ¬ è¨­ë ­¥ ®âªà뢠¥âáï - ®¤¨­ à § ¢ë¯®«­¨â¥ ®â ¨¬¥­¨
echo  ¤¬¨­¨áâà â®à : scripts\open-firewall.bat
echo.
REM --- 7. ‡ ¯ã᪠---
echo ‡ ¯ã᪠î web-vnc ­  http://localhost:8080
echo Žáâ ­®¢¨âì: Ctrl+C
echo.
web-vnc.exe --password-hash "%HASH%" %SPAWNARGS% --spawn --listen :8080
echo.
echo ‘¥à¢¥à ®áâ ­®¢«¥­.
pause
exit /b
:buildfail
echo ‘¡®àª  ­¥ 㤠« áì.
pause
exit /b 1
:hashfail
echo [®è¨¡ª ] ¥ 㤠«®áì ᣥ­¥à¨à®¢ âì åíè ¯ à®«ï.
pause
exit /b 1