tribler.core.tunnel.community

Attributes

DESTROY_REASON_BALANCE

PEER_FLAG_EXIT_HTTP

PEER_FLAG_EXIT_BACKUP

MAX_HTTP_PACKET_SIZE

Classes

TriblerTunnelSettings

Settings for Tribler's tunnel community.

TriblerTunnelCommunity

This community is built upon the anonymous messaging layer in IPv8.

Functions

is_bencoded(→ bool)

Returns True is x appears to be valid bencoded byte string.

Module Contents

tribler.core.tunnel.community.DESTROY_REASON_BALANCE = 65535
tribler.core.tunnel.community.PEER_FLAG_EXIT_HTTP = 32768
tribler.core.tunnel.community.PEER_FLAG_EXIT_BACKUP = 16384
tribler.core.tunnel.community.MAX_HTTP_PACKET_SIZE = 1400
tribler.core.tunnel.community.is_bencoded(x: bytes) bool

Returns True is x appears to be valid bencoded byte string.

class tribler.core.tunnel.community.TriblerTunnelSettings

Bases: ipv8.messaging.anonymization.hidden_services.HiddenTunnelSettings

Settings for Tribler’s tunnel community.

exitnode_cache: pathlib.Path | None = None
notifier: tribler.core.notifier.Notifier
download_manager: tribler.core.libtorrent.download_manager.download_manager.DownloadManager
exitnode_enabled: bool = False
default_hops: int = 0
max_intro_points: int = 10
class tribler.core.tunnel.community.TriblerTunnelCommunity(settings: TriblerTunnelSettings)

Bases: ipv8.messaging.anonymization.hidden_services.HiddenTunnelCommunity

This community is built upon the anonymous messaging layer in IPv8. It adds support for libtorrent anonymous downloads.

community_id
settings_class
bittorrent_peers: dict[tribler.core.libtorrent.download_manager.download.Download, set[tuple[str, int]]]
download_states: dict[bytes, tribler.core.libtorrent.download_manager.download_state.DownloadStatus]
last_forced_announce: dict[bytes, float]
async _poll_download_manager() None

Get the latest download states from the download manager.

cache_exitnodes_to_disk() None

Write a copy of the exit_candidates to the file self.settings.exitnode_cache.

restore_exitnodes_from_disk() None

Send introduction requests to peers stored in the file self.settings.exitnode_cache.

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.

async should_join_circuit(create_payload: ipv8.messaging.anonymization.payload.CreatePayload, previous_node_address: ipv8.messaging.interfaces.udp.endpoint.Address) bool

Check whether we should join a circuit. Returns a future that fires with a boolean.

readd_bittorrent_peers() None

Add the special IPs that belong to circuits to a download.

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.

async remove_circuit(circuit_id: int, additional_info: str = '', remove_now: bool = False, destroy: bool | int = False) None

Remove the circuit that belongs to the given circuit id.

async remove_relay(circuit_id: int, additional_info: str = '', remove_now: bool = False, destroy: bool = False) None

Callback for when a relay is removed.

async remove_exit_socket(circuit_id: int, additional_info: str = '', remove_now: bool = False, destroy: bool = False) ipv8.messaging.anonymization.exit_socket.TunnelExitSocket | None

Remove the exit socket that belongs to the given circuit id.

_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.

on_raw_data(circuit: ipv8.messaging.anonymization.tunnel.Circuit, origin: tuple[str, int], data: bytes) None

We have incoming data.

monitor_downloads(dslist: list[tribler.core.libtorrent.download_manager.download_state.DownloadState]) None

Periodically check the Tribler downloads for state changes.

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.

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.

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).

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.

async create_introduction_point(info_hash: bytes, required_ip: ipv8.peer.Peer | None = None) None

Start creating an introduction point.

async unload() None

Cache known exit nodes.

get_lookup_info_hash(info_hash: bytes) bytes

Get the SHA-1 hash to lookup for a given torrent info hash.