update(ToBypassTrackers): 修复插件动作

This commit is contained in:
wumode
2025-08-04 21:58:44 +08:00
parent 460afee768
commit 049eae0864
2 changed files with 26 additions and 14 deletions

View File

@@ -418,17 +418,18 @@
"name": "绕过Trackers",
"description": "提供tracker服务器IP地址列表帮助IPv6连接绕过OpenClash。",
"labels": "工具",
"version": "1.4.1",
"version": "1.4.2",
"icon": "Clash_A.png",
"author": "wumode",
"level": 2,
"history": {
"v1.0": "支持自定义Trackers",
"v1.1": "更新列表后发送通知",
"v1.2": "修复Trackers加载错误",
"v1.3": "新增一些Trackers",
"v1.4.2": "修复插件动作",
"v1.4.1": "修复通知类型错误",
"v1.4": "异步查询DNS",
"v1.4.1": "修复通知类型错误"
"v1.3": "新增一些Trackers",
"v1.2": "修复Trackers加载错误",
"v1.1": "更新列表后发送通知",
"v1.0": "支持自定义Trackers"
}
},
"ImdbSource": {

View File

@@ -12,7 +12,7 @@ from apscheduler.triggers.cron import CronTrigger
from fastapi import Response
from app.core.config import settings
from app.core.event import eventmanager
from app.core.event import eventmanager, Event
from app.db.site_oper import SiteOper
from app.log import logger
from app.plugins import _PluginBase
@@ -29,7 +29,7 @@ class ToBypassTrackers(_PluginBase):
# 插件图标
plugin_icon = "Clash_A.png"
# 插件版本
plugin_version = "1.4.1"
plugin_version = "1.4.2"
# 插件作者
plugin_author = "wumode"
# 作者主页
@@ -128,7 +128,14 @@ class ToBypassTrackers(_PluginBase):
@staticmethod
def get_command() -> List[Dict[str, Any]]:
pass
return [{
"cmd": "/refresh_tracker_ips",
"event": EventType.PluginAction,
"desc": "更新 Tracker IP 列表",
"data": {
"action": "refresh_tracker_ips"
}
}]
def get_api(self) -> List[Dict[str, Any]]:
"""
@@ -495,7 +502,7 @@ class ToBypassTrackers(_PluginBase):
self._scheduler.shutdown()
self._scheduler = None
except Exception as e:
logger.error("退出插件失败:%s" % str(e))
logger.error(f"退出插件失败:{e}")
def get_service(self) -> List[Dict[str, Any]]:
"""
@@ -518,13 +525,13 @@ class ToBypassTrackers(_PluginBase):
}]
return []
def bypassed_ips(self, protocol: str):
def bypassed_ips(self, protocol: str) -> Response:
if protocol == '6':
return Response(content=self.ipv6_txt, media_type="text/plain")
return Response(content=self.ipv4_txt, media_type="text/plain")
@eventmanager.register(EventType.PluginAction)
def update_ips(self):
def update_ips(self, event: Optional[Event]=None):
def __is_ip_in_subnet(ip_input: str, su_bnet: str) -> bool:
"""
Check if the given IP address is in the specified subnet.
@@ -537,10 +544,10 @@ class ToBypassTrackers(_PluginBase):
subnet_obj = ipaddress.ip_network(su_bnet, strict=False)
return ip_obj in subnet_obj
def __search_ip(ip, ips_list):
def __search_ip(_ip, ips_list):
i = 0
for ip_range in ips_list:
if __is_ip_in_subnet(ip, ip_range):
if __is_ip_in_subnet(_ip, ip_range):
return i
i += 1
return -1
@@ -592,6 +599,10 @@ class ToBypassTrackers(_PluginBase):
for domain_ in domains_])
await asyncio.gather(*tasks)
if event:
event_data = event.event_data
if not event_data or event_data.get("action") != "refresh_tracker_ips":
return
query_helper = DnsHelper(self._dns_input)
logger.info(f"开始通过 {query_helper.method_name} 解析DNS")
chnroute6_lists_url = "https://ispip.clang.cn/all_cn_ipv6.txt"