diff --git a/src/tribler/core/libtorrent/download_manager/download_manager.py b/src/tribler/core/libtorrent/download_manager/download_manager.py index d60690016c..7ed4751804 100644 --- a/src/tribler/core/libtorrent/download_manager/download_manager.py +++ b/src/tribler/core/libtorrent/download_manager/download_manager.py @@ -283,14 +283,19 @@ def create_session(self, hops: int = 0) -> lt.session: # noqa: PLR0915 # Due to a bug in Libtorrent 0.16.18, the outgoing_port and num_outgoing_ports value should be set in # the settings dictionary logger.info("Creating a session") - settings: dict[str, str | float] = {"outgoing_port": 0, - "num_outgoing_ports": 1, - "allow_multiple_connections_per_ip": 0, - "enable_upnp": int(self.config.get("libtorrent/upnp")), - "enable_dht": int(self.config.get("libtorrent/dht")), - "enable_lsd": int(self.config.get("libtorrent/lsd")), - "enable_natpmp": int(self.config.get("libtorrent/natpmp")), - "allow_i2p_mixed": 1} + settings: dict[str, str | float] = { + "outgoing_port": 0, + "num_outgoing_ports": 1, + "allow_multiple_connections_per_ip": 0, + "enable_upnp": int(self.config.get("libtorrent/upnp")), + "enable_dht": int(self.config.get("libtorrent/dht")), + "enable_lsd": int(self.config.get("libtorrent/lsd")), + "enable_natpmp": int(self.config.get("libtorrent/natpmp")), + "allow_i2p_mixed": 1, + "announce_to_all_tiers": int(self.config.get("libtorrent/announce_to_all_tiers")), + "announce_to_all_trackers": int(self.config.get("libtorrent/announce_to_all_trackers")), + "max_concurrent_http_announces": int(self.config.get("libtorrent/max_concurrent_http_announces")) + } # Copy construct so we don't modify the default list extensions = list(DEFAULT_LT_EXTENSIONS) @@ -800,10 +805,7 @@ def set_session_settings(self, lt_session: lt.session, new_settings: dict) -> No self.ltsettings[lt_session].update(new_settings) try: - if hasattr(lt_session, "apply_settings"): - lt_session.apply_settings(new_settings) - else: - lt_session.set_settings(new_settings) # type: ignore[attr-defined] # (checker uses 2.X) + lt_session.apply_settings(new_settings) except OverflowError as e: msg = f"Overflow error when setting libtorrent sessions with settings: {new_settings}" raise OverflowError(msg) from e diff --git a/src/tribler/tribler_config.py b/src/tribler/tribler_config.py index 4bb9626b77..fdf67cfa14 100644 --- a/src/tribler/tribler_config.py +++ b/src/tribler/tribler_config.py @@ -106,6 +106,9 @@ class LibtorrentConfig(TypedDict): upnp: bool natpmp: bool lsd: bool + announce_to_all_tiers: bool + announce_to_all_trackers: bool + max_concurrent_http_announces: int download_defaults: DownloadDefaultsConfig @@ -214,6 +217,9 @@ class TriblerConfig(TypedDict): upnp=True, natpmp=True, lsd=True, + announce_to_all_tiers=False, + announce_to_all_trackers=False, + max_concurrent_http_announces=50, download_defaults=DownloadDefaultsConfig( anonymity_enabled=True, number_hops=1, diff --git a/src/tribler/ui/public/locales/en_US.json b/src/tribler/ui/public/locales/en_US.json index c9d7c884ee..6b329a1eac 100644 --- a/src/tribler/ui/public/locales/en_US.json +++ b/src/tribler/ui/public/locales/en_US.json @@ -40,6 +40,8 @@ "MaxConnections": "Max connections per download", "ZeroIsUnlimited": "0 = unlimited", "MinusOneIsUnlimited": "-1 = unlimited", + "EnableAnnounceAll": "Announce to all torrent trackers", + "MaxTrackerConnections": "Max concurrent tracker connections", "Password": "Password", "UploadRate": "Upload rate limit", "DownloadRate": "Download rate limit", diff --git a/src/tribler/ui/public/locales/es_ES.json b/src/tribler/ui/public/locales/es_ES.json index 7d37542c26..845a725e77 100644 --- a/src/tribler/ui/public/locales/es_ES.json +++ b/src/tribler/ui/public/locales/es_ES.json @@ -40,6 +40,8 @@ "MaxConnections": "Conexiones máximas por descarga", "ZeroIsUnlimited": "0 = ilimitadas", "MinusOneIsUnlimited": "-1 = ilimitadas", + "EnableAnnounceAll": "Anunciar a todos los rastreadores de torrents", + "MaxTrackerConnections": "Conexiones de seguimiento simultáneas máximas", "Password": "Contraseña", "UploadRate": "Límite de velocidad de subida", "DownloadRate": "Límite de velocidad de descarga", diff --git a/src/tribler/ui/public/locales/ko_KR.json b/src/tribler/ui/public/locales/ko_KR.json index afa19e31ec..6a04ed1824 100644 --- a/src/tribler/ui/public/locales/ko_KR.json +++ b/src/tribler/ui/public/locales/ko_KR.json @@ -40,6 +40,8 @@ "MaxConnections": "내려받기당 최대 연결 수", "ZeroIsUnlimited": "0 = 무제한", "MinusOneIsUnlimited": "-1 = 무제한", + "EnableAnnounceAll": "모든 토렌트 추적자에게 공지", + "MaxTrackerConnections": "최대 동시 추적기 연결", "Password": "비밀번호", "UploadRate": "올리기 속도 제한", "DownloadRate": "내려받기 속도 제한", diff --git a/src/tribler/ui/public/locales/pt_BR.json b/src/tribler/ui/public/locales/pt_BR.json index 6fa1155196..362b91053d 100644 --- a/src/tribler/ui/public/locales/pt_BR.json +++ b/src/tribler/ui/public/locales/pt_BR.json @@ -38,6 +38,8 @@ "MaxConnections": "Máximo de conexões por download", "ZeroIsUnlimited": "0 = sem limites", "MinusOneIsUnlimited": "-1 = sem limites", + "EnableAnnounceAll": "Anuncie a todos os rastreadores de torrent", + "MaxTrackerConnections": "Máximo de conexões simultâneas do rastreador", "Password": "Senha", "UploadRate": "Limite de upload", "DownloadRate": "Limite de upload", diff --git a/src/tribler/ui/public/locales/ru_RU.json b/src/tribler/ui/public/locales/ru_RU.json index 14fd6a8d61..38aa0cc959 100644 --- a/src/tribler/ui/public/locales/ru_RU.json +++ b/src/tribler/ui/public/locales/ru_RU.json @@ -41,6 +41,8 @@ "MaxConnections": "Макс. число соединений", "ZeroIsUnlimited": "0 = без ограничения", "MinusOneIsUnlimited": "-1 = без ограничения", + "EnableAnnounceAll": "Анонсируйте на всех торрент-трекерах", + "MaxTrackerConnections": "Максимальное количество одновременных подключений к трекеру", "Password": "Пароль", "UploadRate": "Исходящий трафик", "DownloadRate": "Входящий трафик", diff --git a/src/tribler/ui/public/locales/zh_CN.json b/src/tribler/ui/public/locales/zh_CN.json index 547b11a531..add3120dae 100644 --- a/src/tribler/ui/public/locales/zh_CN.json +++ b/src/tribler/ui/public/locales/zh_CN.json @@ -39,6 +39,8 @@ "MaxConnections": "每个下载任务的最大连接数", "ZeroIsUnlimited": "0 = 无限制", "MinusOneIsUnlimited": "-1 = 无限制", + "EnableAnnounceAll": "向所有种子追踪者宣布", + "MaxTrackerConnections": "最大并发跟踪器连接数", "Password": "密码", "UploadRate": "上传速率限制", "DownloadRate": "下载速率限制", diff --git a/src/tribler/ui/src/models/settings.model.tsx b/src/tribler/ui/src/models/settings.model.tsx index c2faeef3a0..f65a930541 100644 --- a/src/tribler/ui/src/models/settings.model.tsx +++ b/src/tribler/ui/src/models/settings.model.tsx @@ -66,6 +66,9 @@ export interface Settings { upnp: boolean; natpmp: boolean; lsd: boolean; + announce_to_all_tiers: boolean; + announce_to_all_trackers: boolean; + max_concurrent_http_announces: number; download_defaults: { anonymity_enabled: boolean; number_hops: number; diff --git a/src/tribler/ui/src/pages/Settings/Connection.tsx b/src/tribler/ui/src/pages/Settings/Connection.tsx index 74dcf366f5..8448c9deaf 100644 --- a/src/tribler/ui/src/pages/Settings/Connection.tsx +++ b/src/tribler/ui/src/pages/Settings/Connection.tsx @@ -178,7 +178,7 @@ export default function Connection() { ...settings, libtorrent: { ...settings.libtorrent, - max_connections_download: Math.max(0, +event.target.value) + max_connections_download: Math.max(-1, +event.target.value) } }); } @@ -186,6 +186,47 @@ export default function Connection() { />
{t('MinusOneIsUnlimited')}
+ + +