Skip to main content

ConnectUdpSocket

Struct ConnectUdpSocket 

pub struct ConnectUdpSocket<T = Upgraded> { /* private fields */ }
Available on crate feature masque only.
Expand description

A DatagramSocket carrying UDP payloads through a CONNECT-UDP tunnel (RFC 9298).

Wraps the HttpDatagramSession of an accepted tunnel on any HTTP version, so a QUIC endpoint, a relay or a proxy can use the tunnel as a UDP socket fixed to one peer. Payloads travel with Context ID 0; datagrams for other contexts are dropped. Sending never waits for delivery, but a full queue applies backpressure (Pending) instead of dropping older payloads. Native HTTP/3 payloads above the current limit are dropped, never re-sent as capsules (RFC 9298 §6.1).

Implementations§

§

impl<T> ConnectUdpSocket<T>
where T: AsyncRead + AsyncWrite + ExtensionsRef + Send + 'static,

pub fn new( scope: &Scope, session: HttpDatagramSession<T>, local: SocketAddress, peer: SocketAddress, config: ConnectUdpSocketConfig, ) -> ConnectUdpSocket<T>

Turn an established tunnel’s session into a socket fixed to peer.

Build the session with session_config.

local and peer are what Socket reports: the target’s address on the client side or the observed endpoint addresses on the proxy side. IPv4-mapped IPv6 addresses are reported as IPv4.

pub fn from_client_session( scope: &Scope, session: HttpDatagramSession<T>, target: ConnectUdpTarget, config: ConnectUdpSocketConfig, ) -> ConnectUdpSocket<T>

Carry UDP over a session established by a client. The proxy resolves the requested target. Use rama_udp::ConnectedDatagrams to exchange complete payloads on this association. Socket::local_addr reports io::ErrorKind::AddrNotAvailable. Socket::peer_addr returns a canonical address for an IP literal and the same error for a hostname. Addressed datagram sends and receives require both socket addresses. On a client session both return AddrNotAvailable without consuming a payload.

§

impl<T> ConnectUdpSocket<T>

pub fn stats(&self) -> ConnectUdpStats

What the tunnel received, forwarded and dropped so far.

pub fn close_reason(&self) -> Option<ConnectUdpClose>

Why the tunnel stopped, once it did.

pub fn max_payload(&self) -> usize

The largest UDP payload that can be sent now: the native datagram limit minus the Context ID, or the RFC 9298 maximum on capsule carriers.

Trait Implementations§

§

impl<T> ConnectedDatagrams for ConnectUdpSocket<T>
where T: AsyncRead + Send + 'static,

§

type Sender = ConnectUdpSender

§

fn payload_sender(&self) -> <ConnectUdpSocket<T> as ConnectedDatagrams>::Sender

§

fn capabilities(&self) -> DatagramCapabilities

§

fn poll_recv( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<Bytes, DatagramError>>

§

fn recv_payload( &mut self, ) -> impl Future<Output = Result<Bytes, DatagramError>> + Send
where Self: Sized,

Receive the next complete payload. Cancelling leaves the next message available.
§

impl<T> DatagramSocket for ConnectUdpSocket<T>
where T: AsyncRead + Send + 'static,

§

type Sender = ConnectUdpSender

Independently wakeable send handle created by this socket.
§

fn into_transport(self) -> DatagramTransport<ConnectUdpSocket<T>>

Hand this socket to a transport consumer such as QUIC. A tunnel can provide its established association directly, even when neither socket address is available to the caller. The default describes an addressed socket. Wrappers must delegate to the wrapped transport and preserve any datagrams they own, including packets read ahead by a peeker.
§

fn create_sender(&self) -> <ConnectUdpSocket<T> as DatagramSocket>::Sender

Create a send handle with independent readiness registration. Read more
§

fn poll_recv( &mut self, cx: &mut Context<'_>, buffers: &mut [IoSliceMut<'_>], metadata: &mut [DatagramMetadata], ) -> Poll<Result<usize, DatagramError>>

