3.0.ipv8.messaging.anonymization.exit_socket ============================================ .. py:module:: 3.0.ipv8.messaging.anonymization.exit_socket Classes ------- .. autoapisummary:: 3.0.ipv8.messaging.anonymization.exit_socket.DataChecker 3.0.ipv8.messaging.anonymization.exit_socket.TunnelProtocol 3.0.ipv8.messaging.anonymization.exit_socket.TunnelExitSocket Module Contents --------------- .. py:class:: DataChecker Class to verify that only IPv8-allowed traffic is being forwarded. .. py:method:: could_be_utp(data: bytes) -> bool :staticmethod: 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 .. py:method:: could_be_udp_tracker(data: bytes) -> bool :staticmethod: Check if the data could be a UDP-based tracker. .. py:method:: could_be_dht(data: bytes) -> bool :staticmethod: Check if the data contain a bencoded dictionary. .. py:method:: could_be_bt(data: bytes) -> bool :staticmethod: Check if the data could be any BitTorrent traffic. .. py:method:: could_be_ipv8(data: bytes) -> bool :staticmethod: Check if the data is likely IPv8 overlay traffic. .. py:class:: TunnelProtocol(received_cb: Callable, local_addr: ipv8.types.Address) Bases: :py:obj:`asyncio.DatagramProtocol` Protocol used by TunnelExitSocket. .. py:attribute:: received_cb .. py:attribute:: local_addr .. py:attribute:: logger .. py:method:: open() -> asyncio.DatagramTransport :async: Opens a datagram endpoint and returns the Transport. .. py:method:: datagram_received(data: bytes, addr: ipv8.types.Address) -> None Callback for when data is received by the socket. .. py:class:: TunnelExitSocket(circuit_id: int, hop: 3.0.ipv8.messaging.anonymization.tunnel.Hop, overlay: ipv8.messaging.anonymization.community.TunnelCommunity) Bases: :py:obj:`3.0.ipv8.messaging.anonymization.tunnel.RoutingObject`, :py:obj:`3.0.ipv8.taskmanager.TaskManager` Socket for exit nodes that communicates with the outside world. .. py:attribute:: hop .. py:attribute:: overlay .. py:attribute:: transport_ipv4 :type: asyncio.DatagramTransport | None :value: None .. py:attribute:: transport_ipv6 :type: asyncio.DatagramTransport | None :value: None .. py:attribute:: queue :type: collections.deque[tuple[bytes, ipv8.types.Address]] .. py:attribute:: enabled :value: False .. py:method:: enable() -> None Allow data to be sent. This creates the datagram endpoints that allows us to send messages. .. py:method:: sendto(data: bytes, destination: ipv8.types.Address) -> None Send o message over our datagram transporter. .. py:method:: resolve(address: ipv8.types.Address) -> ipv8.types.Address :async: Using asyncio's getaddrinfo since the aiodns resolver seems to have issues. Returns [(family, type, proto, canonname, sockaddr)]. .. py:method:: datagram_received_ipv4(data: bytes, source: ipv8.types.Address) -> None Callback for when data is received by the IPv4 socket. .. py:method:: datagram_received_ipv6(data: bytes, source: ipv8.types.Address) -> None Callback for when data is received by the IPv6 socket. .. py:method:: datagram_received(data: bytes, source: ipv8.types.Address) -> None Callback for when data is received by a IPv4/IPv6 socket. .. py:method:: is_allowed(data: bytes) -> bool Check if the captured data is not malicious junk. .. py:method:: tunnel_data(source: ipv8.types.Address, data: bytes) -> None Send data back over the tunnel that we are exiting for. .. py:method:: close() -> None :async: Closes the UDP socket if enabled and cancels all pending tasks. :return: A deferred that fires once the UDP socket has closed.