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 moreAuto Trait Implementations§
impl Freeze for DownstreamProxy
impl RefUnwindSafe for DownstreamProxy
impl Send for DownstreamProxy
impl Sync for DownstreamProxy
impl Unpin for DownstreamProxy
impl UnsafeUnpin for DownstreamProxy
impl UnwindSafe for DownstreamProxy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more