mirror of
https://github.com/mahdibland/V2RayAggregator.git
synced 2026-06-24 21:34:12 +08:00
Add cn proxy&profile for GitHub Action speedtest
This commit is contained in:
parent
7288d28c00
commit
e47a5fa3c1
@ -1,106 +0,0 @@
|
||||
import socket
|
||||
import time
|
||||
|
||||
|
||||
class ping:
|
||||
def __init__(self, host, port=443):
|
||||
self.host = host
|
||||
self.port = port
|
||||
|
||||
def tcp_ping(self):
|
||||
|
||||
alt=0 # 平均值
|
||||
suc=0 # 丢包率
|
||||
fac=0 # 超时时间
|
||||
_list = []
|
||||
while True:
|
||||
if fac >= 3 or (suc != 0 and fac + suc >= 10):
|
||||
break
|
||||
try:
|
||||
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
st=time.time()
|
||||
s.settimeout(3)
|
||||
s.connect((self.host,self.port))
|
||||
s.close()
|
||||
deltaTime = time.time()-st
|
||||
alt += deltaTime
|
||||
suc += 1
|
||||
_list.append(deltaTime)
|
||||
except (socket.timeout):
|
||||
fac+=1
|
||||
_list.append(0)
|
||||
# print("TCP Ping Timeout %d times." % fac)
|
||||
except Exception:
|
||||
_list.append(0)
|
||||
fac+=1
|
||||
if suc==0:
|
||||
return (0,0,_list)
|
||||
return (alt/suc,suc/(suc+fac),_list)
|
||||
|
||||
def google_ping(self):
|
||||
alt=0
|
||||
suc=0
|
||||
fac=0
|
||||
_list = []
|
||||
while True:
|
||||
if fac >= 3 or (suc != 0 and fac + suc >= 10):
|
||||
break
|
||||
try:
|
||||
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(3)
|
||||
s.connect((self.host,self.port))
|
||||
st=time.time()
|
||||
s.send(b"\x05\x01\x00")
|
||||
s.recv(2)
|
||||
s.send(b"\x05\x01\x00\x03\x0agoogle.com\x00\x50")
|
||||
s.recv(10)
|
||||
s.send(b"GET / HTTP/1.1\r\nHost: google.com\r\nUser-Agent: curl/11.45.14\r\n\r\n")
|
||||
s.recv(1)
|
||||
s.close()
|
||||
deltaTime = time.time()-st
|
||||
alt += deltaTime
|
||||
suc += 1
|
||||
_list.append(deltaTime)
|
||||
except (socket.timeout):
|
||||
fac += 1
|
||||
_list.append(0)
|
||||
except Exception:
|
||||
_list.append(0)
|
||||
fac += 1
|
||||
if (suc == 0):
|
||||
return (0,0,_list)
|
||||
return (alt/suc,suc/(suc+fac),_list)
|
||||
|
||||
def youtube_ping(self):
|
||||
alt=0
|
||||
suc=0
|
||||
fac=0
|
||||
_list = []
|
||||
while True:
|
||||
if fac >= 3 or (suc != 0 and fac + suc >= 10):
|
||||
break
|
||||
try:
|
||||
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(3)
|
||||
s.connect((self.host,self.port))
|
||||
st=time.time()
|
||||
s.send(b"\x05\x01\x00")
|
||||
s.recv(2)
|
||||
s.send(b"\x05\x01\x00\x03\x0ayoutube.com\x00\x50")
|
||||
s.recv(10)
|
||||
s.send(b"GET / HTTP/1.1\r\nHost: youtube.com\r\nUser-Agent: curl/11.45.14\r\n\r\n")
|
||||
s.recv(1)
|
||||
s.close()
|
||||
deltaTime = time.time()-st
|
||||
alt += deltaTime
|
||||
suc += 1
|
||||
_list.append(deltaTime)
|
||||
except (socket.timeout):
|
||||
fac += 1
|
||||
_list.append(0)
|
||||
except Exception:
|
||||
_list.append(0)
|
||||
fac += 1
|
||||
if (suc == 0):
|
||||
return (0,0,_list)
|
||||
return (alt/suc,suc/(suc+fac),_list)
|
||||
0
utils/speedtest/clash_config.yml
Normal file
0
utils/speedtest/clash_config.yml
Normal file
Binary file not shown.
0
utils/speedtest/proxychains.conf
Normal file
0
utils/speedtest/proxychains.conf
Normal file
21
utils/speedtest/speedtest.sh
Normal file
21
utils/speedtest/speedtest.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#准备好所需文件
|
||||
wget -O clash.gz https://github.com/Dreamacro/clash/releases/download/v1.10.0/clash-linux-amd64-v1.10.0.gz
|
||||
gunzip clash.gz
|
||||
wget -O lite.gz https://github.com/alanbobs999/LiteSpeedTest/releases/download/v0.9.1/lite-linux-amd64-v0.9.1.gz
|
||||
gunzip lite.gz
|
||||
wget -O clash_config.yml https://raw.githubusercontent.com/alanbobs999/TopFreeProxies/master/utils/speedtest/clash_config.yml
|
||||
wget -O proxychains.conf https://raw.githubusercontent.com/alanbobs999/TopFreeProxies/master/utils/speedtest/proxychains.conf
|
||||
wget -O lite_config.json https://raw.githubusercontent.com/alanbobs999/TopFreeProxies/master/utils/speedtest/lite_config.json
|
||||
#初始化 Clash
|
||||
chmod +x clash
|
||||
nohup ./clash >clash.log 2>&1 &
|
||||
#安装并配置 proxychains
|
||||
sudo apt-get install proxychains
|
||||
sudo chmod 777 ../../../../../etc/proxychains.conf
|
||||
mv -f proxychains.conf ../../../../../etc/proxychains.conf
|
||||
#开始运行 Clash
|
||||
sudo pkill -f clash
|
||||
nohup ./clash -f clash_config.yml >clash.log 2>&1 &
|
||||
#运行 LiteSpeedTest
|
||||
chmod +x lite
|
||||
nohup proxychains ./lite --config ./lite_config.json --test https://raw.githubusercontent.com/alanbobs999/TopFreeProxies/master/Eternity.yml >speedtest.log 2>&1 &
|
||||
Loading…
Reference in New Issue
Block a user