Skip to content

The only downloader you need. 下载器的集大成者。

refactor(bt): 代理设置构造改为公开方法 buildProxySettings

XiaoYouChR62b403633cad
diff --git a/features/bittorrent_pack/session.py b/features/bittorrent_pack/session.py
index 319628cb..9ac90601 100644
--- a/features/bittorrent_pack/session.py
+++ b/features/bittorrent_pack/session.py
@@ -323,7 +323,7 @@ class BTSession:
"enable_upnp": True,
"enable_natpmp": True,
"alert_mask": ALERT_MASK,
- **self._proxySettings(),
+ **self.buildProxySettings(),
}
self._session = lt.session(params)
if self._poller is None or self._poller.done():
@@ -574,7 +574,7 @@ class BTSession:
def _onProxyChanged(self, _value=None) -> None:
if self._session is None:
return
- settings = self._proxySettings()
+ settings = self.buildProxySettings()
self._session.apply_settings(
settings or {"proxy_type": lt.proxy_type_t.none}
)
@@ -584,7 +584,7 @@ class BTSession:
return 0
return int(cfg.speedLimitation.value)
- def _proxySettings(self) -> dict:
+ def buildProxySettings(self) -> dict:
url = proxy(PROXY_SCHEMES)
if not url:
return {}
diff --git a/tests/test_bt_proxy.py b/tests/test_bt_proxy.py
index c6d6c8b2..754313a1 100644
--- a/tests/test_bt_proxy.py
+++ b/tests/test_bt_proxy.py
@@ -1,6 +1,6 @@
"""BT 只走 SOCKS5 代理:libtorrent 只有 SOCKS5 能转发 UDP(tracker、DHT)。
-Seam: BTSession._proxySettings(设置全局代理)
+Seam: BTSession.buildProxySettings(设置全局代理)
"""
from __future__ import annotations
@@ -18,7 +18,7 @@ def settingsFor():
def build(url):
cfg.proxyServer.value = url or "Off"
assert cfg.proxyServer.value == (url or "Off")
- return BTSession()._proxySettings()
+ return BTSession().buildProxySettings()
yield build
cfg.proxyServer.value = saved