pub struct DownstreamProxy { /* private fields */ }Expand description
Proxy that accepts TCP connections and forwards them over iroh.
The downstream proxy is the client-facing component that receives incoming TCP connections (typically HTTP requests) and routes them to upstream proxies via iroh’s peer-to-peer QUIC connections.
§Modes
- TCP mode: Blindly tunnels all traffic to a fixed upstream destination.
- HTTP mode: Parses HTTP requests to enable dynamic routing and supports both forward proxy (absolute-form) and reverse proxy (origin-form) requests.
§Connection Pooling
Maintains a pool of iroh connections to upstream endpoints for efficiency. Multiple requests to the same endpoint share a single QUIC connection.
Implementations§
Source§impl DownstreamProxy
impl DownstreamProxy
Sourcepub fn new(endpoint: Endpoint, pool_opts: PoolOpts) -> Self
pub fn new(endpoint: Endpoint, pool_opts: PoolOpts) -> Self
Creates a downstream proxy with the given endpoint and pool options.
Sourcepub fn metrics(&self) -> &Arc<DownstreamMetrics>
pub fn metrics(&self) -> &Arc<DownstreamMetrics>
Returns the downstream metrics tracker.
Sourcepub async fn create_tunnel(
&self,
destination: &EndpointAuthority,
) -> Result<TunnelClientStreams, ProxyError>
pub async fn create_tunnel( &self, destination: &EndpointAuthority, ) -> Result<TunnelClientStreams, ProxyError>
Opens a CONNECT tunnel to the upstream proxy and returns the client streams.
Note: any non-200 OK response from upstream is returned as a ProxyError.
Sourcepub async fn forward_tcp_listener(
&self,
listener: TcpListener,
mode: ProxyMode,
) -> Result<()>
pub async fn forward_tcp_listener( &self, listener: TcpListener, mode: ProxyMode, ) -> Result<()>
Accepts TCP connections from the listener and forwards each in a new task.
Runs indefinitely until the listener errors or the task is cancelled.
Sourcepub async fn forward_uds_listener(
&self,
listener: UnixListener,
mode: ProxyMode,
) -> Result<()>
pub async fn forward_uds_listener( &self, listener: UnixListener, mode: ProxyMode, ) -> Result<()>
Accepts UDS connections from the Unix Domain Socket and forwards each in a new task.
Runs indefinitely until the listener errors or the task is cancelled.
Trait Implementations§
Source§impl Clone for DownstreamProxy
impl Clone for DownstreamProxy
Source§fn clone(&self) -> DownstreamProxy
fn clone(&self) -> DownstreamProxy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more