3.0.ipv8.messaging.anonymization.hidden_services ================================================ .. py:module:: 3.0.ipv8.messaging.anonymization.hidden_services .. autoapi-nested-parse:: The hidden tunnel community. Author(s): Egbert Bouman Classes ------- .. autoapisummary:: 3.0.ipv8.messaging.anonymization.hidden_services.HiddenTunnelSettings 3.0.ipv8.messaging.anonymization.hidden_services.HiddenTunnelCommunity Module Contents --------------- .. py:class:: HiddenTunnelSettings Bases: :py:obj:`3.0.ipv8.messaging.anonymization.community.TunnelSettings` Settings for the hidden tunnel community. .. py:attribute:: ipv8 :type: 3.0.ipv8.types.IPv8 | None :value: None .. py:attribute:: e2e_callbacks :type: dict[bytes, Callable[[Address], None] | None] | None :value: None .. py:class:: HiddenTunnelCommunity(settings: HiddenTunnelSettings) Bases: :py:obj:`3.0.ipv8.messaging.anonymization.community.TunnelCommunity` Extension of TunnelCommunity logic to link up circuits and create closed-loop e2e circuits. .. py:attribute:: settings_class .. py:attribute:: ipv8 .. py:attribute:: e2e_callbacks :type: dict[bytes, Callable[[Address], None] | None] .. py:attribute:: swarms :type: dict[bytes, 3.0.ipv8.messaging.anonymization.tunnel.Swarm] .. py:attribute:: pex :type: dict[bytes, 3.0.ipv8.messaging.anonymization.pex.PexCommunity] .. py:attribute:: intro_point_for :type: dict[bytes, tuple[3.0.ipv8.messaging.anonymization.exit_socket.TunnelExitSocket, bytes]] .. py:attribute:: rendezvous_point_for :type: dict[bytes, 3.0.ipv8.messaging.anonymization.exit_socket.TunnelExitSocket] .. py:method:: join_swarm(info_hash: bytes, hops: int, callback: Callable[[Address], None] | None = None, seeding: bool = True) -> None Join a hidden swarm. This should be called by both the downloader and the seeder. Calling this method while already part of the swarm will cause the community to drop all pre-existing connections. Note that the seeder should also create introduction points by calling create_introduction_point(). :param info_hash: the swarm identifier :param hops: the amount of hops for our introduction/rendezvous circuits :param callback: the callback function to call when we have established an e2e circuit :param seeding: whether the swarm should be joined as seeder .. py:method:: leave_swarm(info_hash: bytes) -> None Leave a hidden swarm. Can be called by both the downloader and the seeder. :param info_hash: the swarm identifier .. py:method:: estimate_swarm_size(info_hash: bytes, hops: int = 1, max_requests: int = 10) -> int :async: Estimate the number of unique seeders that are part of a hidden swarm. :param info_hash: the swarm identifier :param hops: the amount of hops to use for contacting introduction points :param max_requests: the number of introduction points we should send a get-peers message to :return: number of unique seeders .. py:method:: select_circuit_for_infohash(info_hash: bytes) -> Circuit | None Get a circuit that connectes to the swarm of the given SHA-1 hash. .. py:method:: create_circuit_for_infohash(info_hash: bytes, ctype: str, exit_flags: set[int] | None = None, required_exit: 3.0.ipv8.peer.Peer | None = None) -> Circuit | None Create a circuit that connects to the swarm given by the SHA-1 (info) hash. .. py:method:: ip_to_circuit_id(ip_str: str) -> int Convert an IP to a (special) circuit id. .. py:method:: circuit_id_to_ip(circuit_id: int) -> str Convert an IP-embedded circuit id back to the original IP. .. py:method:: do_peer_discovery() -> None :async: Find peers in the swarms that we are a part of. .. py:method:: do_circuits() -> None Beyond normal circuit creation, make sure we have circuits for introduction points. .. py:method:: do_ping(exclude: list[int] | None = None) -> None Ping all circuits, except pending e2e circuits. .. py:method:: remove_circuit(circuit_id: int, additional_info: str = '', remove_now: bool = False, destroy: bool | int = False) -> collections.abc.Coroutine[Any, Any, None] Remove the given circuit and update any swarms it may be part of. .. py:method:: remove_exit_socket(circuit_id: int, additional_info: str = '', remove_now: bool = False, destroy: bool = False) -> collections.abc.Coroutine[Any, Any, 3.0.ipv8.messaging.anonymization.exit_socket.TunnelExitSocket | None] Remove the given exit circuit, remove associated rendezvous points and update any PEX communities it may be part of. .. py:method:: get_max_time(circuit_id: int) -> float Get the maximum time that a given circuit is allowed to exist. .. py:method:: tunnel_data(circuit: Circuit | 3.0.ipv8.messaging.anonymization.exit_socket.TunnelExitSocket, destination: Address, payload: VariablePayloadWID) -> None Send any serializable payload to the next hop in the circuit. .. py:method:: select_circuit(destination: Address | None, hops: int) -> Circuit | None Make sure that we select the right circuit when dealing with an e2e connection. .. py:method:: send_peers_request(info_hash: bytes, target: 3.0.ipv8.messaging.anonymization.tunnel.IntroductionPoint | None, hops: int) -> Future[list[3.0.ipv8.messaging.anonymization.tunnel.IntroductionPoint]] Attempt to find peers for a given SHA-1 (info) hash. .. py:method:: on_peers_request(source_address: Address, payload: PeersRequestPayload, circuit_id: int | None = None) -> None :async: Callback for when someone wants us to find peers for their circuit. .. py:method:: send_peers_response(target_addr: Address, request: PeersRequestPayload, intro_points: list[3.0.ipv8.messaging.anonymization.tunnel.IntroductionPoint], circuit_id: int | None) -> None Send a response with the peers that we found through the DHT. .. py:method:: on_peers_response(source_address: Address, payload: PeersResponsePayload, circuit_id: int | None) -> None Callback for when someone performed a DHT lookup for us. .. py:method:: create_e2e(info_hash: bytes, intro_point: 3.0.ipv8.messaging.anonymization.tunnel.IntroductionPoint) -> None Create an e2e bridge for the given SHA-1 (info) hash over the given introduction point. .. py:method:: on_create_e2e(source_address: Address, payload: CreateE2EPayload, circuit_id: int | None = None) -> None :async: Callback for when we receive a creation message for an e2e circuit. .. py:method:: create_created_e2e(rp: 3.0.ipv8.messaging.anonymization.tunnel.RendezvousPoint, source_address: Address, payload: CreateE2EPayload, circuit_id: int | None) -> None Callback for when we receive "create" or "created" payloads. .. py:method:: on_created_e2e(source_address: Address, payload: CreatedE2EPayload, circuit_id: int | None) -> None :async: Callback for when peers signal that they have created an e2e circuit. .. py:method:: on_link_e2e(source_address: Address, payload: LinkE2EPayload, circuit_id: int | None) -> None Callback for when an e2e circuit attempts to link up sender and receiver. .. py:method:: on_linked_e2e(source_address: Address, payload: LinkedE2EPayload, circuit_id: int | None) -> None Callback for when a sender and receiver circuit have been linked up. .. py:method:: create_introduction_point(info_hash: bytes, required_ip: 3.0.ipv8.peer.Peer | None = None) -> None :async: Create an introduction point for the given SHA-1 (info) hash. .. py:method:: on_establish_intro(source_address: Address, payload: EstablishIntroPayload, circuit_id: int | None) -> None Callback for when we are asked to be an introduction point. .. py:method:: on_intro_established(source_address: Address, payload: IntroEstablishedPayload, circuit_id: int | None) -> None Callback for when a peer signals that an introduction point has been created for us. .. py:method:: create_rendezvous_point(info_hash: bytes) -> 3.0.ipv8.messaging.anonymization.tunnel.RendezvousPoint | None :async: Create a new rendezvous point for the given SHA-1 (info) hash. .. py:method:: on_establish_rendezvous(source_address: Address, payload: EstablishRendezvousPayload, circuit_id: int | None) -> None Callback for when we are requested to be a rendezvous point. .. py:method:: on_rendezvous_established(source_address: Address, payload: RendezvousEstablishedPayload, circuit_id: int | None) -> None Callback for when a peer signals that they act as a rendezvous point for us. .. py:method:: dht_lookup(info_hash: bytes) -> tuple[bytes, list[3.0.ipv8.messaging.anonymization.tunnel.IntroductionPoint]] | None :async: Attempt to find introduction points for the given SHA-1 (info) hash. .. py:method:: dht_announce(info_hash: bytes, intro_point: 3.0.ipv8.messaging.anonymization.tunnel.IntroductionPoint) -> None :async: Announce ourselves as a candidate for the given SHA-1 (info) hash.