Expand description
Proxy support for outbound WebSocket connections.
Implements HTTP CONNECT tunneling so a WebSocketClient can be reached
through an HTTP or HTTPS forward proxy. The same proxy_url field is used
by the HTTP client (via reqwest::Proxy::all), keeping a single config
field for both transports.
socks5:// / socks5h:// URLs are recognized but not yet implemented
for the WebSocket path. The dispatcher logs a warning and falls back to
a direct connection so that REST configs that already point at a SOCKS
proxy keep working unchanged. SOCKS support requires the optional
tokio-socks crate, which is not yet a workspace dependency.
The tunnel is established as follows:
- TCP connect to the proxy host / port.
- If the proxy URL scheme is
https, layer TLS using the proxy host as the SNI and certificate domain. - Send
CONNECT target_host:target_port HTTP/1.1plus the matchingHost:header (and optionalProxy-Authorization:derived from the proxy URL user-info). - Read the response line and headers; require a
2xxstatus. - If the upstream WebSocket scheme is
wss, layer a second TLS session using the upstream host name. - Hand the resulting stream to
tokio-tungstenite’sclient_asyncso the WebSocket handshake completes over the tunnel.
Structs§
- Proxy
Target - Parsed components of a forward proxy URL.
- WsTarget
- Parsed components of a target WebSocket URL needed by the proxy hop.
Enums§
- Proxied
Stream - Stream produced by
tunnel_via_proxywhen the upstream isws://(no upstream TLS, but the proxy hop itself may have been TLS-protected). - Proxy
Kind - Outcome of parsing a proxy URL prior to opening a tunnel.
Functions§
- tunnel_
via_ proxy - Establish a tunneled connection through
proxyto the WebSockettarget.