tribler.core.tunnel.community ============================= .. py:module:: tribler.core.tunnel.community Attributes ---------- .. autoapisummary:: tribler.core.tunnel.community.DESTROY_REASON_BALANCE tribler.core.tunnel.community.PEER_FLAG_EXIT_HTTP tribler.core.tunnel.community.PEER_FLAG_EXIT_BACKUP tribler.core.tunnel.community.MAX_HTTP_PACKET_SIZE Classes ------- .. autoapisummary:: tribler.core.tunnel.community.TriblerTunnelSettings tribler.core.tunnel.community.TriblerTunnelCommunity Functions --------- .. autoapisummary:: tribler.core.tunnel.community.is_bencoded Module Contents --------------- .. py:data:: DESTROY_REASON_BALANCE :value: 65535 .. py:data:: PEER_FLAG_EXIT_HTTP :value: 32768 .. py:data:: PEER_FLAG_EXIT_BACKUP :value: 16384 .. py:data:: MAX_HTTP_PACKET_SIZE :value: 1400 .. py:function:: is_bencoded(x: bytes) -> bool Returns True is x appears to be valid bencoded byte string. .. py:class:: TriblerTunnelSettings Bases: :py:obj:`ipv8.messaging.anonymization.hidden_services.HiddenTunnelSettings` Settings for Tribler's tunnel community. .. py:attribute:: exitnode_cache :type: pathlib.Path | None :value: None .. py:attribute:: notifier :type: tribler.core.notifier.Notifier .. py:attribute:: download_manager :type: tribler.core.libtorrent.download_manager.download_manager.DownloadManager .. py:attribute:: exitnode_enabled :type: bool :value: False .. py:attribute:: default_hops :type: int :value: 0 .. py:attribute:: max_intro_points :type: int :value: 10 .. py:class:: TriblerTunnelCommunity(settings: TriblerTunnelSettings) Bases: :py:obj:`ipv8.messaging.anonymization.hidden_services.HiddenTunnelCommunity` This community is built upon the anonymous messaging layer in IPv8. It adds support for libtorrent anonymous downloads. .. py:attribute:: community_id .. py:attribute:: settings_class .. py:attribute:: bittorrent_peers :type: dict[tribler.core.libtorrent.download_manager.download.Download, set[tuple[str, int]]] .. py:attribute:: download_states :type: dict[bytes, tribler.core.libtorrent.download_manager.download_state.DownloadStatus] .. py:attribute:: last_forced_announce :type: dict[bytes, float] .. py:method:: _poll_download_manager() -> None :async: Get the latest download states from the download manager. .. py:method:: cache_exitnodes_to_disk() -> None Write a copy of the exit_candidates to the file self.settings.exitnode_cache. .. py:method:: restore_exitnodes_from_disk() -> None Send introduction requests to peers stored in the file self.settings.exitnode_cache. .. py:method:: get_candidates(*requested_flags: int) -> list[ipv8.peer.Peer] Get all the peers that we can create circuits with. When requesting exits, prefer peers that aren't backups. .. py:method:: should_join_circuit(create_payload: ipv8.messaging.anonymization.payload.CreatePayload, previous_node_address: ipv8.messaging.interfaces.udp.endpoint.Address) -> bool :async: Check whether we should join a circuit. Returns a future that fires with a boolean. .. py:method:: readd_bittorrent_peers() -> None Add the special IPs that belong to circuits to a download. .. py:method:: update_torrent(peers: set[tuple[str, int]], download: tribler.core.libtorrent.download_manager.download.Download) -> None Ensure that the given peers are registered in the given download. .. py:method:: remove_circuit(circuit_id: int, additional_info: str = '', remove_now: bool = False, destroy: bool | int = False) -> None :async: Remove the circuit that belongs to the given circuit id. .. py:method:: remove_relay(circuit_id: int, additional_info: str = '', remove_now: bool = False, destroy: bool = False) -> None :async: Callback for when a relay is removed. .. py:method:: remove_exit_socket(circuit_id: int, additional_info: str = '', remove_now: bool = False, destroy: bool = False) -> ipv8.messaging.anonymization.exit_socket.TunnelExitSocket | None :async: Remove the exit socket that belongs to the given circuit id. .. py:method:: _ours_on_created_extended(circuit_id: int, payload: ipv8.messaging.anonymization.payload.CreatedPayload | ipv8.messaging.anonymization.payload.ExtendedPayload) -> None Callback for when we receive either a Created or and Extended payload. .. py:method:: on_raw_data(circuit: ipv8.messaging.anonymization.tunnel.Circuit, origin: tuple[str, int], data: bytes) -> None We have incoming data. .. py:method:: monitor_downloads(dslist: list[tribler.core.libtorrent.download_manager.download_state.DownloadState]) -> None Periodically check the Tribler downloads for state changes. .. py:method:: monitor_hidden_swarms(new_states: dict[bytes, tribler.core.libtorrent.download_manager.download_state.DownloadStatus], hops: dict[bytes, int]) -> None Update the known swarms based on the changed states. .. py:method:: on_e2e_finished(address: ipv8.messaging.interfaces.udp.endpoint.Address, info_hash: bytes) -> None Callback for when an end-to-end connection has been established. .. py:method:: get_download(lookup_info_hash: bytes) -> tribler.core.libtorrent.download_manager.download.Download | None Match the given infohash to a download (or None if it cannot be found). .. py:method:: introduction_response_callback(peer: ipv8.peer.Peer, dist: ipv8.messaging.payload_headers.GlobalTimeDistributionPayload, payload: ipv8.messaging.payload.IntroductionResponsePayload | ipv8.messaging.payload.NewIntroductionResponsePayload) -> None Try to discover peers that are behind a different port. .. py:method:: create_introduction_point(info_hash: bytes, required_ip: ipv8.peer.Peer | None = None) -> None :async: Start creating an introduction point. .. py:method:: unload() -> None :async: Cache known exit nodes. .. py:method:: get_lookup_info_hash(info_hash: bytes) -> bytes Get the SHA-1 hash to lookup for a given torrent info hash.