Skip to main content

tunnel_via_proxy

Function tunnel_via_proxy 

Source
pub async fn tunnel_via_proxy(
    target: &WsTarget,
    proxy: &ProxyTarget,
) -> Result<ProxiedStream, TransportError>
Expand description

Establish a tunneled connection through proxy to the WebSocket target.

On success the returned stream is positioned right after the proxy’s 200/2xx response, ready for the WebSocket handshake. The function does not perform the WebSocket handshake itself; callers wrap the stream in tokio-tungstenite::client_async.

§Errors

Returns a TransportError when:

  • The TCP connection to the proxy fails (TransportError::Io).
  • The TLS layer to the proxy or upstream cannot be established (TransportError::Tls).
  • The proxy returns a non-success status, malformed headers, or closes the stream before completing the response.