Skip to main content

connect

Function connect 

Source
pub async fn connect(
    stream: BoxStream,
    target: &Target,
    username: Option<&str>,
    password: Option<&str>,
    proxy_addr: IpAddr,
) -> Result<BoxStream>
Expand description

Connect through an HTTPS CONNECT proxy.

  1. Wraps stream in a TLS session directed at the proxy (cert validation skipped).
  2. Sends an HTTP CONNECT target HTTP/1.0 request over the TLS channel.
  3. Returns the TLS stream positioned after the proxy’s 200 response, ready to relay tunnel traffic.

§Arguments

  • stream — a connected TCP stream to the proxy’s HTTPS port.
  • target — the tunnel destination requested in the CONNECT line.
  • username / password — optional Proxy-Authorization: Basic credentials.
  • proxy_addr — the proxy’s IP address, used as the TLS SNI value.

§Errors

Returns an error if the TLS handshake or HTTP CONNECT negotiation fails.