latest.ipv8.messaging.anonymization.tunnel

Module Contents

Classes

Hop

Hop contains all information needed to add/remove a single layer of

RoutingObject

Statistics for a tunnel to a peer over a circuit (base class for circuits, exit sockets, and relay routes).

Circuit

A peer-to-peer encrypted communication channel, consisting of 0 or more hops (intermediate peers).

RelayRoute

Relay object containing the destination circuit, socket address and whether it is online or not.

RendezvousPoint

Rendezvous for circuits to link up.

IntroductionPoint

A point of introduction, available for linking up.

Swarm

A group of circuit exits that organizes around an SHA-1.

Attributes

FORWARD

BACKWARD

PEER_SOURCE_UNKNOWN

PEER_SOURCE_DHT

PEER_SOURCE_PEX

PEER_FLAG_RELAY

PEER_FLAG_EXIT_BT

PEER_FLAG_EXIT_IPV8

PEER_FLAG_SPEED_TEST

CIRCUIT_TYPE_DATA

CIRCUIT_TYPE_IP_SEEDER

CIRCUIT_TYPE_RP_SEEDER

CIRCUIT_TYPE_RP_DOWNLOADER

CIRCUIT_STATE_READY

CIRCUIT_STATE_EXTENDING

CIRCUIT_STATE_CLOSING

CIRCUIT_ID_PORT

PING_INTERVAL

DESTROY_REASON_UNKNOWN

DESTROY_REASON_SHUTDOWN

DESTROY_REASON_UNNEEDED

latest.ipv8.messaging.anonymization.tunnel.FORWARD = 0
latest.ipv8.messaging.anonymization.tunnel.BACKWARD = 1
latest.ipv8.messaging.anonymization.tunnel.PEER_SOURCE_UNKNOWN = 0
latest.ipv8.messaging.anonymization.tunnel.PEER_SOURCE_DHT = 1
latest.ipv8.messaging.anonymization.tunnel.PEER_SOURCE_PEX = 2
latest.ipv8.messaging.anonymization.tunnel.PEER_FLAG_RELAY = 1
latest.ipv8.messaging.anonymization.tunnel.PEER_FLAG_EXIT_BT = 2
latest.ipv8.messaging.anonymization.tunnel.PEER_FLAG_EXIT_IPV8 = 4
latest.ipv8.messaging.anonymization.tunnel.PEER_FLAG_SPEED_TEST = 8
latest.ipv8.messaging.anonymization.tunnel.CIRCUIT_TYPE_DATA = 'DATA'
latest.ipv8.messaging.anonymization.tunnel.CIRCUIT_TYPE_IP_SEEDER = 'IP_SEEDER'
latest.ipv8.messaging.anonymization.tunnel.CIRCUIT_TYPE_RP_SEEDER = 'RP_SEEDER'
latest.ipv8.messaging.anonymization.tunnel.CIRCUIT_TYPE_RP_DOWNLOADER = 'RP_DOWNLOADER'
latest.ipv8.messaging.anonymization.tunnel.CIRCUIT_STATE_READY = 'READY'
latest.ipv8.messaging.anonymization.tunnel.CIRCUIT_STATE_EXTENDING = 'EXTENDING'
latest.ipv8.messaging.anonymization.tunnel.CIRCUIT_STATE_CLOSING = 'CLOSING'
latest.ipv8.messaging.anonymization.tunnel.CIRCUIT_ID_PORT = 1024
latest.ipv8.messaging.anonymization.tunnel.PING_INTERVAL = 7.5
latest.ipv8.messaging.anonymization.tunnel.DESTROY_REASON_UNKNOWN = 1
latest.ipv8.messaging.anonymization.tunnel.DESTROY_REASON_SHUTDOWN = 2
latest.ipv8.messaging.anonymization.tunnel.DESTROY_REASON_UNNEEDED = 4
class latest.ipv8.messaging.anonymization.tunnel.Hop

Hop contains all information needed to add/remove a single layer of onion encryption and send it to the next target.

property address: latest.ipv8.types.Address

Get the address of this hop.

property public_key: latest.ipv8.keyvault.public.libnaclkey.LibNaCLPK

