diff --git a/.gitignore b/.gitignore index a16e7a5..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +0,0 @@ -version.txt \ No newline at end of file diff --git a/bin/winws.exe b/bin/winws.exe index 74ddafe..f450cc5 100644 Binary files a/bin/winws.exe and b/bin/winws.exe differ diff --git a/check_updates.bat b/check_updates.bat index 03fe620..642be00 100644 --- a/check_updates.bat +++ b/check_updates.bat @@ -2,87 +2,36 @@ setlocal EnableDelayedExpansion chcp 437 > nul -set "CURRENT_VERSION=1.6.3" -set "GITHUB_URL=https://raw.githubusercontent.com/Flowseal/zapret-discord-youtube/refs/heads/main/.service/version.txt" -set "RELEASE_URL=https://github.com/Flowseal/zapret-discord-youtube/releases" -set "VERSION_FILE=version.txt" -set "SKIP_VERSION=null" -set "FILE_EXISTS=1" +:: Set current version and URLs +set "LOCAL_VERSION=1.6.3" +set "GITHUB_VERSION_URL=https://raw.githubusercontent.com/Flowseal/zapret-discord-youtube/main/.service/version.txt" +set "GITHUB_RELEASE_URL=https://github.com/Flowseal/zapret-discord-youtube/releases/tag/" +set "GITHUB_DOWNLOAD_URL=https://github.com/Flowseal/zapret-discord-youtube/releases/latest/download/zapret-discord-youtube-" -for /f "delims=" %%A in ('powershell -command "[datetime]::Now.ToString('yyyy-MM-dd HH:mm:ss')"') do set CURRENT_TIMESTAMP=%%A +:: Get the latest version from GitHub +for /f "delims=" %%A in ('powershell -command "(Invoke-WebRequest -Uri \"%GITHUB_VERSION_URL%\" -Headers @{\"Cache-Control\"=\"no-cache\"} -TimeoutSec 5).Content.Trim()" 2^>nul') do set "GITHUB_VERSION=%%A" -:: If file version.txt exists -if not exist %VERSION_FILE% ( - set "FILE_EXISTS=0" - echo time: %CURRENT_TIMESTAMP%> %VERSION_FILE% - echo ver: %CURRENT_VERSION%>> %VERSION_FILE% -) - -:: Reading data from local version.txt -for /f "tokens=1,* delims=: " %%A in (%VERSION_FILE%) do ( - if "%%A"=="time" set "LAST_CHECK=%%B" - if "%%A"=="ver" set "INSTALLED_VERSION=%%B" - if "%%A"=="skip" set "SKIP_VERSION=%%B" -) - -:: If file was called from thirdparty script (with 'soft' argument that blocks checking for 12 hours) -if "%~1"=="soft" ( - :: Converting dates to parts for calculation - for /f "tokens=1-6 delims=-: " %%A in ("%CURRENT_TIMESTAMP%") do ( - set "CURRENT_MONTH=%%B" - set "CURRENT_DAY=%%C" - set "CURRENT_HOUR=%%D" - ) - for /f "tokens=1-6 delims=-: " %%A in ("%LAST_CHECK%") do ( - set "LAST_MONTH=%%B" - set "LAST_DAY=%%C" - set "LAST_HOUR=%%D" - ) - - set /a "time_diff_in_minutes = (CURRENT_MONTH - LAST_MONTH) * 43200 + (CURRENT_DAY - LAST_DAY) * 1440 + (CURRENT_HOUR - LAST_HOUR) * 60" - - if !time_diff_in_minutes! LEQ 360 if !FILE_EXISTS!==1 ( - echo Skipping the update check because it hasnt been 6 hours - goto :EOF - ) -) - -:: Reading new version from github -set "NEW_VERSION=" -for /f "delims=" %%A in ('powershell -command "(Invoke-WebRequest -Uri %GITHUB_URL% -Headers @{\"Cache-Control\"=\"no-cache\"} -TimeoutSec 5).Content" 2^>nul') do set "NEW_VERSION=%%A" -if not defined NEW_VERSION ( - echo Error reading new version +:: Error handling +if not defined GITHUB_VERSION ( + echo Error: Failed to fetch the latest version. Check your internet connection goto :EOF ) -:: Rewrite file -echo time: %CURRENT_TIMESTAMP%> %VERSION_FILE% -echo ver: %INSTALLED_VERSION%>> %VERSION_FILE% -echo skip: %SKIP_VERSION%>> %VERSION_FILE% - -:: Comparing versions -if "%NEW_VERSION%"=="%INSTALLED_VERSION%" ( - echo You are using the latest version %NEW_VERSION%. - goto :EOF +:: Version comparison +if "%LOCAL_VERSION%"=="%GITHUB_VERSION%" ( + echo Latest version installed: %LOCAL_VERSION% ) else ( - :: Check if version skipped - if "%NEW_VERSION%"=="%SKIP_VERSION%" ( - echo Newer version %NEW_VERSION% skipped by user. - goto :EOF - ) else ( - echo New version found: %NEW_VERSION%. - echo Visit %RELEASE_URL% to download a new version + echo New version available: %GITHUB_VERSION% + echo Release page: %GITHUB_RELEASE_URL%%GITHUB_VERSION% + + set /p "CHOICE=Do you want to automatically download the new version? (y/n, default: y): " + + if "!CHOICE!"=="" set "CHOICE=y" + + if /i "!CHOICE!"=="y" ( + echo Opening the download page... + start "" "%GITHUB_DOWNLOAD_URL%%GITHUB_VERSION%.zip" ) ) - -:: Skip check -set /p "CHOICE=Skip this update? (y/n, default: n): " || set "CHOICE=n" -set "CHOICE=!CHOICE:~0,1!" -if /i "!CHOICE!"=="y" ( - echo skip: %NEW_VERSION%>> %VERSION_FILE% - echo Update %NEW_VERSION% skipped. -) else ( - start %RELEASE_URL% -) - +if not "%1"=="soft" pause endlocal diff --git a/discord.bat b/discord.bat index 0473570..ad37d36 100644 --- a/discord.bat +++ b/discord.bat @@ -1,5 +1,5 @@ @echo off -chcp 65001 >nul +chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" diff --git a/general (ALT).bat b/general (ALT).bat index 4cb006a..1b4e7d8 100644 --- a/general (ALT).bat +++ b/general (ALT).bat @@ -1,5 +1,5 @@ @echo off -chcp 65001 >nul +chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" diff --git a/general (ALT2).bat b/general (ALT2).bat index c2d5147..bfe77bc 100644 --- a/general (ALT2).bat +++ b/general (ALT2).bat @@ -1,5 +1,5 @@ @echo off -chcp 65001 >nul +chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" diff --git a/general (ALT3).bat b/general (ALT3).bat index 5a47424..911e8e8 100644 --- a/general (ALT3).bat +++ b/general (ALT3).bat @@ -1,5 +1,5 @@ @echo off -chcp 65001 >nul +chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" diff --git a/general (ALT4).bat b/general (ALT4).bat index 18caf66..aef06a8 100644 --- a/general (ALT4).bat +++ b/general (ALT4).bat @@ -1,5 +1,5 @@ @echo off -chcp 65001 >nul +chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" diff --git a/general (ALT5).bat b/general (ALT5).bat index f034108..840e746 100644 --- a/general (ALT5).bat +++ b/general (ALT5).bat @@ -1,5 +1,5 @@ @echo off -chcp 65001 >nul +chcp 65001 > nul :: 65001 - UTF-8 :: NOT RECOMMENDED diff --git a/general (МГТС).bat b/general (МГТС).bat index 01f644d..b4eec88 100644 --- a/general (МГТС).bat +++ b/general (МГТС).bat @@ -1,5 +1,5 @@ @echo off -chcp 65001 >nul +chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" diff --git a/general (МГТС2).bat b/general (МГТС2).bat index 85549f5..805046b 100644 --- a/general (МГТС2).bat +++ b/general (МГТС2).bat @@ -1,5 +1,5 @@ @echo off -chcp 65001 >nul +chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" diff --git a/general.bat b/general.bat index e749b5e..83d24fa 100644 --- a/general.bat +++ b/general.bat @@ -1,5 +1,5 @@ @echo off -chcp 65001 >nul +chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" diff --git a/list-discord.txt b/list-discord.txt index 35d8307..46d4207 100644 --- a/list-discord.txt +++ b/list-discord.txt @@ -1,19 +1,25 @@ -discord.com -gateway.discord.gg -cdn.discordapp.com -discordapp.net -discordapp.com -discord.gg -media.discordapp.net -images-ext-1.discordapp.net -discord.app -discord.media -discordcdn.com -discord.dev -discord.new -discord.gift -discordstatus.com +cloudflare-ech.com dis.gd -discord.co discord-attachments-uploads-prd.storage.googleapis.com -cloudflare-ech.com \ No newline at end of file +discord.app +discord.co +discord.com +discord.design +discord.dev +discord.gift +discord.gifts +discord.gg +discord.media +discord.new +discord.status +discord.store +discordapp.com +discordapp.net +discordcdn.com +discordmerch.com +discordpartygames.com +discordsays.com +discordsez.com +discord-activities.com +discordactivities.com +stable.dl2.discordapp.net diff --git a/list-general.txt b/list-general.txt index 3072fc6..e67251a 100644 --- a/list-general.txt +++ b/list-general.txt @@ -1,36 +1,42 @@ -googlevideo.com -youtu.be -youtube.com -youtubei.googleapis.com -youtubeembeddedplayer.googleapis.com -ytimg.l.google.com -ytimg.com -jnn-pa.googleapis.com -youtube-nocookie.com -youtube-ui.l.google.com -yt-video-upload.l.google.com -wide-youtube.l.google.com -youtubekids.com -ggpht.com -discord.com -gateway.discord.gg -cdn.discordapp.com -discordapp.net -discordapp.com -discord.gg -media.discordapp.net -images-ext-1.discordapp.net -discord.app -discord.media -discordcdn.com -discord.dev -discord.new -discord.gift -discordstatus.com -dis.gd -discord.co -discord-attachments-uploads-prd.storage.googleapis.com +10tv.app 7tv.app 7tv.io -10tv.app -cloudflare-ech.com \ No newline at end of file +cloudflare-ech.com +dis.gd +discord-attachments-uploads-prd.storage.googleapis.com +discord.app +discord.co +discord.com +discord.design +discord.dev +discord.gift +discord.gifts +discord.gg +discord.media +discord.new +discord.store +discord.status +discord-activities.com +discordactivities.com +discordapp.com +discordapp.net +discordcdn.com +discordmerch.com +discordpartygames.com +discordsays.com +discordsez.com +ggpht.com +googlevideo.com +jnn-pa.googleapis.com +stable.dl2.discordapp.net +wide-youtube.l.google.com +youtube-nocookie.com +youtube-ui.l.google.com +youtube.com +youtubeembeddedplayer.googleapis.com +youtubekids.com +youtubei.googleapis.com +youtu.be +yt-video-upload.l.google.com +ytimg.com +ytimg.l.google.com diff --git a/service_install.bat b/service_install.bat index f2bb09d..29cc13c 100644 --- a/service_install.bat +++ b/service_install.bat @@ -1,23 +1,27 @@ @echo off setlocal EnableDelayedExpansion -chcp 65001 >nul +chcp 65001 > nul :: 65001 - UTF-8 -set "arg=%1" -if "%arg%" == "admin" ( - echo Restarted with admin rights +:: Admin rights check +if "%1"=="admin" ( + echo Started with admin rights ) else ( + echo Requesting admin rights... powershell -Command "Start-Process 'cmd.exe' -ArgumentList '/k \"\"%~f0\" admin\"' -Verb RunAs" exit /b ) +:: Main cd /d "%~dp0" +set BIN_PATH=%~dp0bin\ + +:: Checking for updates call check_updates.bat soft echo: -set BIN_PATH=%~dp0bin\ - :: Searching for .bat files in current folder, except files that start with "service" +echo Pick one of the options: set "count=0" for %%f in (*.bat) do ( set "filename=%%~nxf" @@ -31,12 +35,11 @@ for %%f in (*.bat) do ( :: Choosing file set "choice=" set /p "choice=Input file index (number): " - if "!choice!"=="" goto :eof set "selectedFile=!file%choice%!" if not defined selectedFile ( - echo Wrong choice, exiting.. + echo Wrong choice, exiting... pause goto :eof ) @@ -107,11 +110,13 @@ for /f "tokens=*" %%a in ('type "!selectedFile!"') do ( :: Creating service with parsed args set ARGS=%args% echo Final args: !ARGS! - set SRVCNAME=zapret -net stop %SRVCNAME% -sc delete %SRVCNAME% +net stop %SRVCNAME% >nul 2>&1 +sc delete %SRVCNAME% >nul 2>&1 sc create %SRVCNAME% binPath= "\"%BIN_PATH%winws.exe\" %ARGS%" DisplayName= "zapret" start= auto -sc description %SRVCNAME% "zapret DPI bypass software" +sc description %SRVCNAME% "Zapret DPI bypass software" sc start %SRVCNAME% + +pause +endlocal diff --git a/service_remove.bat b/service_remove.bat index 1be3524..654c43f 100644 --- a/service_remove.bat +++ b/service_remove.bat @@ -1,11 +1,11 @@ @echo off -chcp 65001 >nul +chcp 65001 > nul :: 65001 - UTF-8 -set "arg=%1" -if "%arg%" == "admin" ( - echo Restarted with admin rights +if "%1"=="admin" ( + echo Started with admin rights ) else ( + echo Requesting admin rights... powershell -Command "Start-Process 'cmd.exe' -ArgumentList '/k \"\"%~f0\" admin\"' -Verb RunAs" exit /b ) @@ -19,3 +19,6 @@ net stop "WinDivert" sc delete "WinDivert" net stop "WinDivert14" sc delete "WinDivert14" + +pause +endlocal diff --git a/service_status.bat b/service_status.bat index b260adc..fab9526 100644 --- a/service_status.bat +++ b/service_status.bat @@ -1,5 +1,6 @@ @echo off -chcp 65001 >nul +chcp 65001 > nul +:: 65001 - UTF-8 if "%~1"=="" ( call :test_service zapret