Expand description
Per-connection proxy session β forwards streams between client and relay.
Re-exportsΒ§
use std::future::Future;πuse std::pin::Pin;πuse std::sync::atomic::AtomicBool;πuse std::sync::atomic::AtomicU64;πuse std::sync::atomic::Ordering;πuse std::sync::Arc;πuse std::sync::Mutex;πuse std::time::Duration;πuse std::time::Instant;πuse bytes::Bytes;πuse bytes::BytesMut;πuse tokio::sync::mpsc;πuse tokio::sync::watch;πuse tokio::task::JoinSet;πuse tokio_util::sync::CancellationToken;πuse moqtap_client::transport::quic::QuicTransport;πuse moqtap_client::transport::RecvStream;πuse moqtap_client::transport::SendStream;πuse moqtap_client::transport::Transport;πuse moqtap_client::transport::TransportError;πuse moqtap_codec::dispatch::AnyControlMessage;πuse moqtap_codec::dispatch::AnyDatagramHeader;πuse moqtap_codec::varint::VarInt;πuse moqtap_codec::version::DraftVersion;πuse crate::action::Action;πuse crate::action::EgressConfig;πuse crate::action::Interest;πuse crate::action::StreamEnd;πuse crate::capability::fetch_group_order_is_needed;πuse crate::capability::ActionKind;πuse crate::capability::Capabilities;πuse crate::capability::Site;πuse crate::control::AbortOnDrop;πuse crate::control::ControlAttachment;πuse crate::control::ControlLeg;πuse crate::control::ControlPlane;πuse crate::control::SessionCommand;πuse crate::control::StreamCommand;πuse crate::control::StreamRegistry;πuse crate::control::COMMAND_QUEUE_DEPTH;πuse crate::egress;πuse crate::egress::CloseOrigin;πuse crate::egress::DrainOutcome;πuse crate::egress::EgressGauge;πuse crate::egress::PendingQueue;πuse crate::egress::SessionCloser;πuse crate::error::ProxyError;πuse crate::event::DataStreamHeaderKind;πuse crate::event::Effect;πuse crate::event::ImpairmentKind;πuse crate::event::ProxyEvent;πuse crate::event::SessionId;πuse crate::event::ShapeOutcome;πuse crate::exec;πuse crate::exec::DeferredEffects;πuse crate::exec::Plan;πuse crate::exec::StreamSite;πuse crate::framer::FetchGroupOrders;πuse crate::framer::FramerConfig;πuse crate::framer::FramerOut;πuse crate::framer::ObjectFramer;πuse crate::hook::FrameCtx;πuse crate::hook::ObjectCtx;πuse crate::hook::ProxyHook;πuse crate::hook::StreamCtx;πuse crate::instrument::Counters;πuse crate::instrument::Recorder;πuse crate::observer::ProxyObserver;πuse crate::parser::control::ControlStreamParser;πuse crate::parser::control::ParseResult;πuse crate::parser::control::ParsedItem;πuse crate::shape::Acquire;πuse crate::shape::Admission;πuse crate::shape::Class;πuse crate::shape::Scheduler;πuse crate::shape::ShapeProfile;πuse crate::shape::ShapeRecorder;πuse crate::shape::ShapeStats;πuse crate::shape::StreamKey;πuse crate::transport;πuse crate::transport::TransportInstaller;πuse crate::transport::TransportProfile;πuse crate::types::DataStreamType;πuse crate::types::Leg;πuse crate::types::ProxySide;π
StructsΒ§
- Cached
Shaper π - What
SessionShaperkeeps behind its lock. - Control
Frame πWalker - Where the message boundaries are on a control stream being forwarded verbatim.
- Forward
Ctx π - Shared context for forwarding helpers, avoiding repeated parameter lists.
- Negotiated
Protocol π - The relayβs
WT-Protocol: as sent, and the identifier inside it when it is a well-formed sf-string. - Peeked
Recv π - A receive stream with bytes already taken off it.
- Proxy
Session - A proxy session that forwards traffic between a client and an upstream relay. One session is created per accepted client connection.
- Proxy
Session Config - Configuration for a proxy sessionβs upstream connection.
- Session
Draft π - The draft this session frames with, and the one place every task reads it from.
- Session
Shaper π - One sessionβs shaper, and the proxy profile it watches.
- Shaped
Stream π - Which stream a shaped release is happening on, for the events it owes.
- Skip
Verification π - TLS certificate verifier that skips all verification (testing only).
- Stop
Watcher π - A destination-side
STOP_SENDINGwatcher, hoisted once per forwarded stream and used as a fourthtokio::select!branch. - Stream
State π - The deferred-write state of one stream direction, plus the two facts every teardown helper needs about it.
- Upstream π
- A dialled relay, with the WebTransport protocol it chose.
EnumsΒ§
- Client
Conn π - Where a sessionβs client comes from.
- Draft
Peek π - What
peek_draftmade of a control streamβs opening bytes. - Draft
Source π - Where a sessionβs draft came from, ranked by how much it is worth.
- Flow π
- Whether a stream direction may keep running after a helper returned.
- Header
Step π - What one more header byte told
ControlFrameWalker. - Source π
- What one poll of the source stream saw.
- Stream
Request π - What a data streamβs task does with a control-plane request.
- UniStream
Kind π - What a unidirectional streamβs leading varint says the stream is.
- Upstream
Transport Type - The transport type for upstream relay connections.
ConstantsΒ§
- CONTROL_
STREAM_ πTYPE - The unidirectional stream type that marks a control stream on the drafts
control_plane_is_unidirectionalnames, and the SETUP message type on the same drafts. They are one number, 0x2F00. - DETECT_
BUF_ πMAX - The most bytes a control stream is buffered for while its first message is peeked at.
- DRAFT_
SETTLE_ πWINDOW - How long a task that needs the sessionβs draft waits for the control stream to name one before running on the draft the session started with.
- MAX_
CONTROL_ πHEADER - The largest control-message header this crate can meet: an eight-byte type varint followed by an eight-byte length varint.
- MAX_
CONTROL_ πPAYLOAD - A declared control-message payload length above which
ControlFrameWalkerstops believing what it is reading. - MAX_
UNI_ πTYPE_ LEN - The most bytes a unidirectional streamβs type varint can occupy: nine, which is MoQTβs widest form from draft-17 (RFC 9000βs is eight).
FunctionsΒ§
- action_
kind π - The
ActionKinda returnedActionwill be reported as. - await_
serialize_ πtarget - Hold this stream until
targetends βStreamAction::SerializeAfter. - bidi_
streams_ πcarry_ requests - Whether this draft puts requests on bidirectional streams of their own, so that a bidirectional stream beyond the control stream is a stream this proxy has to forward.
- class_
label π - The label
ProxyEvent::Shapedreports a class under. - classify_
uni_ πstream - Read a unidirectional streamβs type varint and say what the stream is.
- close_
after_ πdraining - Give this sessionβs egress queues
drainto empty, then end it. - close_
reason π - Who closed the session and with what, when a close was requested.
- control_
event π - The observer event one parsed control frame produces.
- control_
length_ πis_ bounded - Whether
MAX_CONTROL_PAYLOADbounds a control message length this draft frames as a varint. See that constant for why 07-10 are bounded and 23 is not. - control_
plane_ πis_ unidirectional - Whether this draft carries control messages on a pair of unidirectional streams, making a bidirectional stream a request stream rather than the control stream.
- data_
stream_ πrequest - Interpret one request delivered to a data streamβs task.
- datagram_
is_ πstatus - Whether a decoded datagram header carries an Object Status.
- datagram_
payload_ πstart - Where a decoded datagramβs payload starts.
- detect_
stream_ πtype - Determine the data stream type from the first varint on the stream.
- drain_
pending π - Flush anything the hook deferred, honouring its release times, as a race against session cancellation.
- egress_
side π - The egress side paired with an ingress side.
- emit_
parsed_ πframes - Feed bytes to the control parser and emit observer events for any completed frames.
- forward_
control_ πstream - Forward the control stream on the drafts whose control stream is the first client-initiated bidirectional stream β drafts 07 through 16.
- forward_
datagrams π - Forward datagrams from source to destination.
- forward_
mutated_ πframes - Feed bytes into the capturing control parser, then execute the hookβs decision on each completed frame.
- forward_
request_ πstreams - Forward bidirectional request streams, on the drafts where that is
what a bidirectional stream is β see
control_plane_is_unidirectional. - forward_
undefined_ πbidi_ streams - Forward, unread, the bidirectional streams a draft does not define: every one after the control stream on drafts 07-15. The relay answers them as its draft says.
- forward_
uni_ πstreams - Forward unidirectional streams from source to destination.
- is_
connection_ πlevel - Whether a
send_datagramfailure ends the session. - is_
mirrored_ πteardown - Whether a pipe error is an abnormal teardown the proxy already
mirrored and reported as
ProxyEvent::StreamReset. - new_
capturing_ πcontrol_ parser - Build a capturing control parser and count it.
- new_
control_ πparser - Build a non-capturing control parser and count it.
- note_
fetch_ πorder - File the Group Order a FETCH asked for, from the bytes leaving the proxy.
- note_
fetch_ πorders - File the Group Order every FETCH in this batch asked for.
- observe_
source π - Observe the source stream, whatever the egress queue is doing.
- paired_
ingress_ πside - The ingress side of the other direction of the same stream.
- peek_
draft π - Try to name the concrete draft by peeking at the first SETUP message on a control stream.
- pipe_
control π - Pipe one direction of a stream carrying MoQT control-message framing.
- pipe_
control_ πmutating - Parse-then-forward control stream pipe.
- pipe_
control_ πpassthrough - Forward-first control stream pipe.
- pipe_
data π - Pipe a unidirectional data stream.
- pipe_
data_ πframed - Forward a unidirectional data stream through the object framer.
- pipe_
data_ πpassthrough - Forward a unidirectional data stream without interpreting it.
- propagate_
reset π - Mirror a source-side read failure onto the destination stream.
- propagate_
stop π - Mirror a destination-side write failure onto the source stream.
- pump_
control_ πleg - Hand one control legβs requests to the stream that turned out to be that directionβs control stream.
- reject_
pending π - Answer an unanswered request with
404; a connected client is left to its owner. - release_
due_ πunits - Write every unit whose release time has arrived, in order.
- report_
refused_ πframes - Report the control frames the decoder refused in one feed.
- report_
request_ πstream_ end - Report a request-stream pipe that ended badly, on the same terms
forward_uni_streamsreports one. - report_
shaping π - Emit whatever a shaped release decided, if anything.
- report_
unconfirmed π - Report whatever a teardown drain could not vouch for, once.
- request_
streams_ πbeside_ the_ control_ stream - The client-to-relay loop for bidirectional streams beside a bidirectional
control stream: draft-16βs request streams (see
bidi_streams_carry_requests), or on 07-15 streams the draft does not define. - run_
stream_ πend - Call
ProxyHook::on_stream_endand execute what it returns. - same_
classes π - Whether
profilenames exactlyclasses, in the same order. - serve_
session_ πcommands - Serve one sessionβs control-plane requests until the session ends.
- setup_
rank π - Which
DraftSourcea SETUP peeked at onsidecarries. - stop_
error π - The one
StopWatcheroutcome that ends a stream. - stream_
reset_ πcode_ defined - Whether the draft defines a stream-reset error code vocabulary.
- synthesized_
reset_ πcode - The application error code to reset a forwarded data stream with when
the source read failed for a reason that is not a peer
RESET_STREAM. - varint_
len π - Determine the encoded length of a QUIC varint from its first byte.
- version_
varint_ πto_ draft - Convert an on-wire MoQT version varint (
0xff000000 + draft) to aDraftVersion, orNoneif the value is malformed or unsupported. - write_
in_ πorder - Write bytes the hook was never shown, keeping wire order β on an unshaped stream.
- write_
with_ πinjections - Write one forwarded chunk with any held injections spliced in at
split.
Type AliasesΒ§
- Stopped
Future π - A boxed
SendStream::stopped()future.