Skip to content

Commit

Permalink
v1.01
Browse files Browse the repository at this point in the history
  • Loading branch information
PauperZ committed Aug 26, 2021
1 parent 4618699 commit c7a1c46
Show file tree
Hide file tree
Showing 80 changed files with 187 additions and 121 deletions.
1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ Linux 依赖
- [NyanChanMeow](https://github.com/NyanChanMeow)
- beta版测试
- [ChenBilly](https://t.me/ChenBilly)
- [Duang](https://t.me/duang11212)
- [万有引力](https://t.me/cloudspeedtest)
- 建议及支持
- [jiexi](https://t.me/jiexi001)
- [萌新黑客](https://t.me/yxkumad)
Expand Down Expand Up @@ -129,12 +131,13 @@ python main.py -u "https://home.yoyu.dev/subscriptionlink" --include 香港 Azur
## 自定义配置

- **自定义颜色**
- 在 ssrspeed_config.json 文件下第 30 行,采用速度(MB/s)对应输出颜色 (RGB 256)方式
- 在 ssrspeed_config.json 文件下第 35 行,采用速度(MB/s)对应输出颜色 (RGB 256)方式
- **自定义字体**
- 下载字体文件放入 /resources/fonts/ 文件夹下,修改 ssrspeed_config.json 文件下第 29 行,本项目自带两个字体
- 下载字体文件放入 /resources/fonts/ 文件夹下,修改 ssrspeed_config.json 文件下第 34 行,本项目自带两个字体
- **修改测速项目**
- 在 ssrspeed_config.json 文件下第 16 行及第 21 行,可以设置是否进行udp类型及Netflix解锁测试,默认允许

- 在 ssrspeed_config.json 文件下第 16 行及第 25 行,可以设置是否进行udp类型及Netflix解锁测试,默认允许。在 21-23行可以分别设置是否进行 ping / Google ping 测试,默认允许,若不进行测试,对应项在测速图上显示为0
- **修改测速方式**
- 在 ssrspeed_config.json 文件下第 24 行,可以设置采用单/多线程测速方式或均速/最高速测速方式,默认为前者

## 详细使用方法

Expand Down
Binary file modified __pycache__/config.cpython-39.pyc
Binary file not shown.
Binary file modified colorlog/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified colorlog/__pycache__/color.cpython-39.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"server": "node.catdns.obitibet.com", "server_port": 4397, "method": "chacha20-ietf-poly1305", "protocol": "", "obfs": "", "plugin": "", "password": "5eb8b045-a2c8-4d72-8347-e43f5345e4d2", "protocol_param": "", "obfsparam": "", "plugin_opts": "", "plugin_args": "", "remarks": "\u52a0\u62ff\u5927 01", "group": "N/A", "timeout": 10, "local_port": 1087, "local_address": "127.0.0.1", "fastopen": false}
{"remarks": "\u9999\u6e2fHKT3[x1|IEPL|NF|V2Ray]@480Mbps", "group": "N/A", "server": "br-gtm-iepl1.node-fnf.xyz", "server_port": 20110, "log": {"access": "", "error": "", "loglevel": "warning"}, "inbounds": [{"port": 1087, "listen": "127.0.0.1", "protocol": "socks", "sniffing": {"enabled": true, "destOverride": ["http", "tls"]}, "settings": {"auth": "noauth", "udp": true, "ip": null, "clients": null}, "streamSettings": null}], "outbounds": [{"tag": "proxy", "protocol": "vmess", "settings": {"vnext": [{"address": "br-gtm-iepl1.node-fnf.xyz", "port": 20110, "users": [{"id": "0eefa5b3-fe64-3319-ba6c-f4df1c2d9304", "alterId": 1, "email": "", "security": "auto"}]}], "servers": null, "response": null}, "streamSettings": {"network": "tcp", "security": "", "tlsSettings": {}, "tcpSettings": {}, "kcpSettings": {}, "wsSettings": {}, "httpSettings": {}, "quicSettings": {}}, "mux": {"enabled": true}}, {"tag": "direct", "protocol": "freedom", "settings": {"vnext": null, "servers": null, "response": null}, "streamSettings": {}, "mux": {}}, {"tag": "block", "protocol": "blackhole", "settings": {"vnext": null, "servers": null, "response": {"type": "http"}}, "streamSettings": {}, "mux": {}}], "dns": {}, "routing": {"domainStrategy": "IPIfNonMatch", "rules": []}}
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import shutil
import json

__version__ = "2.7.3"
__version__ = "1.01"
__web_api_version__ = "0.5.2"

config = {
Expand Down
File renamed without changes.
Binary file modified ssrspeed/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/client_launcher/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/client_launcher/__pycache__/base_client.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified ssrspeed/client_launcher/__pycache__/client_v2ray.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/config_parser/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/config_parser/__pycache__/base_parser.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/config_parser/__pycache__/clash_parser.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/config_parser/__pycache__/config_parser.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/config_parser/__pycache__/node_filters.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified ssrspeed/config_parser/__pycache__/trojan_parser.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/config_parser/__pycache__/v2ray_parser.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified ssrspeed/core/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/core/__pycache__/ssrspeed_core.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/result/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/result/__pycache__/export_result.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/result/__pycache__/import_result.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/result/__pycache__/sorter.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/result/__pycache__/upload_result.cpython-39.pyc
Binary file not shown.
43 changes: 31 additions & 12 deletions ssrspeed/result/export_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(self):
self.__hide_max_speed = config["exportResult"]["hide_max_speed"]
self.__hide_ntt = not config["ntt"]["enabled"]
self.__hide_netflix = not config["netflix"]
self.__hide_stspeed = not config["StSpeed"]
self.__colors = {}
self.__colorSpeedList = []
self.__font = ImageFont.truetype(self.__config["font"],18)
Expand Down Expand Up @@ -155,7 +156,7 @@ def __exportAsPng(self,result):


# draw.line((0,newImageHeight - 30 - 1,imageRightPosition,newImageHeight - 30 - 1),fill=(127,127,127),width=1)
text = "便宜机场测速 With SSRSpeed ( v{} )".format(config["VERSION"])
text = "便宜机场测速 With SSRSpeed N ( v{} )".format(config["VERSION"])
draw.text((self.__getBasePos(imageRightPosition, text), 4),
text,
font=resultFont,
Expand Down Expand Up @@ -220,20 +221,38 @@ def __exportAsPng(self,result):
"Google Ping", font=resultFont, fill=(0,0,0)
)

draw.text(
(
googlePingRightPosition + self.__getBasePos(dspeedRightPosition - googlePingRightPosition, "单线程"), 30 + 4
),
"单线程", font=resultFont, fill=(0,0,0)
)

if not self.__hide_max_speed:
if not self.__hide_stspeed:
draw.text(
(
dspeedRightPosition + self.__getBasePos(maxDSpeedRightPosition - dspeedRightPosition, "多线程"), 30 + 4
),
"多线程", font=resultFont, fill=(0,0,0)
googlePingRightPosition + self.__getBasePos(dspeedRightPosition - googlePingRightPosition, "单线程"), 30 + 4
),
"单线程", font=resultFont, fill=(0,0,0)
)
else:
draw.text(
(
googlePingRightPosition + self.__getBasePos(dspeedRightPosition - googlePingRightPosition, "AvgSpeed"),
30 + 4
),
"AvgSpeed", font=resultFont, fill=(0, 0, 0)
)

if not self.__hide_max_speed:
if not self.__hide_stspeed:
draw.text(
(
dspeedRightPosition + self.__getBasePos(maxDSpeedRightPosition - dspeedRightPosition, "多线程"), 30 + 4
),
"多线程", font=resultFont, fill=(0,0,0)
)
else:
draw.text(
(
dspeedRightPosition + self.__getBasePos(maxDSpeedRightPosition - dspeedRightPosition, "MaxSpeed"),
30 + 4
),
"MaxSpeed", font=resultFont, fill=(0, 0, 0)
)

if not self.__hide_ntt:
draw.text(
Expand Down
Binary file modified ssrspeed/result/exporters/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file modified ssrspeed/shell/__pycache__/cli.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/speed_test/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/speed_test/__pycache__/speed_test.cpython-39.pyc
Binary file not shown.
46 changes: 26 additions & 20 deletions ssrspeed/speed_test/speed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

LOCAL_ADDRESS = config["localAddress"]
LOCAL_PORT = config["localPort"]
PING_TEST = config["ping"]
GOOGLE_PING_TEST = config["gping"]
NETFLIX_TEXT = config["netflix"]
ntype = "None"

Expand All @@ -34,7 +36,7 @@ def __init__(self, parser, method = "SOCKET", use_ssr_cs = False):
"group": "N/A",
"remarks": "N/A",
"loss": 1,
"ping": -1,
"ping": 0,
"gPingLoss": 1,
"gPing": 0,
"dspeed": -1,
Expand Down Expand Up @@ -129,7 +131,7 @@ def __geoIPOutbound(self):
)
)

if NETFLIX_TEXT:
if NETFLIX_TEXT and outboundIP != "N/A":
logger.info("Performing netflix test LOCAL_PORT: {:d}.".format(LOCAL_PORT))
try:
headers = {
Expand Down Expand Up @@ -185,22 +187,26 @@ def __tcpPing(self, server, port):
"gPingLoss": self.__baseResult["gPingLoss"],
"rawGooglePingStatus": self.__baseResult["rawGooglePingStatus"]
}
st = SpeedTestMethods()
latencyTest = st.tcpPing(server, port)
res["loss"] = 1 - latencyTest[1]
res["ping"] = latencyTest[0]
res["rawTcpPingStatus"] = latencyTest[2]
logger.debug(latencyTest)
time.sleep(1)
if (latencyTest[0] > 0):
try:
googlePingTest = st.googlePing()
res["gPing"] = googlePingTest[0]
res["gPingLoss"] = 1 - googlePingTest[1]
res["rawGooglePingStatus"] = googlePingTest[2]
except:
logger.exception("")
pass

if PING_TEST:
st = SpeedTestMethods()
latencyTest = st.tcpPing(server, port)
res["loss"] = 1 - latencyTest[1]
res["ping"] = latencyTest[0]
res["rawTcpPingStatus"] = latencyTest[2]
logger.debug(latencyTest)
time.sleep(1)

if ((not PING_TEST) or (latencyTest[0] > 0)):
if GOOGLE_PING_TEST:
try:
googlePingTest = st.googlePing()
res["gPing"] = googlePingTest[0]
res["gPingLoss"] = 1 - googlePingTest[1]
res["rawGooglePingStatus"] = googlePingTest[2]
except:
logger.exception("")
pass
return res

def __nat_type_test(self):
Expand Down Expand Up @@ -304,7 +310,7 @@ def __start_test(self, test_mode = "FULL"):
_item["geoIP"]["outbound"]["address"] = outboundInfo[0]
_item["geoIP"]["outbound"]["info"] = outboundInfo[1]

if (_item["gPing"] > 0 or outboundInfo[2] == "CN"):
if ((not GOOGLE_PING_TEST) or _item["gPing"] > 0 or outboundInfo[2] == "CN"):
st = SpeedTestMethods()
if test_mode == "WPS":
res = st.startWpsTest()
Expand Down Expand Up @@ -347,7 +353,7 @@ def __start_test(self, test_mode = "FULL"):
)
)

elif test_mode == "FULL":
elif test_mode == "FULL":
nat_info = ""
if config["ntt"]["enabled"]:
t, eip, eport, sip, sport = self.__nat_type_test()
Expand Down
Binary file not shown.
Binary file modified ssrspeed/speed_test/test_methods/__pycache__/fast.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/speed_test/test_methods/__pycache__/ping.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions ssrspeed/speed_test/test_methods/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import logging
logger = logging.getLogger("Sub")


def tcp_ping(host, port):

alt=0
suc=0
fac=0
Expand Down Expand Up @@ -39,6 +41,7 @@ def tcp_ping(host, port):
return (alt/suc,suc/(suc+fac),_list)

def google_ping(address, port=1080):

alt=0
suc=0
fac=0
Expand Down
110 changes: 60 additions & 50 deletions ssrspeed/speed_test/test_methods/st_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
LOCK = threading.Lock()
TOTAL_RECEIVED = 0
MAX_TIME = 0
SPEED_TEST = config["speed"]
STSPEED_TEST = config["StSpeed"]

def setProxyPort(port):
global LOCAL_PORT
Expand Down Expand Up @@ -95,6 +97,10 @@ def speedTestThread(link):
return 0

def speedTestSocket(port):

if not SPEED_TEST:
return (0, 0, [], 0)

global EXIT_FLAG,LOCAL_PORT,MAX_TIME,TOTAL_RECEIVED,MAX_FILE_SIZE
LOCAL_PORT = port

Expand All @@ -108,53 +114,53 @@ def speedTestSocket(port):
socks.set_default_proxy(socks.SOCKS5,"127.0.0.1", LOCAL_PORT)
socket.socket = socks.socksocket


for i in range(0,1):
nmsl = threading.Thread(target=speedTestThread,args=(res[0],))
nmsl.start()
maxSpeedList = []
maxSpeed = 0
currentSpeed = 0
OLD_RECEIVED = 0
DELTA_RECEIVED = 0
for i in range(1,11):
time.sleep(0.5)
LOCK.acquire()
DELTA_RECEIVED = TOTAL_RECEIVED - OLD_RECEIVED
OLD_RECEIVED = TOTAL_RECEIVED
LOCK.release()
currentSpeed = DELTA_RECEIVED / 0.5
maxSpeedList.append(currentSpeed)
print("\r[" + "="*i + "> [%d%%/100%%] [%.2f MB/s]" % (int(i * 10),currentSpeed / 1024 / 1024),end='')
if (EXIT_FLAG):
break
print("\r[" + "="*i + "] [100%%/100%%] [%.2f MB/s]" % (currentSpeed / 1024 / 1024),end='\n')
EXIT_FLAG = True
for i in range(0,10):
time.sleep(0.1)
if (MAX_TIME != 0):
break
if (MAX_TIME == 0):
logger.error("Socket Test Error !")
return (0, 0, [], 0)
restoreSocket()
rawSpeedList = copy.deepcopy(maxSpeedList)
maxSpeedList.sort()
if (len(maxSpeedList) > 12):
msum = 0
for i in range(12,len(maxSpeedList) - 2):
msum += maxSpeedList[i]
maxSpeed = (msum / (len(maxSpeedList) - 2 - 12))
else:
maxSpeed = currentSpeed
logger.info("SingleThread: Fetched {:.2f} KB in {:.2f} s.".format(TOTAL_RECEIVED / 1024, MAX_TIME))

AvgStSpeed = TOTAL_RECEIVED / MAX_TIME

MAX_TIME = 0
TOTAL_RECEIVED = 0
EXIT_FLAG = False
if STSPEED_TEST:
for i in range(0,1):
nmsl = threading.Thread(target=speedTestThread,args=(res[0],))
nmsl.start()

maxSpeedList = []
maxSpeed = 0
currentSpeed = 0
OLD_RECEIVED = 0
DELTA_RECEIVED = 0
for i in range(1,11):
time.sleep(0.5)
LOCK.acquire()
DELTA_RECEIVED = TOTAL_RECEIVED - OLD_RECEIVED
OLD_RECEIVED = TOTAL_RECEIVED
LOCK.release()
currentSpeed = DELTA_RECEIVED / 0.5
maxSpeedList.append(currentSpeed)
print("\r[" + "="*i + "> [%d%%/100%%] [%.2f MB/s]" % (int(i * 10),currentSpeed / 1024 / 1024),end='')
if (EXIT_FLAG):
break
print("\r[" + "="*i + "] [100%%/100%%] [%.2f MB/s]" % (currentSpeed / 1024 / 1024),end='\n')
EXIT_FLAG = True
for i in range(0,10):
time.sleep(0.1)
if (MAX_TIME != 0):
break
if (MAX_TIME == 0):
logger.error("Socket Test Error !")
return (0, 0, [], 0)
restoreSocket()
rawSpeedList = copy.deepcopy(maxSpeedList)
maxSpeedList.sort()
if (len(maxSpeedList) > 12):
msum = 0
for i in range(12,len(maxSpeedList) - 2):
msum += maxSpeedList[i]
maxSpeed = (msum / (len(maxSpeedList) - 2 - 12))
else:
maxSpeed = currentSpeed
logger.info("SingleThread: Fetched {:.2f} KB in {:.2f} s.".format(TOTAL_RECEIVED / 1024, MAX_TIME))

AvgStSpeed = TOTAL_RECEIVED / MAX_TIME

MAX_TIME = 0
TOTAL_RECEIVED = 0
EXIT_FLAG = False

for i in range(0,MAX_THREAD):
nmsl = threading.Thread(target=speedTestThread,args=(res[0],))
Expand Down Expand Up @@ -189,14 +195,18 @@ def speedTestSocket(port):
restoreSocket()
rawSpeedList = copy.deepcopy(maxSpeedList)
maxSpeedList.sort()
if (len(maxSpeedList) > 12):
if (len(maxSpeedList) > 7):
msum = 0
for i in range(12,len(maxSpeedList) - 2):
for i in range(7,len(maxSpeedList) - 2):
msum += maxSpeedList[i]
maxSpeed = (msum / (len(maxSpeedList) - 2 - 12))
maxSpeed = (msum / (len(maxSpeedList) - 2 - 7))
else:
maxSpeed = currentSpeed
logger.info("MultiThread: Fetched {:.2f} KB in {:.2f} s.".format(TOTAL_RECEIVED / 1024, MAX_TIME))
AvgSpeed = TOTAL_RECEIVED / MAX_TIME

if not STSPEED_TEST:
AvgStSpeed = AvgSpeed
AvgSpeed = maxSpeed

return (AvgStSpeed, AvgSpeed, rawSpeedList, TOTAL_RECEIVED)
Binary file modified ssrspeed/thread_pool/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/thread_pool/__pycache__/abstract_task.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/thread_pool/__pycache__/thread_pool.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/thread_pool/__pycache__/work_thread.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/types/nodes/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified ssrspeed/types/nodes/__pycache__/node_type_base.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/types/nodes/__pycache__/node_v2ray.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/utils/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/utils/__pycache__/b64plus.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/utils/__pycache__/geo_ip.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/utils/__pycache__/platform_check.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/utils/__pycache__/port_checker.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/utils/__pycache__/requirements_check.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/utils/rules/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified ssrspeed/utils/rules/__pycache__/dl_rule_match.cpython-39.pyc
Binary file not shown.
Loading

0 comments on commit c7a1c46

Please sign in to comment.