diff --git "a/batch/CF\344\274\230\351\200\211IP-ANSI.bat" "b/batch/CF\344\274\230\351\200\211IP-ANSI.bat" index 3c43ecd..60ff894 100644 --- "a/batch/CF\344\274\230\351\200\211IP-ANSI.bat" +++ "b/batch/CF\344\274\230\351\200\211IP-ANSI.bat" @@ -1,45 +1,44 @@ -chcp 936>nul +chcp 936 > nul @echo off cd "%~dp0" -color A setlocal enabledelayedexpansion -set version=20220525 +set version=20220615 -:main cls +:main title CF优选IP -echo 1. IPV4优选&echo 2. IPV6优选&echo 3. 自定义IPV4段&echo 4. 单IP测速&echo 5. 清空缓存&echo 0. 退出&echo. -set /p menu=请选择菜单: +set /a menu=1 +echo 1. IPV4优选&echo 2. IPV6优选&echo 3. 单IP测速&echo 4. 清空缓存&echo 0. 退出&echo. +set /p menu=请选择菜单(默认%menu%): if %menu%==0 exit -if %menu%==1 title IPV4优选&set ips=ipv4&set /a selfmode=0&goto bettercloudflareip -if %menu%==2 title IPV6优选&set ips=ipv6&set /a selfmode=0&goto bettercloudflareip -if %menu%==3 title 自定义IPV4段&set ips=ipv4&set /a selfmode=1&set /p selfip=请输入C类自定义IPV4(格式 104.16.16):&goto bettercloudflareip -if %menu%==4 title 单IP测速&call :singletest -if %menu%==5 del ipv4.txt ipv6.txt data.txt ip.txt CR.txt CRLF.txt cut.txt speed.txt meta.txt>nul 2>&1&RD /S /Q rtt>nul 2>&1 +if %menu%==1 title IPV4优选&set ips=ipv4&goto bettercloudflareip +if %menu%==2 title IPV6优选&set ips=ipv6&goto bettercloudflareip +if %menu%==3 title 单IP测速&call :singletest&goto main +if %menu%==4 del ipv4.txt ipv6.txt rtt.txt data.txt ip.txt CR.txt CRLF.txt cut.txt speed.txt meta.txt > nul 2>&1&RD /S /Q rtt > nul 2>&1&cls&echo 缓存已经清空&goto main +cls goto main :singletest +set /a port=443 set /p ip=请输入需要测速的IP: -curl --resolve service.baipiaocf.ml:443:!ip! https://service.baipiaocf.ml -o temp.txt -# -for /f "tokens=2 delims==" %%i in ('findstr "domain=" temp.txt') do ( -set domain=%%i -) -for /f "delims=" %%i in ('findstr "file=" temp.txt') do ( -set file=%%i -set file=!file:~5! +set /p port=请输入需要测速的端口(默认%port%): +echo 正在测速 !ip! 端口 !port! +goto download +:download +for /f "tokens=1,2 delims=_" %%i in ('curl --resolve speed.cloudflare.com:!port!:!ip! "https://speed.cloudflare.com:!port!/__down?bytes=300000000" -o nul --connect-timeout 5 --max-time 15 -w %%{http_code}_%%{speed_download}') do ( +set /a status=%%i +set /a speed_download=%%j +if !status! EQU 503 (cls&echo Cloudflare Workers 超出资源限制&echo 正在重新请求 Workers 资源&echo 正在测速 !ip! 端口 !port!&goto download) else (set /a speed_download=speed_download/1024&cls&echo !ip! 平均速度 !speed_download! kB/s) ) -del temp.txt -title 正在测速 !ip! -curl --resolve !domain!:443:!ip! https://!domain!/!file! -o nul --connect-timeout 5 --max-time 15 goto :eof :bettercloudflareip -set /a tasknum=25 +set /a tasknum=10 set /a bandwidth=1 set /p bandwidth=请设置期望的带宽大小(默认最小%bandwidth%,单位 Mbps): set /p tasknum=请设置RTT测试进程数(默认%tasknum%,最大50): if %bandwidth% EQU 0 (set /a bandwidth=1) -if %tasknum% EQU 0 (set /a tasknum=25&echo 进程数不能为0,自动设置为默认值) +if %tasknum% EQU 0 (set /a tasknum=10&echo 进程数不能为0,自动设置为默认值) if %tasknum% GTR 50 (set /a tasknum=50&echo 超过最大进程限制,自动设置为最大值) set /a speed=bandwidth*128 set /a startH=%time:~0,2% @@ -49,15 +48,15 @@ call :start exit :start -del data.txt ip.txt CR.txt CRLF.txt cut.txt speed.txt meta.txt>nul 2>&1 -RD /S /Q rtt>nul 2>&1 +del rtt.txt data.txt ip.txt CR.txt CRLF.txt cut.txt speed.txt meta.txt > nul 2>&1 +RD /S /Q rtt > nul 2>&1 if exist "!ips!.txt" goto resolve if not exist "!ips!.txt" goto dnsresolve :dnsresolve echo DNS解析获取CF !ips! 节点 echo 如果域名被污染,请手动创建 !ips!.txt 做解析 -curl --!ips! --retry 3 -s https://service.baipiaocf.ml/meta -o meta.txt +curl --!ips! --retry 1 -s https://service.baipiaocf.ml/meta -o meta.txt --connect-timeout 2 --max-time 3 if not exist "meta.txt" goto start for /f "tokens=2 delims==" %%i in ('findstr "asn=" meta.txt') do ( set asn=%%i @@ -80,7 +79,7 @@ for /f "tokens=2 delims==" %%i in ('findstr "longitude=" meta.txt') do ( for /f "tokens=2 delims==" %%i in ('findstr "latitude=" meta.txt') do ( set latitude=%%i ) -curl --!ips! --retry 3 https://service.baipiaocf.ml -o data.txt -# +curl --!ips! --retry 1 https://service.baipiaocf.ml -o data.txt -# --connect-timeout 2 --max-time 3 if not exist "data.txt" goto start goto checkupdate @@ -90,7 +89,7 @@ set resolveip=%%i ) echo 指向解析获取CF !ips! 节点 echo 如果长时间无法获取CF !ips! 节点,重新运行程序并选择清空缓存 -curl --!ips! --resolve service.baipiaocf.ml:443:!resolveip! --retry 3 -s https://service.baipiaocf.ml/meta -o meta.txt +curl --!ips! --resolve service.baipiaocf.ml:443:!resolveip! --retry 1 -s https://service.baipiaocf.ml/meta -o meta.txt --connect-timeout 2 --max-time 3 if not exist "meta.txt" goto start for /f "tokens=2 delims==" %%i in ('findstr "asn=" meta.txt') do ( set asn=%%i @@ -113,7 +112,7 @@ for /f "tokens=2 delims==" %%i in ('findstr "longitude=" meta.txt') do ( for /f "tokens=2 delims==" %%i in ('findstr "latitude=" meta.txt') do ( set latitude=%%i ) -curl --!ips! --resolve service.baipiaocf.ml:443:!resolveip! --retry 3 https://service.baipiaocf.ml -o data.txt -# +curl --!ips! --resolve service.baipiaocf.ml:443:!resolveip! --retry 1 https://service.baipiaocf.ml -o data.txt -# --connect-timeout 2 --max-time 3 if not exist "data.txt" goto start goto checkupdate @@ -130,100 +129,69 @@ set url=%%i ) for /f "tokens=2 delims==" %%i in ('findstr "app=" data.txt') do ( set app=%%i -if !app! NEQ !version! (echo 发现新版本程序: !app!&echo 更新地址: !url!&title 更新后才可以使用&echo 按任意键退出程序&pause>nul&exit) +if !app! NEQ !version! (echo 发现新版本程序: !app!&echo 更新地址: !url!&title 更新后才可以使用&echo 按任意键退出程序&pause > nul&exit) ) -if not exist "RTT.bat" echo 当前程序不完整&echo 请重新下载Release版本: !url! &pause>nul&exit -if not exist "CR2CRLF.exe" echo 当前程序不完整&echo 请重新下载Release版本: !url! &pause>nul&exit -if !selfmode!==0 (goto getip) else (set /a a=0&goto selfconfigip) - -:getip +if not exist "RTT.bat" echo 当前程序不完整&echo 请重新下载Release版本: !url! &pause > nul&exit +if not exist "CR2CRLF.exe" echo 当前程序不完整&echo 请重新下载Release版本: !url! &pause > nul&exit for /f "skip=4" %%i in (data.txt) do ( -echo %%i>>ip.txt +echo %%i >> ip.txt ) goto rtt -:selfconfigip -if !a!==256 (goto rtt) else (echo !selfip!.!a!>>ip.txt&set /a a=a+1&goto selfconfigip) - :rtt -del meta.txt data.txt +del rtt.txt meta.txt data.txt mkdir rtt for /f "tokens=2 delims=:" %%i in ('find /c /v "" ip.txt') do ( set /a ipnum=%%i ) -if !tasknum! GTR !ipnum! set /a iplist=1 -set /a doubletasknum=tasknum*2 -if !ipnum! LSS !doubletasknum! (set /a iplist=2) else (set /a iplist=ipnum/tasknum) -set /a a=1 -set /a b=1 +if !tasknum! EQU 0 set /a tasknum=1 +if !ipnum! LSS !tasknum! set /a tasknum=ipnum +set /a n=1 for /f "delims=" %%i in (ip.txt) do ( -echo %%i>>rtt/!b!.txt -if !a! EQU !iplist! (set /a a=1&set /a b=b+1) else (set /a a=a+1) +echo %%i >> rtt/!n!.txt +if !n! EQU !tasknum! (set /a n=1) else (set /a n=n+1) ) +set /a n=1 del ip.txt -if !a! NEQ 1 set /a a=1&set /a b=b+1 title RTT测试中 goto rtttest :rtttest -if !a! NEQ !b! (start /b rtt.bat !a!>nul&set /a a=a+1&goto rtttest) else (goto rttstatus) +start /b rtt.bat !n! > nul +if !n! EQU !tasknum! (goto rttstatus) else (set /a n=n+1&goto rtttest) :rttstatus -timeout /T 2 /NOBREAK>nul for /f "delims=" %%i in ('dir rtt /o:-s /b^| findstr txt^| find /c /v ""') do ( -set /a taskstatus=%%i -if !taskstatus! NEQ 0 (echo %time:~0,8% 等待RTT测试结束,剩余进程数 !taskstatus!&goto rttstatus) else (echo %time:~0,8% RTT测试完成) -) -for /f "delims=" %%i in ('dir rtt /o:-s /b^| find /c /v ""') do ( set /a status=%%i -if !status! EQU 0 echo 当前所有IP都存在RTT丢包&goto start -) -copy rtt\*.log rtt\ip.txt>nul -sort rtt/ip.txt /O ip.txt -for /f "tokens=2 delims=:" %%i in ('find /c /v "" ip.txt') do ( -if %%i LSS 5 (echo 当前所有IP都存在RTT丢包&goto start) -) -set /a a=0 -for /f "tokens=2,3 delims= " %%i in (ip.txt) do ( -set /a a=a+1 -if !a!==1 echo 第1个IP %%j 往返延迟 %%i 毫秒 -) -set /a a=0 -for /f "tokens=2,3 delims= " %%i in (ip.txt) do ( -set /a a=a+1 -if !a!==2 echo 第2个IP %%j 往返延迟 %%i 毫秒 +if !status! NEQ 0 (echo %time:~0,8% 等待RTT测试结束,剩余进程数 !status!&timeout /T 1 /NOBREAK > nul&goto rttstatus) else (echo %time:~0,8% RTT测试完成) ) -set /a a=0 -for /f "tokens=2,3 delims= " %%i in (ip.txt) do ( -set /a a=a+1 -if !a!==3 echo 第3个IP %%j 往返延迟 %%i 毫秒 +for /f "delims=" %%i in ('dir rtt /o:-s /b^| findstr log^| find /c /v ""') do ( +set /a status=%%i +if !status! NEQ 0 ( +copy rtt\*.log rtt.txt>nul +) else ( +echo 当前所有IP都存在RTT丢包 +goto start ) -set /a a=0 -for /f "tokens=2,3 delims= " %%i in (ip.txt) do ( -set /a a=a+1 -if !a!==4 echo 第4个IP %%j 往返延迟 %%i 毫秒 ) -set /a a=0 -for /f "tokens=2,3 delims= " %%i in (ip.txt) do ( -set /a a=a+1 -if !a!==5 echo 第5个IP %%j 往返延迟 %%i 毫秒 +echo 待测速的IP地址 +for /f "tokens=1,2 delims= " %%i in ('sort rtt.txt') do ( +echo %%j 往返延迟 %%i 毫秒 ) title 启动测速 set /a a=0 -for /f "tokens=2,3 delims= " %%i in (ip.txt) do ( -set /a a=a+1 -if !a! GTR 5 echo 没有满足速度要求的IP&goto start -del CRLF.txt cut.txt speed.txt>nul 2>&1 +for /f "tokens=1,2 delims= " %%i in ('sort rtt.txt') do ( +del CRLF.txt cut.txt speed.txt > nul 2>&1 set avgms=%%i set anycast=%%j echo 正在测试 !anycast! -curl --resolve !domain!:443:!anycast! https://!domain!/!file! -o nul --connect-timeout 5 --max-time 10 > CR.txt 2>&1 +curl --resolve !domain!:443:!anycast! https://!domain!/!file! -o nul --connect-timeout 1 --max-time 10 > CR.txt 2>&1 findstr "0:" CR.txt >> CRLF.txt -CR2CRLF CRLF.txt>nul +CR2CRLF CRLF.txt > nul for /f "delims=" %%i in (CRLF.txt) do ( set s=%%i set s=!s:~73,5! -echo !s%!>>cut.txt +echo !s%! >> cut.txt ) for /f "delims=" %%i in ('findstr /v "k M" cut.txt') do ( set x=%%i @@ -252,10 +220,17 @@ for /f "tokens=1,2" %%i in ('type "speed.txt"') do ( if %%i GEQ !max! set /a max=%%i ) echo !anycast! 峰值速度 !max! kB/s -if !max! GEQ !speed! cls&goto end +if !max! GEQ !speed! goto end ) +goto start :end +echo !anycast!|clip +echo !anycast! > !ips!.txt +echo IP地址,往返延迟 > !ips!.csv +for /f "tokens=1,2 delims= " %%i in ('sort rtt.txt') do ( +echo %%j,%%i ms >> !ips!.csv +) set /a realbandwidth=max/128 set /a stopH=%time:~0,2% if %time:~3,1% EQU 0 (set /a stopM=%time:~4,1%) else (set /a stopM=%time:~3,2%) @@ -263,13 +238,23 @@ if %time:~6,1% EQU 0 (set /a stopS=%time:~7,1%) else (set /a stopS=%time:~6,2%) set /a starttime=%startH%*3600+%startM%*60+%startS% set /a stoptime=%stopH%*3600+%stopM%*60+%stopS% if %starttime% GTR %stoptime% (set /a alltime=86400-%starttime%+%stoptime%) else (set /a alltime=%stoptime%-%starttime%) -curl --!ips! --resolve service.baipiaocf.ml:443:!anycast! --retry 3 -s -X POST https://service.baipiaocf.ml -o data.txt +echo 从服务器获取详细信息 +curl --!ips! --resolve service.baipiaocf.ml:443:!anycast! --retry 1 -s -X POST https://service.baipiaocf.ml -o data.txt --connect-timeout 2 --max-time 3 +cls +if not exist "data.txt" ( +set publicip=获取超时 +set colo=获取超时 +) else ( for /f "tokens=2 delims==" %%i in ('findstr "publicip=" data.txt') do ( set publicip=%%i ) for /f "tokens=2 delims==" %%i in ('findstr "colo=" data.txt') do ( set colo=%%i ) +) +del rtt.txt data.txt ip.txt CR.txt CRLF.txt cut.txt speed.txt meta.txt > nul 2>&1 +RD /S /Q rtt > nul 2>&1 +title 优选IP已经自动复制到剪贴板 echo 优选IP !anycast! echo 公网IP !publicip! echo 自治域 AS!asn! @@ -282,11 +267,10 @@ echo echo 往返延迟 !avgms! 毫秒 echo 数据中心 !colo! echo 总计用时 !alltime! 秒 -echo !anycast!>!ips!.txt -echo !anycast!|clip -del data.txt ip.txt CR.txt CRLF.txt cut.txt speed.txt meta.txt>nul 2>&1 -RD /S /Q rtt>nul 2>&1 -title 优选IP已经自动复制到剪贴板 +echo. +echo 优选IP地址保存到 !ips!.txt +echo 所有IP地址保存到 !ips!.csv +echo. echo 按任意键关闭 -pause>nul +pause > nul goto :eof \ No newline at end of file diff --git "a/batch/CF\344\274\230\351\200\211IP-UTF8.bat" "b/batch/CF\344\274\230\351\200\211IP-UTF8.bat" index 5124edb..36f7e21 100644 --- "a/batch/CF\344\274\230\351\200\211IP-UTF8.bat" +++ "b/batch/CF\344\274\230\351\200\211IP-UTF8.bat" @@ -1,45 +1,44 @@ -chcp 65001>nul +chcp 65001 > nul @echo off cd "%~dp0" -color A setlocal enabledelayedexpansion -set version=20220525 +set version=20220615 -:main cls +:main title CF浼橀塈P -echo 1. IPV4浼橀&echo 2. IPV6浼橀&echo 3. 鑷畾涔塈PV4娈&echo 4. 鍗旾P娴嬮&echo 5. 娓呯┖缂撳瓨&echo 0. 閫鍑&echo. -set /p menu=璇烽夋嫨鑿滃崟: +set /a menu=1 +echo 1. IPV4浼橀&echo 2. IPV6浼橀&echo 3. 鍗旾P娴嬮&echo 4. 娓呯┖缂撳瓨&echo 0. 閫鍑&echo. +set /p menu=璇烽夋嫨鑿滃崟(榛樿%menu%): if %menu%==0 exit -if %menu%==1 title IPV4浼橀&set ips=ipv4&set /a selfmode=0&goto bettercloudflareip -if %menu%==2 title IPV6浼橀&set ips=ipv6&set /a selfmode=0&goto bettercloudflareip -if %menu%==3 title 鑷畾涔塈PV4娈&set ips=ipv4&set /a selfmode=1&set /p selfip=璇疯緭鍏绫昏嚜瀹氫箟IPV4(鏍煎紡 104.16.16):&goto bettercloudflareip -if %menu%==4 title 鍗旾P娴嬮&call :singletest -if %menu%==5 del ipv4.txt ipv6.txt data.txt ip.txt CR.txt CRLF.txt cut.txt speed.txt meta.txt>nul 2>&1&RD /S /Q rtt>nul 2>&1 +if %menu%==1 title IPV4浼橀&set ips=ipv4&goto bettercloudflareip +if %menu%==2 title IPV6浼橀&set ips=ipv6&goto bettercloudflareip +if %menu%==3 title 鍗旾P娴嬮&call :singletest&goto main +if %menu%==4 del ipv4.txt ipv6.txt rtt.txt data.txt ip.txt CR.txt CRLF.txt cut.txt speed.txt meta.txt > nul 2>&1&RD /S /Q rtt > nul 2>&1&cls&echo 缂撳瓨宸茬粡娓呯┖&goto main +cls goto main :singletest +set /a port=443 set /p ip=璇疯緭鍏ラ渶瑕佹祴閫熺殑IP: -curl --resolve service.baipiaocf.ml:443:!ip! https://service.baipiaocf.ml -o temp.txt -# -for /f "tokens=2 delims==" %%i in ('findstr "domain=" temp.txt') do ( -set domain=%%i -) -for /f "delims=" %%i in ('findstr "file=" temp.txt') do ( -set file=%%i -set file=!file:~5! +set /p port=璇疯緭鍏ラ渶瑕佹祴閫熺殑绔彛(榛樿%port%): +echo 姝e湪娴嬮 !ip! 绔彛 !port! +goto download +:download +for /f "tokens=1,2 delims=_" %%i in ('curl --resolve speed.cloudflare.com:!port!:!ip! "https://speed.cloudflare.com:!port!/__down?bytes=300000000" -o nul --connect-timeout 5 --max-time 15 -w %%{http_code}_%%{speed_download}') do ( +set /a status=%%i +set /a speed_download=%%j +if !status! EQU 503 (cls&echo Cloudflare Workers 瓒呭嚭璧勬簮闄愬埗&echo 姝e湪閲嶆柊璇锋眰 Workers 璧勬簮&echo 姝e湪娴嬮 !ip! 绔彛 !port!&goto download) else (set /a speed_download=speed_download/1024&cls&echo !ip! 骞冲潎閫熷害 !speed_download! kB/s) ) -del temp.txt -title 姝e湪娴嬮 !ip! -curl --resolve !domain!:443:!ip! https://!domain!/!file! -o nul --connect-timeout 5 --max-time 15 goto :eof :bettercloudflareip -set /a tasknum=25 +set /a tasknum=10 set /a bandwidth=1 set /p bandwidth=璇疯缃湡鏈涚殑甯﹀澶у皬(榛樿鏈灏%bandwidth%,鍗曚綅 Mbps): set /p tasknum=璇疯缃甊TT娴嬭瘯杩涚▼鏁(榛樿%tasknum%,鏈澶50): if %bandwidth% EQU 0 (set /a bandwidth=1) -if %tasknum% EQU 0 (set /a tasknum=25&echo 杩涚▼鏁颁笉鑳戒负0,鑷姩璁剧疆涓洪粯璁ゅ) +if %tasknum% EQU 0 (set /a tasknum=10&echo 杩涚▼鏁颁笉鑳戒负0,鑷姩璁剧疆涓洪粯璁ゅ) if %tasknum% GTR 50 (set /a tasknum=50&echo 瓒呰繃鏈澶ц繘绋嬮檺鍒,鑷姩璁剧疆涓烘渶澶у) set /a speed=bandwidth*128 set /a startH=%time:~0,2% @@ -49,15 +48,15 @@ call :start exit :start -del data.txt ip.txt CR.txt CRLF.txt cut.txt speed.txt meta.txt>nul 2>&1 -RD /S /Q rtt>nul 2>&1 +del rtt.txt data.txt ip.txt CR.txt CRLF.txt cut.txt speed.txt meta.txt > nul 2>&1 +RD /S /Q rtt > nul 2>&1 if exist "!ips!.txt" goto resolve if not exist "!ips!.txt" goto dnsresolve :dnsresolve echo DNS瑙f瀽鑾峰彇CF !ips! 鑺傜偣 echo 濡傛灉鍩熷悕琚薄鏌,璇锋墜鍔ㄥ垱寤 !ips!.txt 鍋氳В鏋 -curl --!ips! --retry 3 -s https://service.baipiaocf.ml/meta -o meta.txt +curl --!ips! --retry 1 -s https://service.baipiaocf.ml/meta -o meta.txt --connect-timeout 2 --max-time 3 if not exist "meta.txt" goto start for /f "tokens=2 delims==" %%i in ('findstr "asn=" meta.txt') do ( set asn=%%i @@ -80,7 +79,7 @@ for /f "tokens=2 delims==" %%i in ('findstr "longitude=" meta.txt') do ( for /f "tokens=2 delims==" %%i in ('findstr "latitude=" meta.txt') do ( set latitude=%%i ) -curl --!ips! --retry 3 https://service.baipiaocf.ml -o data.txt -# +curl --!ips! --retry 1 https://service.baipiaocf.ml -o data.txt -# --connect-timeout 2 --max-time 3 if not exist "data.txt" goto start goto checkupdate @@ -90,7 +89,7 @@ set resolveip=%%i ) echo 鎸囧悜瑙f瀽鑾峰彇CF !ips! 鑺傜偣 echo 濡傛灉闀挎椂闂存棤娉曡幏鍙朇F !ips! 鑺傜偣,閲嶆柊杩愯绋嬪簭骞堕夋嫨娓呯┖缂撳瓨 -curl --!ips! --resolve service.baipiaocf.ml:443:!resolveip! --retry 3 -s https://service.baipiaocf.ml/meta -o meta.txt +curl --!ips! --resolve service.baipiaocf.ml:443:!resolveip! --retry 1 -s https://service.baipiaocf.ml/meta -o meta.txt --connect-timeout 2 --max-time 3 if not exist "meta.txt" goto start for /f "tokens=2 delims==" %%i in ('findstr "asn=" meta.txt') do ( set asn=%%i @@ -113,7 +112,7 @@ for /f "tokens=2 delims==" %%i in ('findstr "longitude=" meta.txt') do ( for /f "tokens=2 delims==" %%i in ('findstr "latitude=" meta.txt') do ( set latitude=%%i ) -curl --!ips! --resolve service.baipiaocf.ml:443:!resolveip! --retry 3 https://service.baipiaocf.ml -o data.txt -# +curl --!ips! --resolve service.baipiaocf.ml:443:!resolveip! --retry 1 https://service.baipiaocf.ml -o data.txt -# --connect-timeout 2 --max-time 3 if not exist "data.txt" goto start goto checkupdate @@ -130,100 +129,69 @@ set url=%%i ) for /f "tokens=2 delims==" %%i in ('findstr "app=" data.txt') do ( set app=%%i -if !app! NEQ !version! (echo 鍙戠幇鏂扮増鏈▼搴: !app!&echo 鏇存柊鍦板潃: !url!&title 鏇存柊鍚庢墠鍙互浣跨敤&echo 鎸変换鎰忛敭閫鍑虹▼搴&pause>nul&exit) +if !app! NEQ !version! (echo 鍙戠幇鏂扮増鏈▼搴: !app!&echo 鏇存柊鍦板潃: !url!&title 鏇存柊鍚庢墠鍙互浣跨敤&echo 鎸変换鎰忛敭閫鍑虹▼搴&pause > nul&exit) ) -if not exist "RTT.bat" echo 褰撳墠绋嬪簭涓嶅畬鏁&echo 璇烽噸鏂颁笅杞絉elease鐗堟湰: !url! &pause>nul&exit -if not exist "CR2CRLF.exe" echo 褰撳墠绋嬪簭涓嶅畬鏁&echo 璇烽噸鏂颁笅杞絉elease鐗堟湰: !url! &pause>nul&exit -if !selfmode!==0 (goto getip) else (set /a a=0&goto selfconfigip) - -:getip +if not exist "RTT.bat" echo 褰撳墠绋嬪簭涓嶅畬鏁&echo 璇烽噸鏂颁笅杞絉elease鐗堟湰: !url! &pause > nul&exit +if not exist "CR2CRLF.exe" echo 褰撳墠绋嬪簭涓嶅畬鏁&echo 璇烽噸鏂颁笅杞絉elease鐗堟湰: !url! &pause > nul&exit for /f "skip=4" %%i in (data.txt) do ( -echo %%i>>ip.txt +echo %%i >> ip.txt ) goto rtt -:selfconfigip -if !a!==256 (goto rtt) else (echo !selfip!.!a!>>ip.txt&set /a a=a+1&goto selfconfigip) - :rtt -del meta.txt data.txt +del rtt.txt meta.txt data.txt mkdir rtt for /f "tokens=2 delims=:" %%i in ('find /c /v "" ip.txt') do ( set /a ipnum=%%i ) -if !tasknum! GTR !ipnum! set /a iplist=1 -set /a doubletasknum=tasknum*2 -if !ipnum! LSS !doubletasknum! (set /a iplist=2) else (set /a iplist=ipnum/tasknum) -set /a a=1 -set /a b=1 +if !tasknum! EQU 0 set /a tasknum=1 +if !ipnum! LSS !tasknum! set /a tasknum=ipnum +set /a n=1 for /f "delims=" %%i in (ip.txt) do ( -echo %%i>>rtt/!b!.txt -if !a! EQU !iplist! (set /a a=1&set /a b=b+1) else (set /a a=a+1) +echo %%i >> rtt/!n!.txt +if !n! EQU !tasknum! (set /a n=1) else (set /a n=n+1) ) +set /a n=1 del ip.txt -if !a! NEQ 1 set /a a=1&set /a b=b+1 title RTT娴嬭瘯涓 goto rtttest :rtttest -if !a! NEQ !b! (start /b rtt.bat !a!>nul&set /a a=a+1&goto rtttest) else (goto rttstatus) +start /b rtt.bat !n! > nul +if !n! EQU !tasknum! (goto rttstatus) else (set /a n=n+1&goto rtttest) :rttstatus -timeout /T 2 /NOBREAK>nul for /f "delims=" %%i in ('dir rtt /o:-s /b^| findstr txt^| find /c /v ""') do ( -set /a taskstatus=%%i -if !taskstatus! NEQ 0 (echo %time:~0,8% 绛夊緟RTT娴嬭瘯缁撴潫,鍓╀綑杩涚▼鏁 !taskstatus!&goto rttstatus) else (echo %time:~0,8% RTT娴嬭瘯瀹屾垚) -) -for /f "delims=" %%i in ('dir rtt /o:-s /b^| find /c /v ""') do ( set /a status=%%i -if !status! EQU 0 echo 褰撳墠鎵鏈塈P閮藉瓨鍦≧TT涓㈠寘&goto start -) -copy rtt\*.log rtt\ip.txt>nul -sort rtt/ip.txt /O ip.txt -for /f "tokens=2 delims=:" %%i in ('find /c /v "" ip.txt') do ( -if %%i LSS 5 (echo 褰撳墠鎵鏈塈P閮藉瓨鍦≧TT涓㈠寘&goto start) -) -set /a a=0 -for /f "tokens=2,3 delims= " %%i in (ip.txt) do ( -set /a a=a+1 -if !a!==1 echo 绗1涓狪P %%j 寰杩斿欢杩 %%i 姣 -) -set /a a=0 -for /f "tokens=2,3 delims= " %%i in (ip.txt) do ( -set /a a=a+1 -if !a!==2 echo 绗2涓狪P %%j 寰杩斿欢杩 %%i 姣 +if !status! NEQ 0 (echo %time:~0,8% 绛夊緟RTT娴嬭瘯缁撴潫,鍓╀綑杩涚▼鏁 !status!&timeout /T 1 /NOBREAK > nul&goto rttstatus) else (echo %time:~0,8% RTT娴嬭瘯瀹屾垚) ) -set /a a=0 -for /f "tokens=2,3 delims= " %%i in (ip.txt) do ( -set /a a=a+1 -if !a!==3 echo 绗3涓狪P %%j 寰杩斿欢杩 %%i 姣 +for /f "delims=" %%i in ('dir rtt /o:-s /b^| findstr log^| find /c /v ""') do ( +set /a status=%%i +if !status! NEQ 0 ( +copy rtt\*.log rtt.txt>nul +) else ( +echo 褰撳墠鎵鏈塈P閮藉瓨鍦≧TT涓㈠寘 +goto start ) -set /a a=0 -for /f "tokens=2,3 delims= " %%i in (ip.txt) do ( -set /a a=a+1 -if !a!==4 echo 绗4涓狪P %%j 寰杩斿欢杩 %%i 姣 ) -set /a a=0 -for /f "tokens=2,3 delims= " %%i in (ip.txt) do ( -set /a a=a+1 -if !a!==5 echo 绗5涓狪P %%j 寰杩斿欢杩 %%i 姣 +echo 寰呮祴閫熺殑IP鍦板潃 +for /f "tokens=1,2 delims= " %%i in ('sort rtt.txt') do ( +echo %%j 寰杩斿欢杩 %%i 姣 ) title 鍚姩娴嬮 set /a a=0 -for /f "tokens=2,3 delims= " %%i in (ip.txt) do ( -set /a a=a+1 -if !a! GTR 5 echo 娌℃湁婊¤冻閫熷害瑕佹眰鐨処P&goto start -del CRLF.txt cut.txt speed.txt>nul 2>&1 +for /f "tokens=1,2 delims= " %%i in ('sort rtt.txt') do ( +del CRLF.txt cut.txt speed.txt > nul 2>&1 set avgms=%%i set anycast=%%j echo 姝e湪娴嬭瘯 !anycast! -curl --resolve !domain!:443:!anycast! https://!domain!/!file! -o nul --connect-timeout 5 --max-time 10 > CR.txt 2>&1 +curl --resolve !domain!:443:!anycast! https://!domain!/!file! -o nul --connect-timeout 1 --max-time 10 > CR.txt 2>&1 findstr "0:" CR.txt >> CRLF.txt -CR2CRLF CRLF.txt>nul +CR2CRLF CRLF.txt > nul for /f "delims=" %%i in (CRLF.txt) do ( set s=%%i set s=!s:~73,5! -echo !s%!>>cut.txt +echo !s%! >> cut.txt ) for /f "delims=" %%i in ('findstr /v "k M" cut.txt') do ( set x=%%i @@ -252,10 +220,17 @@ for /f "tokens=1,2" %%i in ('type "speed.txt"') do ( if %%i GEQ !max! set /a max=%%i ) echo !anycast! 宄板奸熷害 !max! kB/s -if !max! GEQ !speed! cls&goto end +if !max! GEQ !speed! goto end ) +goto start :end +echo !anycast!|clip +echo !anycast! > !ips!.txt +echo IP鍦板潃,寰杩斿欢杩 > !ips!.csv +for /f "tokens=1,2 delims= " %%i in ('sort rtt.txt') do ( +echo %%j,%%i ms >> !ips!.csv +) set /a realbandwidth=max/128 set /a stopH=%time:~0,2% if %time:~3,1% EQU 0 (set /a stopM=%time:~4,1%) else (set /a stopM=%time:~3,2%) @@ -263,13 +238,23 @@ if %time:~6,1% EQU 0 (set /a stopS=%time:~7,1%) else (set /a stopS=%time:~6,2%) set /a starttime=%startH%*3600+%startM%*60+%startS% set /a stoptime=%stopH%*3600+%stopM%*60+%stopS% if %starttime% GTR %stoptime% (set /a alltime=86400-%starttime%+%stoptime%) else (set /a alltime=%stoptime%-%starttime%) -curl --!ips! --resolve service.baipiaocf.ml:443:!anycast! --retry 3 -s -X POST https://service.baipiaocf.ml -o data.txt +echo 浠庢湇鍔″櫒鑾峰彇璇︾粏淇℃伅 +curl --!ips! --resolve service.baipiaocf.ml:443:!anycast! --retry 1 -s -X POST https://service.baipiaocf.ml -o data.txt --connect-timeout 2 --max-time 3 +cls +if not exist "data.txt" ( +set publicip=鑾峰彇瓒呮椂 +set colo=鑾峰彇瓒呮椂 +) else ( for /f "tokens=2 delims==" %%i in ('findstr "publicip=" data.txt') do ( set publicip=%%i ) for /f "tokens=2 delims==" %%i in ('findstr "colo=" data.txt') do ( set colo=%%i ) +) +del rtt.txt data.txt ip.txt CR.txt CRLF.txt cut.txt speed.txt meta.txt > nul 2>&1 +RD /S /Q rtt > nul 2>&1 +title 浼橀塈P宸茬粡鑷姩澶嶅埗鍒板壀璐存澘 echo 浼橀塈P !anycast! echo 鍏綉IP !publicip! echo 鑷不鍩 AS!asn! @@ -282,11 +267,10 @@ echo 宄板奸熷害 !max! kB/s echo 寰杩斿欢杩 !avgms! 姣 echo 鏁版嵁涓績 !colo! echo 鎬昏鐢ㄦ椂 !alltime! 绉 -echo !anycast!>!ips!.txt -echo !anycast!|clip -del data.txt ip.txt CR.txt CRLF.txt cut.txt speed.txt meta.txt>nul 2>&1 -RD /S /Q rtt>nul 2>&1 -title 浼橀塈P宸茬粡鑷姩澶嶅埗鍒板壀璐存澘 +echo. +echo 浼橀塈P鍦板潃淇濆瓨鍒 !ips!.txt +echo 鎵鏈塈P鍦板潃淇濆瓨鍒 !ips!.csv +echo. echo 鎸変换鎰忛敭鍏抽棴 -pause>nul +pause > nul goto :eof \ No newline at end of file diff --git a/batch/RTT.bat b/batch/RTT.bat index e99ec90..95cef6b 100644 --- a/batch/RTT.bat +++ b/batch/RTT.bat @@ -1,61 +1,49 @@ @echo off setlocal enabledelayedexpansion cd "%~dp0" -goto cloudflare -:rtt -if !a! LEQ 5 ( -curl --resolve www.cloudflare.com:443:%1 https://www.cloudflare.com/cdn-cgi/trace -o nul -s --connect-timeout 1 --max-time 3 -w "%1"_%%{time_connect}_"HTTP"%%{http_code}"\n">>rtt/!c!-!b!.log -set /a a=a+1 -goto rtt -) else ( -call :getrtt -set /a a=1 -set /a b=b+1 -) -goto :eof - -:getrtt -for /f "delims=" %%i in ('findstr "HTTP200" rtt\!c!-!b!.log^| find /c /v ""') do ( -set /a getrtt=%%i -if !getrtt! NEQ 0 ( -call :getms -) else ( -del rtt\!c!-!b!.log -) +set /a m=%1 +set /a n=1 +set /a avgms=0 +for /f "delims=" %%i in (rtt/!m!.txt) do ( +call :rtt %%i ) -goto :eof +del rtt\!m!.txt +exit -:getms -set /a avgms=0 -for /f "tokens=1,2 delims=_" %%i in ('findstr "HTTP200" rtt\!c!-!b!.log') do ( -set ip=%%i -set ms=%%j +:rtt +if !n! LEQ 3 ( +for /f "tokens=1,2 delims=_" %%i in ('curl --resolve www.cloudflare.com:443:%1 https://www.cloudflare.com/cdn-cgi/trace -o nul -s --connect-timeout 1 --max-time 3 -w %%{time_connect}_%%{http_code}') do ( +set ms=%%i set ms=!ms:0.00=! set ms=!ms:0.0=! set ms=!ms:0.=! +set ms=!ms:1.=1! +set ms=!ms:2.=2! +set ms=!ms:3.=3! +set ms=!ms:4.=4! +set ms=!ms:5.=5! +set ms=!ms:6.=6! +set ms=!ms:7.=7! +set ms=!ms:8.=8! +set ms=!ms:9.=9! set /a ms=!ms! set /a ms=ms/1000 set /a avgms=avgms+ms +set /a rsp=%%j ) -set /a avgms=avgms/getrtt -set /a getrtt=5-getrtt +if !rsp! EQU 200 (set /a n=n+1&goto rtt) else (set /a avgms=0&set /a n=1) +) else ( +set /a avgms=avgms/3 if !avgms! LSS 10 ( -echo !getrtt! 00!avgms! !ip!>rtt/!c!-!b!.log +echo 00!avgms! %1 >> rtt/!m!.log ) else ( if !avgms! LSS 100 ( -echo !getrtt! 0!avgms! !ip!>rtt/!c!-!b!.log +echo 0!avgms! %1 >> rtt/!m!.log ) else ( -echo !getrtt! !avgms! !ip!>rtt/!c!-!b!.log +echo !avgms! %1 >> rtt/!m!.log ) ) -goto :eof - -:cloudflare -set /a a=1 -set /a b=1 -set /a c=%1 -for /f "delims=" %%i in (rtt/!c!.txt) do ( -call :rtt %%i +set /a n=1 +set /a avgms=0 ) -del rtt\!c!.txt -exit +goto :eof diff --git a/shell/cf.sh b/shell/cf.sh index f974df4..a7fd351 100644 --- a/shell/cf.sh +++ b/shell/cf.sh @@ -1,98 +1,98 @@ #!/bin/bash # better-cloudflare-ip -version=20220525 +version=20220615 -function bettercloudflareip (){ -declare -i bandwidth -declare -i speed +function bettercloudflareip(){ read -p "璇疯缃湡鏈涚殑甯﹀澶у皬(榛樿鏈灏1,鍗曚綅 Mbps):" bandwidth -read -p "璇疯缃甊TT娴嬭瘯杩涚▼鏁(榛樿25,鏈澶50):" tasknum +read -p "璇疯缃甊TT娴嬭瘯杩涚▼鏁(榛樿10,鏈澶50):" tasknum +if [ -z "$bandwidth" ] +then + bandwidth=1 +fi if [ $bandwidth -eq 0 ] then bandwidth=1 fi if [ -z "$tasknum" ] then - tasknum=25 + tasknum=10 fi if [ $tasknum -eq 0 ] then - echo 杩涚▼鏁颁笉鑳戒负0,鑷姩璁剧疆涓洪粯璁ゅ - tasknum=25 + echo "杩涚▼鏁颁笉鑳戒负0,鑷姩璁剧疆涓洪粯璁ゅ" + tasknum=10 fi if [ $tasknum -gt 50 ] then - echo 瓒呰繃鏈澶ц繘绋嬮檺鍒,鑷姩璁剧疆涓烘渶澶у + echo "瓒呰繃鏈澶ц繘绋嬮檺鍒,鑷姩璁剧疆涓烘渶澶у" tasknum=50 fi -speed=bandwidth*128*1024 -starttime=$(date +'%Y-%m-%d %H:%M:%S') +speed=$[$bandwidth*128*1024] +starttime=$(date +%s) cloudflaretest -declare -i realbandwidth -realbandwidth=max/128 -endtime=$(date +'%Y-%m-%d %H:%M:%S') -start_seconds=$(date --date="$starttime" +%s) -end_seconds=$(date --date="$endtime" +%s) +realbandwidth=$[$max/128] +endtime=$(date +%s) +echo "浠庢湇鍔″櫒鑾峰彇璇︾粏淇℃伅" +curl --$ips --resolve service.baipiaocf.ml:443:$anycast --retry 1 -s -X POST https://service.baipiaocf.ml -o temp.txt --connect-timeout 2 --max-time 3 clear -curl --$ips --resolve service.baipiaocf.ml:443:$anycast --retry 3 -s -X POST https://service.baipiaocf.ml -o temp.txt -publicip=$(grep publicip= temp.txt | cut -f 2- -d'=') -colo=$(grep colo= temp.txt | cut -f 2- -d'=') -rm -rf temp.txt -echo $anycast>$ips.txt -echo 浼橀塈P $anycast -echo 鍏綉IP $publicip -echo 鑷不鍩 AS$asn -echo 杩愯惀鍟 $isp -echo 缁忕含搴 $longitude,$latitude -echo 浣嶇疆淇℃伅 $city,$region,$country -echo 璁剧疆甯﹀ $bandwidth Mbps -echo 瀹炴祴甯﹀ $realbandwidth Mbps -echo 宄板奸熷害 $max kB/s -echo 寰杩斿欢杩 $avgms 姣 -echo 鏁版嵁涓績 $colo -echo 鎬昏鐢ㄦ椂 $((end_seconds-start_seconds)) 绉 +if [ ! -f "temp.txt" ] +then + publicip=鑾峰彇瓒呮椂 + colo=鑾峰彇瓒呮椂 +else + publicip=$(grep publicip= temp.txt | cut -f 2- -d'=') + colo=$(grep colo= temp.txt | cut -f 2- -d'=') + rm -rf temp.txt + echo $anycast>$ips.txt +fi +echo "浼橀塈P $anycast" +echo "鍏綉IP $publicip" +echo "鑷不鍩 AS$asn" +echo "杩愯惀鍟 $isp" +echo "缁忕含搴 $longitude,$latitude" +echo "浣嶇疆淇℃伅 $city,$region,$country" +echo "璁剧疆甯﹀ $bandwidth Mbps" +echo "瀹炴祴甯﹀ $realbandwidth Mbps" +echo "宄板奸熷害 $max kB/s" +echo "寰杩斿欢杩 $avgms 姣" +echo "鏁版嵁涓績 $colo" +echo "鎬昏鐢ㄦ椂 $[$endtime-$starttime] 绉" +echo "浼橀塈P鍦板潃淇濆瓨鍒 $ips.txt" +echo "鎵鏈塈P鍦板潃淇濆瓨鍒 $ips.csv" } -function rtt (){ -declare -i avgms -declare -i getrtt -t=1 +function rtt(){ +avgms=0 n=1 for ip in `cat rtt/$1.txt` do while true do - if [ $t -le 5 ] + if [ $n -le 3 ] then - curl --resolve www.cloudflare.com:443:$ip https://www.cloudflare.com/cdn-cgi/trace -o /dev/null -s --connect-timeout 1 --max-time 3 -w "$ip"_%{time_connect}_"HTTP"%{http_code}"\n">>rtt/$1-$n.log - t=$[$t+1] - else - getrtt=$(grep HTTP200 rtt/$1-$n.log | wc -l) - if [ $getrtt == 0 ] + rsp=$(curl --resolve www.cloudflare.com:443:$ip https://www.cloudflare.com/cdn-cgi/trace -o /dev/null -s --connect-timeout 1 --max-time 3 -w %{time_connect}_%{http_code}) + if [ $(echo $rsp | awk -F_ '{print $2}') != 200 ] then - rm -rf rtt/$1-$n.log - n=$[$n+1] - t=1 + avgms=0 + n=1 break + else + avgms=$[$(echo $rsp | awk -F_ '{printf ("%d\n",$1*1000000)}')+$avgms] + n=$[$n+1] fi - avgms=0 - for i in `grep HTTP200 rtt/$1-$n.log | awk -F_ '{printf ("%d\n",$2*1000000)}'` - do - avgms=$i+avgms - done - avgms=(avgms/getrtt)/1000 - getrtt=5-getrtt + else + avgms=$[$avgms/3000] if [ $avgms -lt 10 ] then - echo $getrtt 00$avgms $ip>rtt/$1-$n.log + echo 00$avgms $ip >> rtt/$1.log elif [ $avgms -ge 10 ] && [ $avgms -lt 100 ] then - echo $getrtt 0$avgms $ip>rtt/$1-$n.log + echo 0$avgms $ip >> rtt/$1.log else - echo $getrtt $avgms $ip>rtt/$1-$n.log + echo $avgms $ip >> rtt/$1.log fi - n=$[$n+1] - t=1 + avgms=0 + n=1 break fi done @@ -100,25 +100,23 @@ done rm -rf rtt/$1.txt } -function speedtest (){ -curl --resolve $domain:443:$1 https://$domain/$file -o /dev/null --connect-timeout 5 --max-time 10 > log.txt 2>&1 +function speedtest(){ +rm -rf log.txt speed.txt +curl --resolve $domain:443:$1 https://$domain/$file -o /dev/null --connect-timeout 1 --max-time 10 > log.txt 2>&1 cat log.txt | tr '\r' '\n' | awk '{print $NF}' | sed '1,3d;$d' | grep -v 'k\|M' >> speed.txt for i in `cat log.txt | tr '\r' '\n' | awk '{print $NF}' | sed '1,3d;$d' | grep k | sed 's/k//g'` do - declare -i k k=$i - k=k*1024 + k=$[$k*1024] echo $k >> speed.txt done for i in `cat log.txt | tr '\r' '\n' | awk '{print $NF}' | sed '1,3d;$d' | grep M | sed 's/M//g'` do i=$(echo | awk '{print '$i'*10 }') - declare -i M M=$i - M=M*1024*1024/10 + M=$[$M*1024*1024/10] echo $M >> speed.txt done -declare -i max max=0 for i in `cat speed.txt` do @@ -131,27 +129,24 @@ rm -rf log.txt speed.txt echo $max } -function cloudflaretest (){ +function cloudflaretest(){ while true do while true do - declare -i ipnum - declare -i iplist - declare -i n - rm -rf rtt data.txt meta.txt log.txt anycast.txt temp.txt speed.txt + rm -rf rtt rtt.txt data.txt meta.txt log.txt anycast.txt temp.txt speed.txt mkdir rtt while true do if [ ! -f "$ips.txt" ] then - echo DNS瑙f瀽鑾峰彇CF $ips 鑺傜偣 - echo 濡傛灉鍩熷悕琚薄鏌,璇锋墜鍔ㄥ垱寤 $ips.txt 鍋氳В鏋 + echo "DNS瑙f瀽鑾峰彇CF $ips 鑺傜偣" + echo "濡傛灉鍩熷悕琚薄鏌,璇锋墜鍔ㄥ垱寤 $ips.txt 鍋氳В鏋" while true do if [ ! -f "meta.txt" ] then - curl --$ips --retry 3 -s https://service.baipiaocf.ml/meta -o meta.txt + curl --$ips --retry 1 -s https://service.baipiaocf.ml/meta -o meta.txt --connect-timeout 2 --max-time 3 else asn=$(grep asn= meta.txt | cut -f 2- -d'=') isp=$(grep isp= meta.txt | cut -f 2- -d'=') @@ -160,19 +155,19 @@ do city=$(grep city= meta.txt | cut -f 2- -d'=') longitude=$(grep longitude= meta.txt | cut -f 2- -d'=') latitude=$(grep latitude= meta.txt | cut -f 2- -d'=') - curl --$ips --retry 3 https://service.baipiaocf.ml -o data.txt -# + curl --$ips --retry 1 https://service.baipiaocf.ml -o data.txt -# --connect-timeout 2 --max-time 3 break fi done else - echo 鎸囧悜瑙f瀽鑾峰彇CF $ips 鑺傜偣 - echo 濡傛灉闀挎椂闂存棤娉曡幏鍙朇F $ips 鑺傜偣,閲嶆柊杩愯绋嬪簭骞堕夋嫨娓呯┖缂撳瓨 + echo "鎸囧悜瑙f瀽鑾峰彇CF $ips 鑺傜偣" + echo "濡傛灉闀挎椂闂存棤娉曡幏鍙朇F $ips 鑺傜偣,閲嶆柊杩愯绋嬪簭骞堕夋嫨娓呯┖缂撳瓨" resolveip=$(cat $ips.txt) while true do if [ ! -f "meta.txt" ] then - curl --$ips --resolve service.baipiaocf.ml:443:$resolveip --retry 3 -s https://service.baipiaocf.ml/meta -o meta.txt + curl --$ips --resolve service.baipiaocf.ml:443:$resolveip --retry 1 -s https://service.baipiaocf.ml/meta -o meta.txt --connect-timeout 2 --max-time 3 else asn=$(grep asn= meta.txt | cut -f 2- -d'=') isp=$(grep isp= meta.txt | cut -f 2- -d'=') @@ -181,7 +176,7 @@ do city=$(grep city= meta.txt | cut -f 2- -d'=') longitude=$(grep longitude= meta.txt | cut -f 2- -d'=') latitude=$(grep latitude= meta.txt | cut -f 2- -d'=') - curl --$ips --resolve service.baipiaocf.ml:443:$resolveip --retry 3 https://service.baipiaocf.ml -o data.txt -# + curl --$ips --resolve service.baipiaocf.ml:443:$resolveip --retry 1 https://service.baipiaocf.ml -o data.txt -# --connect-timeout 2 --max-time 3 break fi done @@ -197,31 +192,15 @@ do app=$(grep app= data.txt | cut -f 2- -d'=') if [ "$app" != "$version" ] then - echo 鍙戠幇鏂扮増鏈▼搴: $app - echo 鏇存柊鍦板潃: $url - echo 鏇存柊鍚庢墠鍙互浣跨敤 + echo "鍙戠幇鏂扮増鏈▼搴: $app" + echo "鏇存柊鍦板潃: $url" + echo "鏇存柊鍚庢墠鍙互浣跨敤" exit fi - if [ $selfmode == 1 ] - then - rm -rf data.txt - n=0 - while true - do - if [ $n == 256 ] - then - break - else - echo $selfip.$n>>anycast.txt - n=n+1 - fi - done - else - for i in `cat data.txt | sed '1,4d'` - do - echo $i>>anycast.txt - done - fi + for i in `cat data.txt | sed '1,4d'` + do + echo $i>>anycast.txt + done rm -rf meta.txt data.txt ipnum=$(cat anycast.txt | wc -l) if [ $tasknum == 0 ] @@ -230,162 +209,153 @@ do fi if [ $ipnum -lt $tasknum ] then - iplist=1 - fi - doubletasknum=$[$tasknum*2] - if [ $ipnum -lt $doubletasknum ] - then - iplist=2 - else - iplist=ipnum/tasknum + tasknum=$ipnum fi - declare -i a=1 - declare -i b=1 + n=1 for i in `cat anycast.txt` do - echo $i>>rtt/$b.txt - if [ $a == $iplist ] + echo $i>>rtt/$n.txt + if [ $n == $tasknum ] then - a=1 - b=b+1 + n=1 else - a=a+1 + n=$[$n+1] fi done rm -rf anycast.txt - if [ $a != 1 ] - then - a=1 - b=b+1 - fi + n=1 while true do - if [ $a == $b ] + rtt $n & + if [ $n == $tasknum ] then break else - rtt $a & + n=$[$n+1] fi - a=a+1 done while true do - sleep 2 n=$(ls rtt | grep txt | wc -l) if [ $n -ne 0 ] then - echo $(date +'%H:%M:%S') 绛夊緟RTT娴嬭瘯缁撴潫,鍓╀綑杩涚▼鏁 $n + echo "$(date +'%H:%M:%S') 绛夊緟RTT娴嬭瘯缁撴潫,鍓╀綑杩涚▼鏁 $n" else - echo $(date +'%H:%M:%S') RTT娴嬭瘯瀹屾垚 + echo "$(date +'%H:%M:%S') RTT娴嬭瘯瀹屾垚" break fi + sleep 1 done - n=$(ls rtt | wc -l) - if [ $n -ge 5 ] + n=$(ls rtt | grep log | wc -l) + if [ $n == 0 ] then - cat rtt/*.log | sort | awk '{print $2"_"$3}'>ip.txt - echo 寰呮祴閫熺殑IP鍦板潃 - echo $(sed -n '1p' ip.txt | awk -F_ '{print "绗1涓狪P "$2" 寰杩斿欢杩 "$1" 姣"}') - echo $(sed -n '2p' ip.txt | awk -F_ '{print "绗2涓狪P "$2" 寰杩斿欢杩 "$1" 姣"}') - echo $(sed -n '3p' ip.txt | awk -F_ '{print "绗3涓狪P "$2" 寰杩斿欢杩 "$1" 姣"}') - echo $(sed -n '4p' ip.txt | awk -F_ '{print "绗4涓狪P "$2" 寰杩斿欢杩 "$1" 姣"}') - echo $(sed -n '5p' ip.txt | awk -F_ '{print "绗5涓狪P "$2" 寰杩斿欢杩 "$1" 姣"}') - n=0 - for ip in `cat ip.txt` + echo "褰撳墠鎵鏈塈P閮藉瓨鍦≧TT涓㈠寘" + else + cat rtt/*.log > rtt.txt + status=0 + echo "寰呮祴閫熺殑IP鍦板潃" + cat rtt.txt | sort | awk '{print $2" 寰杩斿欢杩 "$1" 姣"}' + for i in `cat rtt.txt | sort | awk '{print $1"_"$2}'` do - if [ $n == 5 ] - then - echo 娌℃湁婊¤冻閫熷害瑕佹眰鐨処P - break - else - n=n+1 - fi - avgms=$(echo $ip | awk -F_ '{print $1}') - ip=$(echo $ip | awk -F_ '{print $2}') - echo 姝e湪娴嬭瘯 $ip + avgms=$(echo $i | awk -F_ '{print $1}') + ip=$(echo $i | awk -F_ '{print $2}') + echo "姝e湪娴嬭瘯 $ip" max=$(speedtest $ip) if [ $max -ge $speed ] then + status=1 anycast=$ip max=$[$max/1024] - echo $ip 宄板奸熷害 $max kB/s + echo "$ip 宄板奸熷害 $max kB/s" + echo "IP鍦板潃,寰杩斿欢杩" > $ips.csv + cat rtt.txt | sort | awk '{print $2","$1" ms"}' >> $ips.csv + rm -rf rtt rtt.txt break else max=$[$max/1024] - echo $ip 宄板奸熷害 $max kB/s + echo "$ip 宄板奸熷害 $max kB/s" fi done - rm -rf rtt ip.txt - if [ $n != 5 ] + if [ $status == 1 ] then break fi - else - echo 褰撳墠鎵鏈塈P閮藉瓨鍦≧TT涓㈠寘 fi done break done } -function singletest (){ -read -p "璇疯緭鍏ラ渶瑕佹祴閫熺殑IP: " testip -curl --resolve service.baipiaocf.ml:443:$testip https://service.baipiaocf.ml -o temp.txt -# -domain=$(grep domain= temp.txt | cut -f 2- -d'=') -file=$(grep file= temp.txt | cut -f 2- -d'=') -rm -rf temp.txt -curl --resolve $domain:443:$testip https://$domain/$file -o /dev/null --connect-timeout 5 --max-time 15 +function singletest(){ +read -p "璇疯緭鍏ラ渶瑕佹祴閫熺殑IP: " ip +read -p "璇疯緭鍏ラ渶瑕佹祴閫熺殑绔彛(榛樿443): " port +if [ -z "$ip" ] +then + echo "鏈緭鍏P" +fi +if [ -z "$port" ] +then + port=443 +fi +echo "姝e湪娴嬮 $ip 绔彛 $port" +while true +do + workers=$(curl --resolve speed.cloudflare.com:$port:$ip https://speed.cloudflare.com:$port/__down?bytes=300000000 -o /dev/null --connect-timeout 5 --max-time 15 -w %{http_code}_%{speed_download}) + status=$(echo $workers | awk -F_ '{print $1}') + speed_download=$[$(echo $workers | awk -F_ '{printf ("%d\n",$2*1000)}')/1024000] + if [ $status == 503 ] + then + clear + echo "Cloudflare Workers 瓒呭嚭璧勬簮闄愬埗" + echo "姝e湪閲嶆柊璇锋眰 Workers 璧勬簮" + echo "姝e湪娴嬮 $ip 绔彛 $port" + else + break + fi +done } - +clear while true do - clear - echo 1. IPV4浼橀 - echo 2. IPV6浼橀 - echo 3. 鑷畾涔塈PV4娈 - echo 4. 鍗旾P娴嬮 - echo 5. 娓呯┖缂撳瓨 - echo 0. 閫鍑 - read -p "璇烽夋嫨鑿滃崟: " menu + echo "1. IPV4浼橀" + echo "2. IPV6浼橀" + echo "3. 鍗旾P娴嬮" + echo "4. 娓呯┖缂撳瓨" + echo "0. 閫鍑" + read -p "璇烽夋嫨鑿滃崟(榛樿1): " menu + if [ -z "$menu" ] + then + menu=1 + fi if [ $menu == 0 ] then clear - echo 閫鍑烘垚鍔 + echo "閫鍑烘垚鍔" break fi if [ $menu == 1 ] then ips=ipv4 - selfmode=0 bettercloudflareip break fi if [ $menu == 2 ] then ips=ipv6 - selfmode=0 bettercloudflareip break fi if [ $menu == 3 ] - then - ips=ipv4 - selfmode=1 - read -p "璇疯緭鍏绫昏嚜瀹氫箟IPV4(鏍煎紡 104.16.16):" selfip - bettercloudflareip - break - fi - if [ $menu == 4 ] then singletest clear - echo 娴嬮熷畬姣 + echo "$ip 骞冲潎閫熷害 $speed_download kB/s" fi - if [ $menu == 5 ] + if [ $menu == 4 ] then - rm -rf ipv4.txt ipv6.txt rtt data.txt meta.txt log.txt anycast.txt temp.txt speed.txt + rm -rf ipv4.txt ipv6.txt rtt rtt.txt data.txt meta.txt log.txt anycast.txt temp.txt speed.txt clear - echo 缂撳瓨宸茬粡娓呯┖ + echo "缂撳瓨宸茬粡娓呯┖" fi done