3.0.ipv8.messaging.anonymization.tunnel ======================================= .. py:module:: 3.0.ipv8.messaging.anonymization.tunnel Attributes ---------- .. autoapisummary:: 3.0.ipv8.messaging.anonymization.tunnel.FORWARD 3.0.ipv8.messaging.anonymization.tunnel.BACKWARD 3.0.ipv8.messaging.anonymization.tunnel.PEER_SOURCE_UNKNOWN 3.0.ipv8.messaging.anonymization.tunnel.PEER_SOURCE_DHT 3.0.ipv8.messaging.anonymization.tunnel.PEER_SOURCE_PEX 3.0.ipv8.messaging.anonymization.tunnel.PEER_FLAG_RELAY 3.0.ipv8.messaging.anonymization.tunnel.PEER_FLAG_EXIT_BT 3.0.ipv8.messaging.anonymization.tunnel.PEER_FLAG_EXIT_IPV8 3.0.ipv8.messaging.anonymization.tunnel.PEER_FLAG_SPEED_TEST 3.0.ipv8.messaging.anonymization.tunnel.CIRCUIT_TYPE_DATA 3.0.ipv8.messaging.anonymization.tunnel.CIRCUIT_TYPE_IP_SEEDER 3.0.ipv8.messaging.anonymization.tunnel.CIRCUIT_TYPE_RP_SEEDER 3.0.ipv8.messaging.anonymization.tunnel.CIRCUIT_TYPE_RP_DOWNLOADER 3.0.ipv8.messaging.anonymization.tunnel.CIRCUIT_STATE_READY 3.0.ipv8.messaging.anonymization.tunnel.CIRCUIT_STATE_EXTENDING 3.0.ipv8.messaging.anonymization.tunnel.CIRCUIT_STATE_CLOSING 3.0.ipv8.messaging.anonymization.tunnel.CIRCUIT_ID_PORT 3.0.ipv8.messaging.anonymization.tunnel.PING_INTERVAL 3.0.ipv8.messaging.anonymization.tunnel.DESTROY_REASON_UNKNOWN 3.0.ipv8.messaging.anonymization.tunnel.DESTROY_REASON_SHUTDOWN 3.0.ipv8.messaging.anonymization.tunnel.DESTROY_REASON_UNNEEDED Classes ------- .. autoapisummary:: 3.0.ipv8.messaging.anonymization.tunnel.Hop 3.0.ipv8.messaging.anonymization.tunnel.RoutingObject 3.0.ipv8.messaging.anonymization.tunnel.Circuit 3.0.ipv8.messaging.anonymization.tunnel.RelayRoute 3.0.ipv8.messaging.anonymization.tunnel.RendezvousPoint 3.0.ipv8.messaging.anonymization.tunnel.IntroductionPoint 3.0.ipv8.messaging.anonymization.tunnel.Swarm Module Contents --------------- .. py:data:: FORWARD :value: 0 .. py:data:: BACKWARD :value: 1 .. py:data:: PEER_SOURCE_UNKNOWN :value: 0 .. py:data:: PEER_SOURCE_DHT :value: 1 .. py:data:: PEER_SOURCE_PEX :value: 2 .. py:data:: PEER_FLAG_RELAY :value: 1 .. py:data:: PEER_FLAG_EXIT_BT :value: 2 .. py:data:: PEER_FLAG_EXIT_IPV8 :value: 4 .. py:data:: PEER_FLAG_SPEED_TEST :value: 8 .. py:data:: CIRCUIT_TYPE_DATA :value: 'DATA' .. py:data:: CIRCUIT_TYPE_IP_SEEDER :value: 'IP_SEEDER' .. py:data:: CIRCUIT_TYPE_RP_SEEDER :value: 'RP_SEEDER' .. py:data:: CIRCUIT_TYPE_RP_DOWNLOADER :value: 'RP_DOWNLOADER' .. py:data:: CIRCUIT_STATE_READY :value: 'READY' .. py:data:: CIRCUIT_STATE_EXTENDING :value: 'EXTENDING' .. py:data:: CIRCUIT_STATE_CLOSING :value: 'CLOSING' .. py:data:: CIRCUIT_ID_PORT :value: 1024 .. py:data:: PING_INTERVAL :value: 7.5 .. py:data:: DESTROY_REASON_UNKNOWN :value: 1 .. py:data:: DESTROY_REASON_SHUTDOWN :value: 2 .. py:data:: DESTROY_REASON_UNNEEDED :value: 4 .. py:class:: Hop Hop contains all information needed to add/remove a single layer of onion encryption and send it to the next target. .. py:attribute:: peer :type: 3.0.ipv8.peer.Peer .. py:attribute:: keys :type: 3.0.ipv8.messaging.anonymization.crypto.SessionKeys | None :value: None .. py:attribute:: flags :type: list[int] | None :value: None .. py:attribute:: dh_first_part :type: 3.0.ipv8.keyvault.public.libnaclkey.LibNaCLPK | None :value: None .. py:attribute:: dh_secret :type: 3.0.ipv8.keyvault.private.libnaclkey.LibNaCLSK | None :value: None .. py:property:: address :type: 3.0.ipv8.types.Address Get the address of this hop. .. py:property:: public_key :type: 3.0.ipv8.keyvault.public.libnaclkey.LibNaCLPK Get the public key instance of the hop. .. py:property:: public_key_bin :type: bytes The hop's public_key bytes. .. py:property:: mid :type: bytes Get the SHA-1 of the hop's public key. .. py:class:: RoutingObject(circuit_id: int) Statistics for a tunnel to a peer over a circuit (base class for circuits, exit sockets, and relay routes). .. py:attribute:: circuit_id .. py:attribute:: creation_time .. py:attribute:: last_activity .. py:attribute:: logger .. py:method:: beat_heart() -> None Notify this object that the tunnel was active. .. py:class:: Circuit(circuit_id: int, goal_hops: int = 0, ctype: str = CIRCUIT_TYPE_DATA, required_exit: 3.0.ipv8.peer.Peer | None = None, info_hash: bytes | None = None) Bases: :py:obj:`RoutingObject` A peer-to-peer encrypted communication channel, consisting of 0 or more hops (intermediate peers). .. py:attribute:: goal_hops .. py:attribute:: ctype .. py:attribute:: required_exit .. py:attribute:: info_hash .. py:attribute:: ready :type: asyncio.Future[Circuit | None] .. py:attribute:: closing_info :value: '' .. py:attribute:: _closing :value: False .. py:attribute:: _hops :type: list[Hop] :value: [] .. py:attribute:: unverified_hop :type: Hop | None :value: None .. py:attribute:: _hs_session_keys :type: 3.0.ipv8.messaging.anonymization.crypto.SessionKeys | None :value: None .. py:attribute:: e2e :value: False .. py:attribute:: relay_early_count :value: 0 .. py:attribute:: dirty :value: False .. py:method:: add_hop(hop: Hop) -> None Adds a hop to the circuits hop collection. .. py:property:: hs_session_keys :type: 3.0.ipv8.messaging.anonymization.crypto.SessionKeys | None Get the session keys for hidden services (if any). .. py:property:: hop :type: Hop Return the first hop of the circuit. .. py:property:: hops :type: collections.abc.Sequence[Hop] Return a read only tuple version of the hop-list of this circuit. .. py:property:: exit_flags :type: list[int] Get the flags of the last hop in our circuit. .. py:property:: state :type: str The circuit state. This can be either: - CIRCUIT_STATE_CLOSING - CIRCUIT_STATE_EXTENDING - CIRCUIT_STATE_READY .. py:method:: close(closing_info: str = '') -> None Sets the state of the circuit to CIRCUIT_STATE_CLOSING. This ensures that this circuit will not be used to contact new peers. .. py:class:: RelayRoute(circuit_id: int, hop: Hop, direction: int, rendezvous_relay: bool = False) Bases: :py:obj:`RoutingObject` Relay object containing the destination circuit, socket address and whether it is online or not. .. py:attribute:: hop .. py:attribute:: direction .. py:attribute:: rendezvous_relay .. py:attribute:: relay_early_count :value: 1 .. py:class:: RendezvousPoint(circuit: Circuit, cookie: bytes) Rendezvous for circuits to link up. .. py:attribute:: circuit .. py:attribute:: cookie .. py:attribute:: address :type: 3.0.ipv8.types.Address | None :value: None .. py:attribute:: ready :type: asyncio.Future[RendezvousPoint | None] .. py:class:: IntroductionPoint(peer: 3.0.ipv8.peer.Peer, seeder_pk: bytes, source: int = PEER_SOURCE_UNKNOWN, last_seen: float | None = None) A point of introduction, available for linking up. .. py:attribute:: peer .. py:attribute:: seeder_pk .. py:attribute:: source .. py:attribute:: last_seen .. py:method:: __eq__(other: object) -> bool Check if another object is equal to this intro point. .. py:method:: __hash__() -> int Each intro point is unique to its peer and seeder's public key. .. py:method:: to_dict() -> dict[str, dict[str, str | int] | str | int] Convert this intro point to a flat dict. .. py:class:: Swarm(info_hash: bytes, hops: int, lookup_func: Callable[[bytes, IntroductionPoint | None, int], asyncio.Future[list[IntroductionPoint]]], seeder_sk: 3.0.ipv8.keyvault.private.libnaclkey.LibNaCLSK | None = None, max_ip_age: float = 180.0, min_dht_lookup_interval: float = 300.0, max_dht_lookup_interval: float = 120.0) A group of circuit exits that organizes around an SHA-1. .. py:attribute:: info_hash .. py:attribute:: hops .. py:attribute:: lookup_func .. py:attribute:: seeder_sk .. py:attribute:: max_ip_age .. py:attribute:: min_dht_lookup_interval .. py:attribute:: max_dht_lookup_interval .. py:attribute:: intro_points :type: list[IntroductionPoint] :value: [] .. py:attribute:: connections :type: dict[int, tuple[Circuit, IntroductionPoint]] .. py:attribute:: last_lookup :type: float :value: 0 .. py:attribute:: last_dht_response :type: float :value: 0 .. py:attribute:: transfer_history :value: [0, 0] .. py:attribute:: logger .. py:property:: seeding :type: bool Whether we are seeding data in this swarm. .. py:property:: _active_circuits :type: list[Circuit] .. py:method:: add_connection(rp_circuit: Circuit, intro_point_used: IntroductionPoint) -> None Add a newly known circuit to this swarm. .. py:method:: remove_connection(rp_circuit: Circuit) -> bool Remove the given circuit from this swarm, if we manage it. This does not close the circuit. .. py:method:: has_connection(seeder_pk: bytes) -> bool Check if the given public key is in the swarm. .. py:method:: get_num_connections() -> int Get the number of circuits we have in this swarm. .. py:method:: get_num_connections_incomplete() -> int Get the number of circuits we don't have yet, but know of, in this swarm. .. py:method:: add_intro_point(ip: IntroductionPoint) -> IntroductionPoint Add an available introduction point to this swarm. Returns the introduction point we should use (not necessarily the one we just added). .. py:method:: remove_old_intro_points() -> None Cleanup old introduction points. .. py:method:: remove_intro_point(ip: IntroductionPoint) -> None Remove the given introduction point from this swarm. .. py:method:: lookup(target: IntroductionPoint | None = None) -> list[IntroductionPoint] | None :async: Lookup introduction points, possibly those that match the given introduction point. .. py:method:: get_num_seeders() -> int Get the number of different seeder public keys in this swarm. .. py:method:: get_total_up() -> int Get the total number of bytes uploaded in this swarm. .. py:method:: get_total_down() -> int Get the total number of bytes downloaded from this swarm.