Function connect_proxy

Source
pub async fn connect_proxy<A: ToSocketAddrs + Clone + Debug>(
    proxy_addr: A,
    address: LocalAddress,
    network: Network,
    allow_v1_fallback: bool,
) -> Result<(ReadTransport<BufReader<ReadHalf<TcpStream>>>, WriteTransport<WriteHalf<TcpStream>>, TransportProtocol), TransportError>
Expand description

Establishes a connection through a SOCKS5 proxy and negotiates the bitcoin protocol.

This function connects to a SOCKS5 proxy, establishes a connection to the target address through the proxy, and then negotiates the bitcoin protocol. Like connect, it first tries the V2 protocol and can fall back to V1 if needed and allowed.

§Arguments

  • proxy_addr - The address of the SOCKS5 proxy
  • address - The target address to connect to through the proxy
  • port - The port to connect to on the target
  • network - The bitcoin network
  • allow_v1_fallback - Whether to allow fallback to V1 protocol if V2 negotiation fails

§Returns

Returns a tuple of read and write transports that can be used to communicate with the node.

§Errors

Returns a TransportError if the proxy connection cannot be established, the connection to the target fails, or protocol negotiation fails.