Skip to content

Commit

Permalink
Merge pull request #168 from mlmmlm/dev
Browse files Browse the repository at this point in the history
🎉联通性测试条目(绘图)支持自定义排序
  • Loading branch information
AirportR authored Feb 26, 2024
2 parents 332700b + cf42635 commit 8e887cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion resources/config.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bot:
# ====================以上为必填项,否则无法启动成功========================
# proxy: host:端口:用户名:密码 #socks5代理,用户名和密码为可选配置,已和下面的proxy单独分离,请勿混用
# strictmode: false # 严格模式,代表测试的时侯,bot内联按钮只有发起测试的主人才能按,否则所有用户用户权限都可以按。默认false,目前未适配,敬请期待。
# scripttext: "⏳联通性测试进行中..." # 解锁脚本测试进度条自定义文本
# scripttext: "⏳连通性测试进行中..." # 解锁脚本测试进度条自定义文本
# analyzetext: "⏳节点测试拓扑进行中..." # 拓扑测试进度条自定义文本
# speedtext: "⏳速度测试进行中..." # 速度测试进度条自定义文本
# bar: "=" #进度条自定义文本
Expand All @@ -27,6 +27,7 @@ bot:
#如果要http代理要验证,配置格式为: proxy: "用户名:密码@host:端口" 比如: user1:[email protected]:7890
#geoip-api: "ip-api.com" # GEOIP 测试api,取二级域名,目前支持 ip-api.com ip.sb ipleak.net ipdata.co ipapi.co 五种,其中 ipdata 需要配置下面的geoip-key
#geoip-key: xxxxxxx #ipdata 的 apikey,如果使用其他api则无需填写
#test_sort: ['类型', 'HTTP(s)排序', 'Netflix', 'Youtube', 'Disney+'] #连通性测试条目自定义排序
#subconverter: #订阅转换(此配置主要开发者已无心维护,能用但不稳定)
# enable: true #是否启用
# host: '127.0.0.1:25500' #域名或者ip加端口
Expand Down
12 changes: 11 additions & 1 deletion utils/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import socket
import time

from collections import Counter
from collections import Counter, OrderedDict
from operator import itemgetter
from typing import Union, Callable, Coroutine, Tuple

Expand Down Expand Up @@ -562,6 +562,7 @@ async def batch_test_pro(self, proxyinfo: list, test_items: list, pool: dict,

async def core(self, proxyinfo: list, **kwargs):
info = {} # 存放测试结果
test_sort = GCONFIG.config.get('test_sort', ["0", "1"])
media_items = kwargs.get('script', None) or kwargs.get('test_items', None) or kwargs.get('media_items', None)
test_items = collector.media_items if media_items is None else media_items
test_items = cleaner.addon.mix_script(test_items, False)
Expand Down Expand Up @@ -606,6 +607,15 @@ async def core(self, proxyinfo: list, **kwargs):
# 任务信息
info['task'] = kwargs.get('task', {})
# 保存结果
sorted_dict = OrderedDict()
for key in test_sort:
if key in info:
sorted_dict[key] = info[key]

for key in info:
if key not in sorted_dict:
sorted_dict[key] = info[key]
info = dict(sorted_dict)
self.saveresult(info)
return info

Expand Down

0 comments on commit 8e887cb

Please sign in to comment.