Receive one or more datagrams, or register for readiness. Read more
§

fn capabilities(&self) -> DatagramCapabilities

Current runtime-detected capabilities.
§

impl<T> Debug for ConnectUdpSocket<T>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<T> Drop for ConnectUdpSocket<T>

§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
§

impl<T> ExtensionsRef for ConnectUdpSocket<T>

§

fn extensions(&self) -> &Extensions

Get reference to the underlying Extensions store
§

impl<T> Socket for ConnectUdpSocket<T>
where T: Send + 'static,

§

fn local_addr(&self) -> Result<SocketAddress, Error>

Try to get the local address of the socket.
§

fn peer_addr(&self) -> Result<SocketAddress, Error>

Try to get the remote address of the socket.

Auto Trait Implementations§

§

impl<T = Upgraded> !Freeze for ConnectUdpSocket<T>

§

impl<T = Upgraded> !RefUnwindSafe for ConnectUdpSocket<T>

§

impl<T = Upgraded> !UnwindSafe for ConnectUdpSocket<T>

§

impl<T> Forget for ConnectUdpSocket<T>

§

impl<T> Move for ConnectUdpSocket<T>

§

impl<T> Send for ConnectUdpSocket<T>
where Arc<IoShared<T>>: Send, Arc<dyn NativeDatagramChannel>: Send, BoxRaw<[CapsuleType]>: Send, Bytes: Send, BytesMut: Send, Arc<dyn CapsuleObserver>: Send, Arc<Shared>: Send, Arc<Chan<Bytes, Semaphore>>: Send, Arc<Node>: Send,

§

impl<T> Sync for ConnectUdpSocket<T>
where Arc<IoShared<T>>: Sync, Arc<dyn NativeDatagramChannel>: Sync, BoxRaw<[CapsuleType]>: Sync, Bytes: Sync, BytesMut: Sync, Arc<dyn CapsuleObserver>: Sync, Arc<Shared>: Sync, Arc<Chan<Bytes, Semaphore>>: Sync, Arc<Node>: Sync,

§

impl<T> Unpin for ConnectUdpSocket<T>
where Arc<IoShared<T>>: Unpin, Arc<dyn NativeDatagramChannel>: Unpin, Box<[CapsuleType]>: Unpin, *const u8: Unpin, Align8<*mut ()>: Unpin, &'static Vtable: Unpin, *const u8 is !null: Unpin, *mut Shared: Unpin, Arc<dyn CapsuleObserver>: Unpin, Arc<Shared>: Unpin, Arc<Chan<Bytes, Semaphore>>: Unpin, Arc<Node>: Unpin,

§

impl<T> UnsafeUnpin for ConnectUdpSocket<T>
where *const ArcInner<IoShared<T>> is !null: UnsafeUnpin, PhantomData<ArcInner<IoShared<T>>>: UnsafeUnpin, *const ArcInner<dyn NativeDatagramChannel> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn NativeDatagramChannel>>: UnsafeUnpin, *const [CapsuleType] is !null: UnsafeUnpin, PhantomData<[CapsuleType]>: UnsafeUnpin, *const u8: UnsafeUnpin, Align8<*mut ()>: UnsafeUnpin, &'static Vtable: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, *mut Shared: UnsafeUnpin, *const ArcInner<dyn CapsuleObserver> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn CapsuleObserver>>: UnsafeUnpin, *const ArcInner<Shared> is !null: UnsafeUnpin, PhantomData<ArcInner<Shared>>: UnsafeUnpin, *const ArcInner<Chan<Bytes, Semaphore>> is !null: UnsafeUnpin, PhantomData<ArcInner<Chan<Bytes, Semaphore>>>: UnsafeUnpin, *const ArcInner<Node> is !null: UnsafeUnpin, PhantomData<ArcInner<Node>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<S> DatagramBridgeInput for S
where S: DatagramSocket + ExtensionsRef + Send + 'static,

§

type Ingress = S

The ingress socket.
§

type Bridged<Egress: Send + 'static> = Bridge<DatagramIo<S>, DatagramIo<Egress>>