Get the public key instance of the hop.

property public_key_bin: bytes

The hop’s public_key bytes.

property mid: bytes

Get the SHA-1 of the hop’s public key.

peer: latest.ipv8.peer.Peer
keys: latest.ipv8.messaging.anonymization.crypto.SessionKeys | None
flags: list[int] | None
dh_first_part: latest.ipv8.keyvault.public.libnaclkey.LibNaCLPK | None
dh_secret: latest.ipv8.keyvault.private.libnaclkey.LibNaCLSK | None
class latest.ipv8.messaging.anonymization.tunnel.RoutingObject(circuit_id: int)

Statistics for a tunnel to a peer over a circuit (base class for circuits, exit sockets, and relay routes).

beat_heart() None

Notify this object that the tunnel was active.

class latest.ipv8.messaging.anonymization.tunnel.Circuit(circuit_id: int, goal_hops: int = 0, ctype: str = CIRCUIT_TYPE_DATA, required_exit: latest.ipv8.peer.Peer | None = None, info_hash: bytes | None = None)

Bases: RoutingObject

A peer-to-peer encrypted communication channel, consisting of 0 or more hops (intermediate peers).

property hs_session_keys: latest.ipv8.messaging.anonymization.crypto.SessionKeys | None

Get the session keys for hidden services (if any).

property hop: Hop

Return the first hop of the circuit.

property hops: Sequence[Hop]

Return a read only tuple version of the hop-list of this circuit.

property exit_flags: list[int]

Get the flags of the last hop in our circuit.

property state: str

The circuit state.

This can be either:
  • CIRCUIT_STATE_CLOSING

  • CIRCUIT_STATE_EXTENDING

  • CIRCUIT_STATE_READY

add_hop(hop: Hop) None

Adds a hop to the circuits hop collection.

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.

class latest.ipv8.messaging.anonymization.tunnel.RelayRoute(circuit_id: int, hop: Hop, direction: int, rendezvous_relay: bool = False)

Bases: RoutingObject

Relay object containing the destination circuit, socket address and whether it is online or not.

class latest.ipv8.messaging.anonymization.tunnel.RendezvousPoint(circuit: Circuit, cookie: bytes)

Rendezvous for circuits to link up.

class latest.ipv8.messaging.anonymization.tunnel.IntroductionPoint(peer: latest.ipv8.peer.Peer, seeder_pk: bytes, source: int = PEER_SOURCE_UNKNOWN, last_seen: float | None = None)

A point of introduction, available for linking up.

__eq__(other: object) bool

Check if another object is equal to this intro point.

__hash__() int

Each intro point is unique to its peer and seeder’s public key.

to_dict() dict[str, dict[str, str | int] | str | int]

Convert this intro point to a flat dict.

class latest.ipv8.messaging.anonymization.tunnel.Swarm(info_hash: bytes, hops: int, lookup_func: Callable[[bytes, IntroductionPoint | None, int], asyncio.Future[list[IntroductionPoint]]], seeder_sk: latest.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.

property seeding: bool

Whether we are seeding data in this swarm.

property _active_circuits: list[Circuit]
add_connection(rp_circuit: Circuit, intro_point_used: IntroductionPoint) None

Add a newly known circuit to this swarm.

remove_connection(rp_circuit: Circuit) bool

Remove the given circuit from this swarm, if we manage it.

This does not close the circuit.

has_connection(seeder_pk: bytes) bool

Check if the given public key is in the swarm.

get_num_connections() int

Get the number of circuits we have in this swarm.

get_num_connections_incomplete() int

Get the number of circuits we don’t have yet, but know of, in this swarm.

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

remove_old_intro_points() None

Cleanup old introduction points.

remove_intro_point(ip: IntroductionPoint) None

Remove the given introduction point from this swarm.

async lookup(target: IntroductionPoint | None = None) list[IntroductionPoint] | None

Lookup introduction points, possibly those that match the given introduction point.

get_num_seeders() int

Get the number of different seeder public keys in this swarm.

get_total_up() int

Get the total number of bytes uploaded in this swarm.

get_total_down() int

Get the total number of bytes downloaded from this swarm.