diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 0047a90f4b..add46cfa8c 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -50,7 +50,7 @@ jobs: - shell: bash run: | cp /opt/homebrew/opt/libsodium/lib/libsodium.dylib /Library/Frameworks/Python.framework/Versions/3.9/lib/libsodium.dylib - sed -i".backup" 's|libtorrent==1.2.19|https://tribler.org/libtorrent-2.0.11-cp39-cp39-macosx_14_0_arm64.whl|' requirements.txt + sed -i".backup" 's|libtorrent==2.0.9|https://tribler.org/libtorrent-2.0.11-cp39-cp39-macosx_14_0_arm64.whl|' requirements.txt - run: python -m pip install -r requirements.txt - name: Run unit tests run: | diff --git a/build/docker/build.Dockerfile b/build/docker/build.Dockerfile index 050b940428..3050801ab3 100644 --- a/build/docker/build.Dockerfile +++ b/build/docker/build.Dockerfile @@ -1,4 +1,4 @@ -# libtorrent-1.2.19 does not support python 3.11 yet +# libtorrent-2.0.9 does not support python 3.11 yet FROM python:3.10-slim RUN apt-get update \ diff --git a/requirements.txt b/requirements.txt index e50a57f64e..530e2c51f9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,8 +3,9 @@ bitarray configobj ipv8-rust-tunnels -libtorrent==1.2.19 +libtorrent==2.0.9 lz4 +marshmallow==3.23.3 # TODO: support 3.24.0 onward pillow pony pystray diff --git a/src/tribler/core/libtorrent/download_manager/download_manager.py b/src/tribler/core/libtorrent/download_manager/download_manager.py index adb6ff0b41..8eccfcc723 100644 --- a/src/tribler/core/libtorrent/download_manager/download_manager.py +++ b/src/tribler/core/libtorrent/download_manager/download_manager.py @@ -287,7 +287,8 @@ def create_session(self, hops: int = 0) -> lt.session: # noqa: PLR0915 "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"))} + "enable_natpmp": int(self.config.get("libtorrent/natpmp")), + "allow_i2p_mixed": 1} # Copy construct so we don't modify the default list extensions = list(DEFAULT_LT_EXTENSIONS) @@ -633,13 +634,8 @@ async def start_download_from_uri(self, uri: str, config: DownloadConfig | None if scheme == "magnet": logger.info("Magnet scheme detected") params = lt.parse_magnet_uri(uri) - try: - # libtorrent 1.2.19 - name, infohash = params["name"].encode(), params["info_hash"] # type: ignore[index] # (checker is 2.X) - except TypeError: - # libtorrent 2.0.9 - name = params.name.encode() - infohash = unhexlify(str(params.info_hash)) + name = params.name.encode() + infohash = unhexlify(str(params.info_hash)) logger.info("Name: %s. Infohash: %s", name, infohash) if infohash in self.metainfo_cache: logger.info("Metainfo found in cache") diff --git a/src/tribler/core/libtorrent/restapi/torrentinfo_endpoint.py b/src/tribler/core/libtorrent/restapi/torrentinfo_endpoint.py index 53a9113b96..c1cb6eeaab 100644 --- a/src/tribler/core/libtorrent/restapi/torrentinfo_endpoint.py +++ b/src/tribler/core/libtorrent/restapi/torrentinfo_endpoint.py @@ -181,12 +181,7 @@ async def get_torrent_info(self, request: Request) -> RESTResponse: # noqa: C90 if response.startswith(b'magnet'): try: - try: - # libtorrent 1.2.19 - infohash = lt.parse_magnet_uri(uri)["info_hash"] # type: ignore[index] # (checker uses 2.X) - except TypeError: - # libtorrent 2.0.9 - infohash = unhexlify(str(lt.parse_magnet_uri(uri).info_hash)) + infohash = unhexlify(str(lt.parse_magnet_uri(uri).info_hash)) except RuntimeError as e: return RESTResponse( {"error": { @@ -203,12 +198,7 @@ async def get_torrent_info(self, request: Request) -> RESTResponse: # noqa: C90 self._logger.info("magnet scheme detected") try: - try: - # libtorrent 1.2.19 - infohash = lt.parse_magnet_uri(uri)["info_hash"] # type: ignore[index] # (checker uses 2.X) - except TypeError: - # libtorrent 2.0.9 - infohash = unhexlify(str(lt.parse_magnet_uri(uri).info_hash)) + infohash = unhexlify(str(lt.parse_magnet_uri(uri).info_hash)) except RuntimeError as e: return RESTResponse( {"error": {