Skip to content

Commit

Permalink
Added announce to all trackers functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
qstokkink committed Jan 22, 2025
1 parent f6114bf commit 27cb6b2
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 13 deletions.
26 changes: 14 additions & 12 deletions src/tribler/core/libtorrent/download_manager/download_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/tribler/tribler_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/tribler/ui/public/locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/tribler/ui/public/locales/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/tribler/ui/public/locales/ko_KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
"MaxConnections": "내려받기당 최대 연결 수",
"ZeroIsUnlimited": "0 = 무제한",
"MinusOneIsUnlimited": "-1 = 무제한",
"EnableAnnounceAll": "모든 토렌트 추적자에게 공지",
"MaxTrackerConnections": "최대 동시 추적기 연결",
"Password": "비밀번호",
"UploadRate": "올리기 속도 제한",
"DownloadRate": "내려받기 속도 제한",
Expand Down
2 changes: 2 additions & 0 deletions src/tribler/ui/public/locales/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/tribler/ui/public/locales/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"MaxConnections": "Макс. число соединений",
"ZeroIsUnlimited": "0 = без ограничения",
"MinusOneIsUnlimited": "-1 = без ограничения",
"EnableAnnounceAll": "Анонсируйте на всех торрент-трекерах",
"MaxTrackerConnections": "Максимальное количество одновременных подключений к трекеру",
"Password": "Пароль",
"UploadRate": "Исходящий трафик",
"DownloadRate": "Входящий трафик",
Expand Down
2 changes: 2 additions & 0 deletions src/tribler/ui/public/locales/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"MaxConnections": "每个下载任务的最大连接数",
"ZeroIsUnlimited": "0 = 无限制",
"MinusOneIsUnlimited": "-1 = 无限制",
"EnableAnnounceAll": "向所有种子追踪者宣布",
"MaxTrackerConnections": "最大并发跟踪器连接数",
"Password": "密码",
"UploadRate": "上传速率限制",
"DownloadRate": "下载速率限制",
Expand Down
43 changes: 42 additions & 1 deletion src/tribler/ui/src/pages/Settings/Connection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,55 @@ 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)
}
});
}
}}
/>
<div></div>
<p className="text-xs p-0 pb-4 text-muted-foreground">{t('MinusOneIsUnlimited')}</p>

<Label htmlFor="announce_to_all" className="whitespace-nowrap pr-5">
{t('EnableAnnounceAll')}
</Label>
<Checkbox
id="announce_to_all"
className="my-2"
checked={(settings?.libtorrent.announce_to_all_tiers !== settings?.libtorrent.announce_to_all_trackers) ? "indeterminate" : settings?.libtorrent.announce_to_all_tiers}
onCheckedChange={(value) => {
if (settings) {
setSettings({
...settings,
libtorrent: {
...settings.libtorrent,
announce_to_all_tiers: !!value,
announce_to_all_trackers: !!value
}
});
}
}}
/>

<Label htmlFor="max_concurrent_http_announces" className="whitespace-nowrap pr-5">
{t('MaxTrackerConnections')}
</Label>
<Input
id="max_concurrent_http_announces"
type="number"
value={settings?.libtorrent?.max_concurrent_http_announces === undefined ? 50 : settings?.libtorrent?.max_concurrent_http_announces}
onChange={(event) => {
if (settings) {
setSettings({
...settings,
libtorrent: {
...settings.libtorrent,
max_concurrent_http_announces: Math.max(1, +event.target.value)
}
});
}
}}
/>
</div>

<SaveButton
Expand Down

0 comments on commit 27cb6b2

Please sign in to comment.