pub struct UpstreamProxy { /* private fields */ }Expand description
Proxy that receives iroh streams and forwards them to origin servers.
The upstream proxy is the server-side component that accepts connections from downstream proxies over iroh and forwards requests to actual TCP origin servers.
§Protocol Support
- CONNECT tunnels: Establishes TCP connections to the requested authority and bidirectionally forwards data.
- Absolute-form requests: Forwards HTTP requests to origin servers using reqwest, with hop-by-hop header filtering per RFC 9110.
§Authorization
All requests pass through an AuthHandler before processing. Unauthorized
requests receive a 403 Forbidden response.
§Usage
Implements ProtocolHandler for use with iroh’s Router:
ⓘ
let proxy = UpstreamProxy::new(AcceptAll)?;
let router = Router::builder(endpoint)
.accept(ALPN, proxy)
.spawn();Implementations§
Source§impl UpstreamProxy
impl UpstreamProxy
Sourcepub fn new(auth: impl AuthHandler + 'static) -> Result<Self>
pub fn new(auth: impl AuthHandler + 'static) -> Result<Self>
Creates a new upstream proxy with the provided authorization handler.
Sourcepub fn metrics(&self) -> Arc<UpstreamMetrics>
pub fn metrics(&self) -> Arc<UpstreamMetrics>
Returns the metrics tracker for this upstream proxy.
Sourcepub fn on_shutdown(&self) -> impl Future<Output = ()> + Send + 'static + use<>
pub fn on_shutdown(&self) -> impl Future<Output = ()> + Send + 'static + use<>
Returns a future that resolves when this upstream proxy begins shutting down.
Trait Implementations§
Source§impl Debug for UpstreamProxy
impl Debug for UpstreamProxy
Source§impl ProtocolHandler for UpstreamProxy
impl ProtocolHandler for UpstreamProxy
Source§async fn accept(&self, connection: Connection) -> Result<(), AcceptError>
async fn accept(&self, connection: Connection) -> Result<(), AcceptError>
Handle an incoming connection. Read more
Source§fn on_accepting(
&self,
accepting: Accepting,
) -> impl Future<Output = Result<Connection, AcceptError>> + Send
fn on_accepting( &self, accepting: Accepting, ) -> impl Future<Output = Result<Connection, AcceptError>> + Send
Optional interception point to handle the
Accepting state. Read moreAuto Trait Implementations§
impl Freeze for UpstreamProxy
impl !RefUnwindSafe for UpstreamProxy
impl Send for UpstreamProxy
impl Sync for UpstreamProxy
impl Unpin for UpstreamProxy
impl UnsafeUnpin for UpstreamProxy
impl !UnwindSafe for UpstreamProxy
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
Mutably borrows from an owned value. Read more