From 9bd394fbd4afd513bf3428e347c1839b35e8390f Mon Sep 17 00:00:00 2001 From: minecraft1024a Date: Wed, 13 Aug 2025 11:49:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9ESOCKS5=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E6=94=AF=E6=8C=81=EF=BC=8C=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=92=8C=E4=BE=9D=E8=B5=96=E9=A1=B9=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97=E4=BF=A1=E6=81=AF=E4=BB=A5?= =?UTF-8?q?=E6=9B=B4=E6=B8=85=E6=99=B0=E5=9C=B0=E6=98=BE=E7=A4=BA=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E4=BD=BF=E7=94=A8=E6=83=85=E5=86=B5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/built_in/WEB_SEARCH_TOOL/plugin.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/plugins/built_in/WEB_SEARCH_TOOL/plugin.py b/src/plugins/built_in/WEB_SEARCH_TOOL/plugin.py index 4d50f691a..8c635a7bc 100644 --- a/src/plugins/built_in/WEB_SEARCH_TOOL/plugin.py +++ b/src/plugins/built_in/WEB_SEARCH_TOOL/plugin.py @@ -190,16 +190,21 @@ class URLParserTool(BaseTool): proxies = None if enable_proxy: + socks5_proxy = self.get_config("proxy.socks5_proxy", None) http_proxy = self.get_config("proxy.http_proxy", None) https_proxy = self.get_config("proxy.https_proxy", None) - if http_proxy or https_proxy: + # 优先使用SOCKS5代理(全协议代理) + if socks5_proxy: + proxies = socks5_proxy + logger.info(f"使用SOCKS5代理: {socks5_proxy}") + elif http_proxy or https_proxy: proxies = {} if http_proxy: proxies["http://"] = http_proxy if https_proxy: proxies["https://"] = https_proxy - logger.info(f"使用代理配置: {proxies}") + logger.info(f"使用HTTP/HTTPS代理配置: {proxies}") client_kwargs = {"timeout": 15.0, "follow_redirects": True} if proxies: @@ -393,7 +398,7 @@ class WEBSEARCHPLUGIN(BasePlugin): plugin_name: str = "web_search_tool" # 内部标识符 enable_plugin: bool = True dependencies: List[str] = [] # 插件依赖列表 - python_dependencies: List[str] = ["asyncddgs","exa_py"] # Python包依赖列表 + python_dependencies: List[str] = ["asyncddgs","exa_py","httpx[socks]"] # Python包依赖列表 config_file_name: str = "config.toml" # 配置文件名 # 配置节描述 @@ -412,6 +417,7 @@ class WEBSEARCHPLUGIN(BasePlugin): "proxy": { "http_proxy": ConfigField(type=str, default=None, description="HTTP代理地址,格式如: http://proxy.example.com:8080"), "https_proxy": ConfigField(type=str, default=None, description="HTTPS代理地址,格式如: http://proxy.example.com:8080"), + "socks5_proxy": ConfigField(type=str, default=None, description="SOCKS5代理地址,格式如: socks5://proxy.example.com:1080"), "enable_proxy": ConfigField(type=bool, default=False, description="是否启用代理") }, "components":{