Fake replace feature; closes #16007 closes #15942

This commit is contained in:
Flowseal
2026-07-22 06:34:36 +03:00
parent 1a7d98d506
commit 73cee5db28
26 changed files with 166 additions and 51 deletions

View File

@@ -79,21 +79,22 @@ echo :: SETTINGS
echo 4. Game Filter [!GameFilterStatus!]
echo 5. IPSet Filter [!IPsetStatus!]
echo 6. Auto-Update Check [!CheckUpdatesStatus!]
echo 7. Replace active fakes
echo.
echo :: UPDATES
echo 7. Update IPSet List
echo 8. Update Hosts File
echo 9. Check for Updates
echo 8. Update IPSet List
echo 9. Update Hosts File
echo 10. Check for Updates
echo.
echo :: TOOLS
echo 10. Run Diagnostics
echo 11. Run Tests
echo 11. Run Diagnostics
echo 12. Run Tests
echo.
echo ----------------------------------------
echo 0. Exit
echo.
set /p menu_choice= Select option (0-11):
set /p menu_choice= Select option (0-12):
if "%menu_choice%"=="1" goto service_install
if "%menu_choice%"=="2" goto service_remove
@@ -101,11 +102,12 @@ if "%menu_choice%"=="3" goto service_status
if "%menu_choice%"=="4" goto game_switch
if "%menu_choice%"=="5" goto ipset_switch
if "%menu_choice%"=="6" goto check_updates_switch
if "%menu_choice%"=="7" goto ipset_update
if "%menu_choice%"=="8" goto hosts_update
if "%menu_choice%"=="9" goto service_check_updates
if "%menu_choice%"=="10" goto service_diagnostics
if "%menu_choice%"=="11" goto run_tests
if "%menu_choice%"=="7" goto replace_active_fakes
if "%menu_choice%"=="8" goto ipset_update
if "%menu_choice%"=="9" goto hosts_update
if "%menu_choice%"=="10" goto service_check_updates
if "%menu_choice%"=="11" goto service_diagnostics
if "%menu_choice%"=="12" goto run_tests
if "%menu_choice%"=="0" exit /b
goto menu
@@ -819,6 +821,119 @@ pause
goto menu
:: REPLACE ACTIVE FAKES =================
:replace_active_fakes
chcp 437 > nul
cls
set "BIN_PATH=%~dp0bin\"
set "fake_count=0"
set "fake_type="
set "fake_number="
set "discord_hash="
set "game_hash="
set "current_discord_fake=(not found)"
set "current_game_fake=(not found)"
if not exist "%BIN_PATH%" (
echo Error: bin folder not found.
pause
goto menu
)
pushd "%BIN_PATH%"
for /f "tokens=1,2,3 delims=|" %%A in ('powershell -NoProfile -Command "foreach ($item in @(@{Name='ACTIVE_DISCORD_UDP.bin'; Label='ACTIVE_DISCORD'},@{Name='ACTIVE_GAME_UDP.bin'; Label='ACTIVE_GAME'})) { if (Test-Path -LiteralPath $item.Name) { Write-Output ($item.Label + [char]124 + $item.Label + [char]124 + (Get-FileHash -LiteralPath $item.Name -Algorithm SHA256).Hash) } }; $files = @(Get-ChildItem -LiteralPath . -File -Filter '*.bin'); foreach ($file in $files) { if ($file.BaseName -notlike 'ACTIVE_*') { Write-Output ('FAKE' + [char]124 + $file.BaseName + [char]124 + (Get-FileHash -LiteralPath $file.FullName -Algorithm SHA256).Hash) } }"') do (
if "%%A"=="ACTIVE_DISCORD" (
set "discord_hash=%%C"
) else if "%%A"=="ACTIVE_GAME" (
set "game_hash=%%C"
) else if "%%A"=="FAKE" (
set /a fake_count+=1
set "fake_file!fake_count!=%BIN_PATH%%%B.bin"
set "fake_name!fake_count!=%%B"
set "fake_hash!fake_count!=%%C"
)
)
popd
if !fake_count! EQU 0 (
echo No .bin files were found in the bin folder.
pause
goto menu
)
for /l %%N in (1,1,!fake_count!) do (
if defined discord_hash if /i "!fake_hash%%N!"=="!discord_hash!" set "current_discord_fake=!fake_name%%N!"
if defined game_hash if /i "!fake_hash%%N!"=="!game_hash!" set "current_game_fake=!fake_name%%N!"
)
:replace_active_fakes_prompt
echo.
echo Enter the fake type number and the fake file number to replace it with.
echo Example: 1 4 (replaces Discord UDP with fake file under number 4)
echo 2 1 (replaces GameFilter UDP with fake file under number 1)
echo.
echo Press ENTER or 0 to return.
echo.
echo ----------------------------------------
echo.
echo Fake types:
echo 1. Discord UDP (current: !current_discord_fake!)
echo 2. GameFilter UDP (current: !current_game_fake!)
echo.
echo Fake files:
for /l %%N in (1,1,!fake_count!) do echo %%N. !fake_name%%N!
echo.
set "replace_choice="
set /p "replace_choice=Enter choice: "
if not defined replace_choice goto menu
if "!replace_choice!"=="0" goto menu
set "active_file="
set "fake_type="
set "fake_number="
for /f "tokens=1,2" %%A in ("!replace_choice!") do (
set "fake_type=%%A"
set "fake_number=%%B"
)
if "!fake_type!"=="1" (
set "active_file=%BIN_PATH%ACTIVE_DISCORD_UDP.bin"
) else if "!fake_type!"=="2" (
set "active_file=%BIN_PATH%ACTIVE_GAME_UDP.bin"
) else (
echo Invalid fake type.
pause
cls
goto replace_active_fakes_prompt
)
set "source_file="
for /l %%N in (1,1,!fake_count!) do if "%%N"=="!fake_number!" set "source_file=!fake_file%%N!"
if not defined source_file (
echo Invalid fake file number.
pause
cls
goto replace_active_fakes_prompt
)
del /f /q "!active_file!" >nul 2>&1
copy /y "!source_file!" "!active_file!" >nul
if errorlevel 1 (
echo Failed to replace the active fake file.
) else (
echo Active fake file replaced successfully.
for /l %%N in (1,1,!fake_count!) do if "%%N"=="!fake_number!" (
if "!fake_type!"=="1" set "current_discord_fake=!fake_name%%N!"
if "!fake_type!"=="2" set "current_game_fake=!fake_name%%N!"
)
)
pause
cls
goto replace_active_fakes_prompt
:: IPSET SWITCH =======================
:ipset_switch_status
chcp 437 > nul