latest.ipv8.messaging.anonymization.exit_socket

Module Contents

Classes

DataChecker

Class to verify that only IPv8-allowed traffic is being forwarded.

TunnelProtocol

Protocol used by TunnelExitSocket.

TunnelExitSocket

Socket for exit nodes that communicates with the outside world.

class latest.ipv8.messaging.anonymization.exit_socket.DataChecker

Class to verify that only IPv8-allowed traffic is being forwarded.

static could_be_utp(data: bytes) bool

Check if this data could be uTP (see also https://www.bittorrent.org/beps/bep_0029.html).

Packets should be 20 bytes or larger.

The type should be 0..4:
  • 0: ST_DATA

  • 1: ST_FIN

  • 2: ST_STATE

  • 3: ST_RESET

  • 4: ST_SYN

The version should be 1.

The extension should be 0..3:
  • 0: No extension

  • 1: Selective ACK

  • 2: Deprecated

  • 3: Close reason

static could_be_udp_tracker(data: bytes) bool

Check if the data could be a UDP-based tracker.

static could_be_dht(data: bytes) bool

Check if the data contain a bencoded dictionary.

static could_be_bt(data: bytes) bool

Check if the data could be any BitTorrent traffic.

static could_be_ipv8(data: bytes) bool

Check if the data is likely IPv8 overlay traffic.

class latest.ipv8.messaging.anonymization.exit_socket.TunnelProtocol(received_cb: Callable, local_addr: ipv8.types.Address)

Bases: asyncio.DatagramProtocol

Protocol used by TunnelExitSocket.

async open() asyncio.DatagramTransport

Opens a datagram endpoint and returns the Transport.

datagram_received(data: bytes, addr: ipv8.types.Address) None

Callback for when data is received by the socket.

class latest.ipv8.messaging.anonymization.exit_socket.TunnelExitSocket(circuit_id: int, hop: latest.ipv8.messaging.anonymization.tunnel.Hop, overlay: ipv8.messaging.anonymization.community.TunnelCommunity)

Bases: latest.ipv8.messaging.anonymization.tunnel.RoutingObject, latest.ipv8.taskmanager.TaskManager

Socket for exit nodes that communicates with the outside world.

enable() None

Allow data to be sent.

This creates the datagram endpoints that allows us to send messages.

sendto(data: bytes, destination: ipv8.types.Address) None

Send o message over our datagram transporter.

async resolve(address: ipv8.types.Address) ipv8.types.Address

Using asyncio’s getaddrinfo since the aiodns resolver seems to have issues. Returns [(family, type, proto, canonname, sockaddr)].

datagram_received_ipv4(data: bytes, source: ipv8.types.Address) None

Callback for when data is received by the IPv4 socket.

datagram_received_ipv6(data: bytes, source: ipv8.types.Address) None

Callback for when data is received by the IPv6 socket.

datagram_received(data: bytes, source: ipv8.types.Address) None

Callback for when data is received by a IPv4/IPv6 socket.

is_allowed(data: bytes) bool

Check if the captured data is not malicious junk.

tunnel_data(source: ipv8.types.Address, data: bytes) None

Send data back over the tunnel that we are exiting for.

async close() None

Closes the UDP socket if enabled and cancels all pending tasks.

Returns:

A deferred that fires once the UDP socket has closed.