This input with its egress socket.
§

fn ingress(&self) -> &<S as DatagramBridgeInput>::Ingress

The ingress socket the egress is created for.
§

fn bridge<Egress>( self, egress: Egress, ) -> <S as DatagramBridgeInput>::Bridged<Egress>
where Egress: Send + 'static,

This input with egress next to its ingress.
§

impl<S> DatagramPeekInput for S
where S: DatagramSocket,

§

type Socket = S

The socket an inspection reads from.
§

type Mapped<Peeked: Send + 'static> = Peeked

This input with its peeked socket replaced, usually by a PrefixedDatagramSocket.
§

fn peek_socket_mut(&mut self) -> &mut <S as DatagramPeekInput>::Socket

The socket an inspection reads from.
§

fn into_peek_socket(self) -> <S as DatagramPeekInput>::Socket

Consume the input and take its ingress socket, dropping any unused egress context.
§

fn map_peek_socket<Peeked, F>( self, map: F, ) -> <S as DatagramPeekInput>::Mapped<Peeked>
where Peeked: Send + 'static, F: FnOnce(<S as DatagramPeekInput>::Socket) -> Peeked,

Rebuild this input around map’s result for its peeked socket.
§

impl<T> DatagramSocketExt for T
where T: DatagramSocket + ?Sized,

§

fn recv<'a>( &'a mut self, buffer: &'a mut [u8], ) -> impl Future<Output = Result<DatagramMetadata, DatagramError>> + Send + 'a
where Self: Sized,

Receive one datagram into buffer.
§

fn recv_batch<'a, 'buffer>( &'a mut self, buffers: &'a mut [IoSliceMut<'buffer>], metadata: &'a mut [DatagramMetadata], ) -> impl Future<Output = Result<usize, DatagramError>> + Send + 'a
where 'buffer: 'a, Self: Sized,

Receive one or more datagrams into parallel buffer and metadata slices.
§

impl<T> ForwardedClientExt for T
where T: ExtensionsRef + ?Sized,

§

fn trusted_forwarded(&self) -> Option<&Forwarded>

The chain as recorded, unless it came from a peer the policy does not trust: what may be selected from, or passed on to the next hop as this connection’s history.
§

fn forwarded_client(&self) -> Option<&ForwardedElement>

The element describing the client.
§

fn forwarded_client_ip(&self) -> Option<IpAddr>

The client’s IP, from its for node.
§

fn forwarded_client_socket_addr(&self) -> Option<SocketAddress>

The client’s IP and port, from its for node.
§

fn forwarded_client_host(&self) -> Option<&ForwardedAuthority>

The host the client asked for.
§

fn forwarded_client_proto(&self) -> Option<ForwardedProtocol>

The protocol the client used.
§

fn forwarded_client_version(&self) -> Option<ForwardedVersion>

The HTTP version the client used.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a rama_grpc::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

impl<T, U> RamaFrom<T> for U
where U: From<T>,

§

fn rama_from(value: T) -> U

§

impl<T, U, CrateMarker> RamaInto<U, CrateMarker> for T
where U: RamaFrom<T, CrateMarker>,

§

fn rama_into(self) -> U

§

impl<T, U> RamaTryFrom<T> for U
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

§

fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>

§

impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for T
where U: RamaTryFrom<T, CrateMarker>,

§

type Error = <U as RamaTryFrom<T, CrateMarker>>::Error

§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<V, F> ValueFormatter<&V> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &&V)

Write value to writer
§

impl<V, F> ValueFormatter<Arc<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Arc<V>)

Write value to writer
§

impl<V, F> ValueFormatter<Box<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Box<V>)

Write value to writer
§

impl<V, F> ValueFormatter<Cow<'_, V>> for F
where V: ToOwned + ?Sized, F: ValueFormatter<V> + ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)

Write value to writer
§

impl<V, F> ValueFormatter<Option<V>> for F
where F: ValueFormatter<V> + ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Option<V>)

Write value to writer
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more