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,
    skip_verify: bool,
) -> Result<BoxStream>
Expand description

Connect through an HTTPS CONNECT proxy.

  1. Wraps stream in a TLS session to the proxy.
  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.
  • skip_verify — when true, certificate validation is skipped entirely (equivalent to https_insecure proxy type). When false, the system CA store is used and the connection fails if the certificate is untrusted.

§Errors

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