Skip to content

Commit

Permalink
Ensure the default hop count is respected
Browse files Browse the repository at this point in the history
  • Loading branch information
egbertbouman committed Aug 13, 2024
1 parent 2766291 commit f740f77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ def from_defaults(settings: TriblerConfigManager) -> DownloadConfig:
defaults.validate(Validator())
config = DownloadConfig(defaults)

config.set_hops(int(settings.get("libtorrent/download_defaults/number_hops")))
if settings.get("libtorrent/download_defaults/anonymity_enabled"):
config.set_hops(int(settings.get("libtorrent/download_defaults/number_hops")))
else:
config.set_hops(0)
config.set_safe_seeding(settings.get("libtorrent/download_defaults/safeseeding_enabled"))
config.set_dest_dir(settings.get("libtorrent/download_defaults/saveas"))

Expand Down
12 changes: 6 additions & 6 deletions src/tribler/core/libtorrent/restapi/downloads_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ def create_dconfig_from_params(self, parameters: dict) -> tuple[DownloadConfig,
"""
download_config = DownloadConfig.from_defaults(self.download_manager.config)

anon_hops = parameters.get('anon_hops', 0)
anon_hops = parameters.get('anon_hops')
safe_seeding = bool(parameters.get('safe_seeding', 0))

if anon_hops > 0 and not safe_seeding:
return None, "Cannot set anonymous download without safe seeding enabled"

if anon_hops >= 0:
download_config.set_hops(anon_hops)
if anon_hops is not None:
if anon_hops > 0 and not safe_seeding:
return None, "Cannot set anonymous download without safe seeding enabled"
if anon_hops >= 0:
download_config.set_hops(anon_hops)

if safe_seeding:
download_config.set_safe_seeding(True)
Expand Down

0 comments on commit f740f77

Please sign in to comment.