批处理

批处理

@echo off
setlocal enabledelayedexpansion
::color f0
mode con cols=40 lines=25
cd "%cd%"

echo.
echo 正在停止 stunnel
echo.

tasklist /nh|find /i "stunnel.exe"
if ERRORLEVEL 1 (goto :stop)
:stop
taskkill /f /im stunnel.exe
echo.
echo stunnel 已停止
echo.


title 正在更新服务器
rem Create server list
echo.
echo 正在更新服务器,请稍候...
echo.

curl --silent --url http://stunnel.yourshell.info/ --output ServerList.txt
echo.
echo 正在查找最快的服务器,请稍候...
echo.

echo.>ServerIP.txt

(for /f "usebackq tokens=1-2" %%a in (ServerList.txt) do (
  call :GetIP %%a
))>>PingIP.txt

rem Get response time
for /f "usebackq tokens=1-3" %%a in (PingIP.txt) do (
  set /p=Checking on %%a %%b %%c<nul
  for /f "skip=11 tokens=10 delims=m= " %%h in ('ping %%a') do (
    echo %%a %%hms>>ServerIP.txt
    set strTime=0000%%h
    set strTime=!strTime:~-5!
    set _arrayTime_!strTime!=%%a_%%b_%%c
  )
)

rem Find best server
for /f "tokens=2-5 delims=_=" %%a in ('set _arrayTime') do (
  set BestServer=%%c
  set BestIP=%%b
  set BestType=%%d
  set BestTime=1%%a
  set /a BestTime%%=100000
  goto :End
)

:GetIP
for /f "skip=2 tokens=3,8 delims=:= " %%h in ('ping -n 1 -l 1 %1') do (
  if "%%i" equ "TTL" (
    echo %%h %1 %2
  )
)

goto :eof

:End

echo.
echo.
echo 最快服务器:%BestServer% %BestTime%ms %BestType%
echo.

echo client = yes>stunnel.conf
echo.>>stunnel.conf
echo [SSL Proxy]>>stunnel.conf
echo accept = 127.0.0.1:8081>>stunnel.conf
echo connect = %BestIP%:443>>stunnel.conf

del /Q ServerList.txt
del /Q PingIP.txt

echo 启动 stunnel
start /min stunnel

goto :eof

 


转载于:https://www.cnblogs.com/yisuo/p/6784079.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值