tribler.core.socks5.client ========================== .. py:module:: tribler.core.socks5.client Exceptions ---------- .. autoapisummary:: tribler.core.socks5.client.Socks5Error Classes ------- .. autoapisummary:: tribler.core.socks5.client.Socks5ClientUDPConnection tribler.core.socks5.client.Socks5Client Module Contents --------------- .. py:exception:: Socks5Error Bases: :py:obj:`Exception` Errors with the SOCKS5 protocol. .. py:class:: Socks5ClientUDPConnection(callback: collections.abc.Callable[[bytes, ipv8.messaging.interfaces.udp.endpoint.DomainAddress | tuple], None]) Bases: :py:obj:`asyncio.DatagramProtocol` A datagram protocol for Socks5 connections. .. py:attribute:: callback .. py:attribute:: transport :type: asyncio.DatagramTransport | None :value: None .. py:attribute:: proxy_udp_addr :type: ipv8.messaging.interfaces.udp.endpoint.DomainAddress | ipv8.messaging.interfaces.udp.endpoint.UDPv4Address | None :value: None .. py:attribute:: logger .. py:method:: connection_made(transport: asyncio.BaseTransport) -> None Callback for when a transport is available. .. py:method:: datagram_received(data: bytes, _: tuple) -> None Callback for when data is received over our transport. .. py:method:: sendto(data: bytes, target_addr: ipv8.messaging.interfaces.udp.endpoint.DomainAddress | tuple) -> None Attempt to send the given data to the given address. .. py:class:: Socks5Client(proxy_addr: tuple, callback: collections.abc.Callable[[bytes, ipv8.messaging.interfaces.udp.endpoint.DomainAddress | tuple], None]) Bases: :py:obj:`asyncio.Protocol` This object represents a minimal Socks5 client. Both TCP and UDP are supported. .. py:attribute:: proxy_addr .. py:attribute:: callback .. py:attribute:: transport :type: asyncio.WriteTransport | None :value: None .. py:attribute:: connection :type: Socks5ClientUDPConnection | None :value: None .. py:attribute:: connected_to :type: ipv8.messaging.interfaces.udp.endpoint.DomainAddress | tuple | None :value: None .. py:attribute:: queue :type: asyncio.Queue[bytes] .. py:method:: data_received(data: bytes) -> None Callback for when data comes in. Call our registered callback or save the incoming save for calling back later. .. py:method:: connection_lost(_: Exception | None) -> None Callback for when the connection is dropped. .. py:method:: _send(data: bytes) -> bytes :async: Send data to the remote and wait for an answer. .. py:method:: _login() -> None :async: Send a login. :raises Socks5Error: If the proxy server is unsupported. .. py:method:: _associate_udp(local_addr: tuple | None = None) -> None :async: Send an associate request to the connection. .. py:method:: _connect_tcp(target_addr: tuple) -> None :async: Connect to the given address using TCP. .. py:property:: connected :type: bool Whether this client is connected over TCP. .. py:property:: associated :type: bool Whether this client is associated over UDP. .. py:method:: associate_udp() -> None :async: Login and associate with the proxy. .. py:method:: sendto(data: bytes, target_addr: tuple) -> None Attemp to send data to the given address. :raises Socks5Error: If we have not associated UDP yet. .. py:method:: connect_tcp(target_addr: tuple) -> None :async: Login and connect to the proxy using TCP. :raises Socks5Error: If we have not associated UDP yet. .. py:method:: write(data: bytes) -> None Write to whatever transport we have.