mirror of
https://github.com/SillyTavern/SillyTavern-Launcher.git
synced 2026-04-28 10:11:41 +00:00
Added log detection failure fallback & VPN detection to warn of install issues
- Added log detection failure fallback so if logs aren't found for auto-repair SillyTavern it launches with start.bat normally - VPN detection to warn of install issues because Node.JS will sometimes partially fail to install if a VPN is active - added a developer fast restart option under 000 at home.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -9,4 +9,5 @@ bin/*
|
||||
!bin/functions/
|
||||
!bin/functions/**
|
||||
*.txt
|
||||
*.logs
|
||||
*.logs
|
||||
/bin/functions/Toolbox/Troubleshooting/telemetry/venv
|
||||
|
||||
13
Launcher.bat
13
Launcher.bat
@@ -447,14 +447,21 @@ echo 0. Exit
|
||||
REM Get the current Git branch
|
||||
for /f %%i in ('git branch --show-current') do set current_branch=%%i
|
||||
|
||||
|
||||
REM Call the VPN detection script
|
||||
call "%troubleshooting_dir%\detect_vpn.bat" > "%log_dir%\vpn_status.txt"
|
||||
set /p "vpnStatus="<"%log_dir%\vpn_status.txt"
|
||||
del "%log_dir%\vpn_status.txt"
|
||||
|
||||
echo ======== VERSION STATUS =========
|
||||
echo SillyTavern branch: %cyan_fg_strong%%current_branch%%reset%
|
||||
echo SillyTavern: %update_status_st%
|
||||
echo STL Version: %stl_version%
|
||||
echo GPU VRAM: %cyan_fg_strong%%VRAM% GB%reset%
|
||||
echo Node.js: %node_version%
|
||||
echo ======== COMPATIBILITY STATUS =========
|
||||
echo %vpnStatus%
|
||||
echo =================================
|
||||
|
||||
set "choice="
|
||||
set /p "choice=Choose Your Destiny (default is 1): "
|
||||
|
||||
@@ -531,6 +538,10 @@ if "%choice%"=="1" (
|
||||
pause
|
||||
goto :home
|
||||
)
|
||||
) else if "%choice%"=="000" (
|
||||
call %troubleshooting_dir%\restart_stl.bat
|
||||
goto :home
|
||||
|
||||
) else (
|
||||
echo [%DATE% %TIME%] %log_invalidinput% >> %logs_stl_console_path%
|
||||
echo %red_bg%[%time%]%reset% %echo_invalidinput%
|
||||
|
||||
116
bin/functions/Toolbox/Troubleshooting/detect_vpn.bat
Normal file
116
bin/functions/Toolbox/Troubleshooting/detect_vpn.bat
Normal file
@@ -0,0 +1,116 @@
|
||||
@echo off
|
||||
REM This script detects if a VPN is active by checking network adapters using netsh and an external IP check.
|
||||
|
||||
REM Initialize variables
|
||||
set "vpnDetected=false"
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM Define log directory
|
||||
set "log_dir=C:\Users\Hayden\Documents\GitHub\SillyTavern-Launcher\bin\logs"
|
||||
|
||||
REM Create a troubleshooting log
|
||||
set "logfile=%log_dir%\troubleshooting_vpn_detection.log"
|
||||
echo Troubleshooting VPN detection log > "%logfile%"
|
||||
echo ================================== >> "%logfile%"
|
||||
netsh interface show interface >> "%logfile%"
|
||||
echo ================================== >> "%logfile%"
|
||||
|
||||
REM Loop through netsh output and check for active VPN adapters
|
||||
for /f "skip=3 tokens=1,2,3,4,* delims= " %%a in ('netsh interface show interface') do (
|
||||
set "adminState=%%a"
|
||||
set "state=%%b"
|
||||
set "type=%%c"
|
||||
set "name=%%d %%e %%f"
|
||||
|
||||
REM Only check connected interfaces
|
||||
if /i "!state!"=="Connected" (
|
||||
echo Checking interface: !name! >> "%logfile%"
|
||||
if /i "!name:VPN=!" NEQ "!name!" (
|
||||
set "vpnDetected=true"
|
||||
echo Detected VPN adapter: !name! >> "%logfile%"
|
||||
goto :vpn_found
|
||||
)
|
||||
if /i "!name:Virtual Private=!" NEQ "!name!" (
|
||||
set "vpnDetected=true"
|
||||
echo Detected VPN adapter: !name! >> "%logfile%"
|
||||
goto :vpn_found
|
||||
)
|
||||
if /i "!name:TAP-Windows Adapter V9=!" NEQ "!name!" (
|
||||
set "vpnDetected=true"
|
||||
echo Detected VPN adapter: !name! >> "%logfile%"
|
||||
goto :vpn_found
|
||||
)
|
||||
if /i "!name:WireGuard Tunnel=!" NEQ "!name!" (
|
||||
set "vpnDetected=true"
|
||||
echo Detected VPN adapter: !name! >> "%logfile%"
|
||||
goto :vpn_found
|
||||
)
|
||||
if /i "!name:Mullvad=!" NEQ "!name!" (
|
||||
set "vpnDetected=true"
|
||||
echo Detected VPN adapter: !name! >> "%logfile%"
|
||||
goto :vpn_found
|
||||
)
|
||||
if /i "!name:OpenVPN Wintun=!" NEQ "!name!" (
|
||||
set "vpnDetected=true"
|
||||
echo Detected VPN adapter: !name! >> "%logfile%"
|
||||
goto :vpn_found
|
||||
)
|
||||
if /i "!name:ProtonVPN=!" NEQ "!name!" (
|
||||
set "vpnDetected=true"
|
||||
echo Detected VPN adapter: !name! >> "%logfile%"
|
||||
goto :vpn_found
|
||||
)
|
||||
if /i "!name:TunnelBear=!" NEQ "!name!" (
|
||||
set "vpnDetected=true"
|
||||
echo Detected VPN adapter: !name! >> "%logfile%"
|
||||
goto :vpn_found
|
||||
)
|
||||
if /i "!name:ExpressVPN=!" NEQ "!name!" (
|
||||
set "vpnDetected=true"
|
||||
echo Detected VPN adapter: !name! >> "%logfile%"
|
||||
goto :vpn_found
|
||||
)
|
||||
if /i "!name:SurfShark=!" NEQ "!name!" (
|
||||
set "vpnDetected=true"
|
||||
echo Detected VPN adapter: !name! >> "%logfile%"
|
||||
goto :vpn_found
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
REM Check external IP for VPN status if no VPN detected yet
|
||||
if "%vpnDetected%"=="false" (
|
||||
echo No VPN adapter detected locally, checking external IP... >> "%logfile%"
|
||||
|
||||
REM Get the external IP address
|
||||
for /f "delims=" %%i in ('curl -s --max-time 5 https://api.ipify.org') do set "externalIP=%%i"
|
||||
echo External IP: !externalIP! >> "%logfile%"
|
||||
|
||||
REM Check the external IP for VPN status using proxycheck.io
|
||||
set "apiResponse="
|
||||
for /f "delims=" %%i in ('curl -s --max-time 5 "https://proxycheck.io/v2/!externalIP!?vpn=2"') do set "apiResponse=!apiResponse! %%i"
|
||||
echo ProxyCheck API Response: !apiResponse! >> "%logfile%"
|
||||
|
||||
REM Write the API response to a temporary file
|
||||
echo !apiResponse! > "%log_dir%\vpn_check.json"
|
||||
|
||||
REM Parse the JSON response to find the proxy value
|
||||
for /f "delims=" %%a in ('type %log_dir%\vpn_check.json') do (
|
||||
set "line=%%a"
|
||||
if "!line!"=="proxy:" (
|
||||
set "vpnDetected=true"
|
||||
echo VPN detected based on external IP check. >> "%logfile%"
|
||||
goto :vpn_found
|
||||
)
|
||||
)
|
||||
echo No VPN detected based on external IP check. >> "%logfile%"
|
||||
)
|
||||
|
||||
:vpn_found
|
||||
if "%vpnDetected%"=="true" (
|
||||
echo VPN Status: %yellow_fg_strong%VPN detected. Local IP access and NodeJS install issues possible.%reset%
|
||||
) else (
|
||||
echo VPN Status: %green_fg_strong%No VPN detected.%reset%
|
||||
)
|
||||
|
||||
endlocal
|
||||
5
bin/functions/Toolbox/Troubleshooting/restart_stl.bat
Normal file
5
bin/functions/Toolbox/Troubleshooting/restart_stl.bat
Normal file
@@ -0,0 +1,5 @@
|
||||
echo Restarting launcher...
|
||||
timeout /t 3
|
||||
cd /d %stl_root%
|
||||
start %stl_root%Launcher.bat
|
||||
exit
|
||||
@@ -52,25 +52,31 @@ REM Clear the old log file if it exists
|
||||
if exist "%logs_st_console_path%" (
|
||||
del "%logs_st_console_path%"
|
||||
)
|
||||
REM Wait for log file to be created, timeout after 60 seconds (20 iterations of 3 seconds)
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Waiting for SillyTavern to fully launch...
|
||||
REM Wait for log file to be created, timeout after 30 seconds (10 iterations of 3 seconds)
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Waiting for 30 seconds for SillyTavern to fully launch...
|
||||
set "counter=0"
|
||||
:wait_for_log
|
||||
timeout /t 3 > nul
|
||||
set /a counter+=1
|
||||
if not exist "%logs_st_console_path%" (
|
||||
if %counter% lss 20 (
|
||||
if %counter% lss 10 (
|
||||
goto :wait_for_log
|
||||
) else (
|
||||
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR]%reset% Log file not found, something went wrong. Close all SillyTavern command windows and try again.
|
||||
pause
|
||||
goto :home
|
||||
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR]%reset% Log file not found, something went wrong. Launching ST with fallback method.
|
||||
goto :fallback
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
goto :scan_log
|
||||
|
||||
:fallback
|
||||
REM Fallback to %st_install_path% and start
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Fallback: Starting SillyTavern from %st_install_path%...
|
||||
start cmd /k "title SillyTavern && cd /d %st_install_path% && call npm install --no-audit && call Start.bat"
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% SillyTavern should now be launching in a new window, if you still receive errors please contact the launcher devs in the #launcher-help channel on discord.
|
||||
timeout /t 10
|
||||
exit /b 1
|
||||
|
||||
:scan_log
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Log file found, scanning log for errors...
|
||||
|
||||
@@ -99,4 +105,4 @@ if /i "%choice%"=="Y" (
|
||||
call "%troubleshooting_dir%\remove_node_modules.bat"
|
||||
if %errorlevel% equ 0 goto :home
|
||||
)
|
||||
exit /b 1
|
||||
exit /b 1
|
||||
|
||||
Reference in New Issue
Block a user