-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
421 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
:: -------------------------------------------------------------- | ||
:: 项目: CloudflareSpeedTest 自动更新 3Proxy | ||
:: 版本: 1.0.5 | ||
:: 作者: XIU2 | ||
:: 项目: https://github.com/XIU2/CloudflareSpeedTest | ||
:: -------------------------------------------------------------- | ||
@echo off | ||
Setlocal Enabledelayedexpansion | ||
|
||
::判断是否已获得管理员权限 | ||
|
||
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" | ||
|
||
if '%errorlevel%' NEQ '0' ( | ||
goto UACPrompt | ||
) else ( goto gotAdmin ) | ||
|
||
::写出 vbs 脚本以管理员身份运行本脚本(bat) | ||
|
||
:UACPrompt | ||
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" | ||
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" | ||
"%temp%\getadmin.vbs" | ||
exit /B | ||
|
||
::如果临时 vbs 脚本存在,则删除 | ||
|
||
:gotAdmin | ||
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) | ||
pushd "%CD%" | ||
CD /D "%~dp0" | ||
|
||
|
||
::上面是判断是否以获得管理员权限,如果没有就去获取,下面才是本脚本主要代码 | ||
|
||
|
||
::如果 nowip_3proxy.txt 文件不存在,说明是第一次运行该脚本 | ||
if not exist "nowip_3proxy.txt" ( | ||
echo 该脚本的作用为 CloudflareST 测速后获取最快 IP 并替换 3Proxy 配置文件中的 Cloudflare CDN IP。 | ||
echo 可以把所有 Cloudflare CDN IP 都重定向至最快 IP,实现一劳永逸的加速所有使用 Cloudflare CDN 的网站(不需要一个个添加域名到 Hosts 了)。 | ||
echo 使用前请先阅读:https://github.com/XIU2/CloudflareSpeedTest/discussions/71 | ||
echo. | ||
set /p nowip="输入当前 3Proxy 正在使用的 Cloudflare CDN IP 并回车(后续不再需要该步骤):" | ||
echo !nowip!>nowip_3proxy.txt | ||
echo. | ||
) | ||
|
||
::从 nowip_3proxy.txt 文件获取当前使用的 Cloudflare CDN IP | ||
set /p nowip=<nowip_3proxy.txt | ||
echo 开始测速... | ||
|
||
|
||
:: 这个 RESET 是给需要 "找不到满足条件的 IP 就一直循环测速下去" 功能的人准备的 | ||
:: 如果需要这个功能就把下面 3 个 goto :STOP 改为 goto :RESET 即可 | ||
:RESET | ||
|
||
|
||
:: 这里可以自己添加、修改 CloudflareST 的运行参数,echo.| 的作用是自动回车退出程序(不再需要加上 -p 0 参数了) | ||
echo.|CloudflareST.exe -o "result_3proxy.txt" | ||
|
||
|
||
:: 判断结果文件是否存在,如果不存在说明结果为 0 | ||
if not exist result_3proxy.txt ( | ||
echo. | ||
echo CloudflareST 测速结果 IP 数量为 0,跳过下面步骤... | ||
goto :STOP | ||
) | ||
|
||
:: 获取第一行的最快 IP | ||
for /f "tokens=1 delims=," %%i in (result_3proxy.txt) do ( | ||
set /a n+=1 | ||
If !n!==2 ( | ||
set bestip=%%i | ||
goto :END | ||
) | ||
) | ||
:END | ||
|
||
:: 判断刚刚获取的最快 IP 是否为空,以及是否和旧 IP 一样 | ||
if "%bestip%"=="" ( | ||
echo. | ||
echo CloudflareST 测速结果 IP 数量为 0,跳过下面步骤... | ||
goto :STOP | ||
) | ||
if "%bestip%"=="%nowip%" ( | ||
echo. | ||
echo CloudflareST 测速结果 IP 数量为 0,跳过下面步骤... | ||
goto :STOP | ||
) | ||
|
||
|
||
:: 下面这段代码是 "找不到满足条件的 IP 就一直循环测速下去" 才需要的代码 | ||
:: 考虑到当指定了下载速度下限,但一个满足全部条件的 IP 都没找到时,CloudflareST 就会输出所有 IP 结果 | ||
:: 因此当你指定 -sl 参数时,需要移除下面这段代码开头的这个 :: 冒号注释符,来做文件行数判断(比如下载测速数量:10 个,那么下面的值就设在为 11) | ||
::set /a v=0 | ||
::for /f %%a in ('type result_3proxy.txt') do set /a v+=1 | ||
::if %v% GTR 11 ( | ||
:: echo. | ||
:: echo CloudflareST 测速结果没有找到一个完全满足条件的 IP,重新测速... | ||
:: goto :RESET | ||
::) | ||
|
||
|
||
echo %bestip%>nowip_3proxy.txt | ||
echo. | ||
echo 旧 IP 为 %nowip% | ||
echo 新 IP 为 %bestip% | ||
|
||
|
||
|
||
:: 请将引号内的 D:\Program Files\3Proxy 改为你的 3Proxy 程序所在目录 | ||
CD /d "D:\Program Files\3Proxy" | ||
:: 请确保运行该脚本前,已经测试过 3Proxy 可以正常运行并使用! | ||
|
||
|
||
|
||
echo. | ||
echo 开始备份 3proxy.cfg 文件(3proxy.cfg_backup)... | ||
copy 3proxy.cfg 3proxy.cfg_backup | ||
echo. | ||
echo 开始替换... | ||
( | ||
for /f "tokens=*" %%i in (3proxy.cfg_backup) do ( | ||
set s=%%i | ||
set s=!s:%nowip%=%bestip%! | ||
echo !s! | ||
) | ||
)>3proxy.cfg | ||
|
||
net stop 3proxy | ||
net start 3proxy | ||
|
||
echo 完成... | ||
echo. | ||
:STOP | ||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
:: -------------------------------------------------------------- | ||
:: 项目: CloudflareSpeedTest 自动更新 Hosts | ||
:: 版本: 1.0.4 | ||
:: 作者: XIU2 | ||
:: 项目: https://github.com/XIU2/CloudflareSpeedTest | ||
:: -------------------------------------------------------------- | ||
@echo off | ||
Setlocal Enabledelayedexpansion | ||
|
||
::判断是否已获得管理员权限 | ||
|
||
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" | ||
|
||
if '%errorlevel%' NEQ '0' ( | ||
goto UACPrompt | ||
) else ( goto gotAdmin ) | ||
|
||
::写出 vbs 脚本以管理员身份运行本脚本(bat) | ||
|
||
:UACPrompt | ||
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" | ||
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" | ||
"%temp%\getadmin.vbs" | ||
exit /B | ||
|
||
::如果临时 vbs 脚本存在,则删除 | ||
|
||
:gotAdmin | ||
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) | ||
pushd "%CD%" | ||
CD /D "%~dp0" | ||
|
||
|
||
::上面是判断是否以获得管理员权限,如果没有就去获取,下面才是本脚本主要代码 | ||
|
||
|
||
::如果 nowip_hosts.txt 文件不存在,说明是第一次运行该脚本 | ||
if not exist "nowip_hosts.txt" ( | ||
echo 该脚本的作用为 CloudflareST 测速后获取最快 IP 并替换 Hosts 中的 Cloudflare CDN IP。 | ||
echo 使用前请先阅读:https://github.com/XIU2/CloudflareSpeedTest/issues/42#issuecomment-768273768 | ||
echo. | ||
echo 第一次使用,请先将 Hosts 中所有 Cloudflare CDN IP 统一改为一个 IP。 | ||
set /p nowip="输入该 Cloudflare CDN IP 并回车(后续不再需要该步骤):" | ||
echo !nowip!>nowip_hosts.txt | ||
echo. | ||
) | ||
|
||
::从 nowip_hosts.txt 文件获取当前 Hosts 中使用的 Cloudflare CDN IP | ||
set /p nowip=<nowip_hosts.txt | ||
echo 开始测速... | ||
|
||
|
||
:: 这个 RESET 是给需要 "找不到满足条件的 IP 就一直循环测速下去" 功能的人准备的 | ||
:: 如果需要这个功能就把下面 3 个 goto :STOP 改为 goto :RESET 即可 | ||
:RESET | ||
|
||
|
||
:: 这里可以自己添加、修改 CloudflareST 的运行参数,echo.| 的作用是自动回车退出程序(不再需要加上 -p 0 参数了) | ||
echo.|CloudflareST.exe -o "result_hosts.txt" | ||
|
||
|
||
:: 判断结果文件是否存在,如果不存在说明结果为 0 | ||
if not exist result_hosts.txt ( | ||
echo. | ||
echo CloudflareST 测速结果 IP 数量为 0,跳过下面步骤... | ||
goto :STOP | ||
) | ||
|
||
:: 获取第一行的最快 IP | ||
for /f "tokens=1 delims=," %%i in (result_hosts.txt) do ( | ||
SET /a n+=1 | ||
If !n!==2 ( | ||
SET bestip=%%i | ||
goto :END | ||
) | ||
) | ||
:END | ||
|
||
:: 判断刚刚获取的最快 IP 是否为空,以及是否和旧 IP 一样 | ||
if "%bestip%"=="" ( | ||
echo. | ||
echo CloudflareST 测速结果 IP 数量为 0,跳过下面步骤... | ||
goto :STOP | ||
) | ||
if "%bestip%"=="%nowip%" ( | ||
echo. | ||
echo CloudflareST 测速结果 IP 数量为 0,跳过下面步骤... | ||
goto :STOP | ||
) | ||
|
||
|
||
:: 下面这段代码是 "找不到满足条件的 IP 就一直循环测速下去" 才需要的代码 | ||
:: 考虑到当指定了下载速度下限,但一个满足全部条件的 IP 都没找到时,CloudflareST 就会输出所有 IP 结果 | ||
:: 因此当你指定 -sl 参数时,需要移除下面这段代码开头的这个 :: 冒号注释符,来做文件行数判断(比如下载测速数量:10 个,那么下面的值就设在为 11) | ||
::set /a v=0 | ||
::for /f %%a in ('type result_hosts.txt') do set /a v+=1 | ||
::if %v% GTR 11 ( | ||
:: echo. | ||
:: echo CloudflareST 测速结果没有找到一个完全满足条件的 IP,重新测速... | ||
:: goto :RESET | ||
::) | ||
|
||
|
||
echo %bestip%>nowip_hosts.txt | ||
echo. | ||
echo 旧 IP 为 %nowip% | ||
echo 新 IP 为 %bestip% | ||
|
||
CD /d "C:\Windows\System32\drivers\etc" | ||
echo. | ||
echo 开始备份 Hosts 文件(hosts_backup)... | ||
copy hosts hosts_backup | ||
echo. | ||
echo 开始替换... | ||
( | ||
for /f "tokens=*" %%i in (hosts_backup) do ( | ||
set s=%%i | ||
set s=!s:%nowip%=%bestip%! | ||
echo !s! | ||
) | ||
)>hosts | ||
|
||
echo 完成... | ||
echo. | ||
:STOP | ||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
173.245.48.0/20 | ||
103.21.244.0/22 | ||
103.22.200.0/22 | ||
103.31.4.0/22 | ||
141.101.64.0/18 | ||
108.162.192.0/18 | ||
190.93.240.0/20 | ||
188.114.96.0/20 | ||
197.234.240.0/22 | ||
198.41.128.0/17 | ||
162.158.0.0/15 | ||
104.16.0.0/12 | ||
172.64.0.0/17 | ||
172.64.128.0/18 | ||
172.64.192.0/19 | ||
172.64.224.0/22 | ||
172.64.229.0/24 | ||
172.64.230.0/23 | ||
172.64.232.0/21 | ||
172.64.240.0/21 | ||
172.64.248.0/21 | ||
172.65.0.0/16 | ||
172.66.0.0/16 | ||
172.67.0.0/16 | ||
131.0.72.0/22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
2400:cb00:2049::/48 | ||
2400:cb00:f00e::/48 | ||
2606:4700::/32 | ||
2606:4700:10::/48 | ||
2606:4700:130::/48 | ||
2606:4700:3000::/48 | ||
2606:4700:3001::/48 | ||
2606:4700:3002::/48 | ||
2606:4700:3003::/48 | ||
2606:4700:3004::/48 | ||
2606:4700:3005::/48 | ||
2606:4700:3006::/48 | ||
2606:4700:3007::/48 | ||
2606:4700:3008::/48 | ||
2606:4700:3009::/48 | ||
2606:4700:3010::/48 | ||
2606:4700:3011::/48 | ||
2606:4700:3012::/48 | ||
2606:4700:3013::/48 | ||
2606:4700:3014::/48 | ||
2606:4700:3015::/48 | ||
2606:4700:3016::/48 | ||
2606:4700:3017::/48 | ||
2606:4700:3018::/48 | ||
2606:4700:3019::/48 | ||
2606:4700:3020::/48 | ||
2606:4700:3021::/48 | ||
2606:4700:3022::/48 | ||
2606:4700:3023::/48 | ||
2606:4700:3024::/48 | ||
2606:4700:3025::/48 | ||
2606:4700:3026::/48 | ||
2606:4700:3027::/48 | ||
2606:4700:3028::/48 | ||
2606:4700:3029::/48 | ||
2606:4700:3030::/48 | ||
2606:4700:3031::/48 | ||
2606:4700:3032::/48 | ||
2606:4700:3033::/48 | ||
2606:4700:3034::/48 | ||
2606:4700:3035::/48 | ||
2606:4700:3036::/48 | ||
2606:4700:3037::/48 | ||
2606:4700:3038::/48 | ||
2606:4700:3039::/48 | ||
2606:4700:a0::/48 | ||
2606:4700:a1::/48 | ||
2606:4700:a8::/48 | ||
2606:4700:a9::/48 | ||
2606:4700:a::/48 | ||
2606:4700:b::/48 | ||
2606:4700:c::/48 | ||
2606:4700:d0::/48 | ||
2606:4700:d1::/48 | ||
2606:4700:d::/48 | ||
2606:4700:e0::/48 | ||
2606:4700:e1::/48 | ||
2606:4700:e2::/48 | ||
2606:4700:e3::/48 | ||
2606:4700:e4::/48 | ||
2606:4700:e5::/48 | ||
2606:4700:e6::/48 | ||
2606:4700:e7::/48 | ||
2606:4700:e::/48 | ||
2606:4700:f1::/48 | ||
2606:4700:f2::/48 | ||
2606:4700:f3::/48 | ||
2606:4700:f4::/48 | ||
2606:4700:f5::/48 | ||
2606:4700:f::/48 | ||
2803:f800:50::/48 | ||
2803:f800:51::/48 | ||
2a06:98c1:3100::/48 | ||
2a06:98c1:3101::/48 | ||
2a06:98c1:3102::/48 | ||
2a06:98c1:3103::/48 | ||
2a06:98c1:3104::/48 | ||
2a06:98c1:3105::/48 | ||
2a06:98c1:3106::/48 | ||
2a06:98c1:3107::/48 | ||
2a06:98c1:3108::/48 | ||
2a06:98c1:3109::/48 | ||
2a06:98c1:310a::/48 | ||
2a06:98c1:310b::/48 | ||
2a06:98c1:310c::/48 | ||
2a06:98c1:310d::/48 | ||
2a06:98c1:310e::/48 | ||
2a06:98c1:310f::/48 | ||
2a06:98c1:3120::/48 | ||
2a06:98c1:3121::/48 | ||
2a06:98c1:3122::/48 | ||
2a06:98c1:3123::/48 | ||
2a06:98c1:3200::/48 | ||
2a06:98c1:50::/48 | ||
2a06:98c1:51::/48 | ||
2a06:98c1:54::/48 | ||
2a06:98c1:58::/48 |
Oops, something went wrong.