Module
whiplash/quic/connection
src/whiplash/quic/connection.pookaOne QUIC connection, from the server's side (RFC 9000, RFC 9001).
Sans-IO: datagrams go in with accept and receive; datagrams to send
come out of flush and on_timeout; the application reads stream data
from events and writes with send. The UDP socket, timers and routing of
datagrams to connections belong to the caller.
What it does: the three packet number spaces with their keys, and 0-RTT
packets in the 1-RTT space when the handshake accepts them; CRYPTO
reassembly driving the TLS handshake (whiplash/quic/tls), then a session
ticket; acknowledgements; round-trip estimates, loss detection by packet
and time thresholds, and probe timeouts (RFC 9002 sections 5 and 6);
NewReno congestion control with persistent congestion, and pacing
(section 7); ordered stream data; flow control both ways (the peer's
MAX_DATA and MAX_STREAM_DATA are respected, ours are raised as data is
delivered, and MAX_STREAMS as client streams end); STOP_SENDING and
RESET_STREAM; key updates either way (RFC 9001 section 6); connection IDs
issued and retired, path validation and migration to a new client
address (RFC 9000 sections 5.1, 8.2 and 9); the transport parameters of a
connection that began with a Retry (retry, accept_retried);
HANDSHAKE_DONE; closing. Initial and Handshake packets share datagrams
where they fit, a datagram with an ack-eliciting Initial is padded to
1,200 bytes, and until the client's address is proven the server sends at
most three times what it received (section 8.1).
Bytes given to send wait in the connection until flow control, the
congestion window and the pacer let them go; pending tells the caller
how much waits, so a producer can be held back.
Not done: the server never asks to move to a preferred address, never sends NEW_TOKEN, and keeps to 1,200-byte datagrams (no path MTU discovery). A 1-RTT packet, having no length, ends its datagram.
API reference
- classEvent
- classConnected
- classMigrated
- classData
- classClosed
- classReset
- classStopped
- classSpace
- classIncoming
- classOutgoing
- classSending
- classCongestion
- classReceiving
- classFlow
- classConnection
- classSent
- classPhases
- classRecovery
- classPath
- functionaccept
- functionaccept_validated
- functionsend_token
- functionaccept_retried
- functionrefuse
- functioninitial_token
- functionretry
- functionlocal_id
- functionids
- functionoriginal_id
- functionis_closed
- functionreceive
- functionreceive_from
- functiontransport_parameters
- functionsend
- functionpending
- functionflush
- functionmax_datagram
- functionprobe_timeout
- functionon_timeout
- functionnext_timeout
- functionclose
- functionfail
- functionhandshake_flight
- functionreset
- functionstop
- functionmanual
- functionconsume
- functionkey_phase
- functionupdate_keys
class Event
What happened on a connection.
class Connected is Event
The handshake completed: the client's Finished was verified.
class Migrated is Event
The peer moved to a new address (RFC 9000 section 9): send there from now on. The connection is validating the address.
class Data(stream: Int, data: BitArray, fin: Bool) is Event
Stream data, in order.
stream: Int
Intdata: BitArray
BitArrayfin: Bool
Bool
fn(Int, BitArray, Bool) -> whiplash/quic/connection.Dataclass Closed(code: Int, reason: String) is Event
The connection is closed, by the peer or by this end.
code: Int
Intreason: String
String
fn(Int, String) -> whiplash/quic/connection.Closedclass Reset(stream: Int, code: Int) is Event
The peer abandoned sending on a stream (RESET_STREAM).
stream: Int
Intcode: Int
Int
fn(Int, Int) -> whiplash/quic/connection.Resetclass Stopped(stream: Int, code: Int) is Event
The peer asked this end to stop sending on a stream (STOP_SENDING). The
connection has answered with RESET_STREAM; whatever is sent on the stream
from now on is dropped, and a send with fin forgets it.
stream: Int
Intcode: Int
Int
fn(Int, Int) -> whiplash/quic/connection.Stoppedclass Space(
rx: Option(crypto.Keys),
tx: Option(crypto.Keys),
next: Int,
largest: Int,
ranges: List(#(Int, Int)),
ack_due: Bool,
crypto_in: Int,
crypto_held: Dict(Int, BitArray),
crypto_data: BitArray,
crypto_out: Int,
queue: List(Frame),
sent: Sent
)
One packet number space: its keys, what has been received and must be acknowledged, the CRYPTO stream in each direction, frames waiting to be sent, and frames sent but not yet acknowledged.
rx: Option(crypto.Keys)
Option(whiplash/quic/crypto.Keys)tx: Option(crypto.Keys)
Option(whiplash/quic/crypto.Keys)next: Int
Intlargest: Int
Intranges: List(#(Int, Int))
List(#(Int, Int))ack_due: Bool
Boolcrypto_in: Int
Intcrypto_held: Dict(Int, BitArray)
$package/pooka_stdlib/pooka/dict.Dict(Int, BitArray)crypto_data: BitArray
BitArraycrypto_out: Int
Intqueue: List(Frame)
List(whiplash/quic.Frame)sent: Sent
whiplash/quic/connection.Sent
fn(Option(whiplash/quic/crypto.Keys), Option(whiplash/quic/crypto.Keys), Int, Int, List(#(Int, Int)), Bool, Int, $package/pooka_stdlib/pooka/dict.Dict(Int, BitArray), BitArray, Int, List(whiplash/quic.Frame), whiplash/quic/connection.Sent) -> whiplash/quic/connection.Spaceclass Incoming(
next: Int,
held: Dict(Int, #(BitArray, Bool)),
limit: Int,
highest: Int,
consumed: Int
)
One receiving stream: the next byte to deliver, the bytes held out of
order, the limit granted to the peer, the highest byte received, and the
bytes the application has consumed (-1 when delivery counts as
consumption; see manual).
next: Int
Intheld: Dict(Int, #(BitArray, Bool))
$package/pooka_stdlib/pooka/dict.Dict(Int, #(BitArray, Bool))limit: Int
Inthighest: Int
Intconsumed: Int
Int
fn(Int, $package/pooka_stdlib/pooka/dict.Dict(Int, #(BitArray, Bool)), Int, Int, Int) -> whiplash/quic/connection.Incomingclass Outgoing(pending: BitArray, offset: Int, fin: Bool, limit: Int)
Bytes waiting to be sent on one stream, the offset they start at, whether the stream ends after them, and how far the peer lets the stream go. A limit of -1 marks a stream the peer stopped: its bytes are dropped.
pending: BitArray
BitArrayoffset: Int
Intfin: Bool
Boollimit: Int
Int
fn(BitArray, Int, Bool, Int) -> whiplash/quic/connection.Outgoingclass Sending(
outgoing: Dict(Int, Outgoing),
order: List(Int),
early: Dict(Int, Int),
peer_data: Int,
data_sent: Int,
peer_bidi: Int,
peer_uni: Int
)
The sending side of flow control: streams with bytes waiting (order is
the round-robin), limits for streams not yet written to, the peer's
connection limit and how much of it is used, and the peer's initial
stream limits.
outgoing: Dict(Int, Outgoing)
$package/pooka_stdlib/pooka/dict.Dict(Int, whiplash/quic/connection.Outgoing)order: List(Int)
List(Int)early: Dict(Int, Int)
$package/pooka_stdlib/pooka/dict.Dict(Int, Int)peer_data: Int
Intdata_sent: Int
Intpeer_bidi: Int
Intpeer_uni: Int
Int
fn($package/pooka_stdlib/pooka/dict.Dict(Int, whiplash/quic/connection.Outgoing), List(Int), $package/pooka_stdlib/pooka/dict.Dict(Int, Int), Int, Int, Int, Int) -> whiplash/quic/connection.Sendingclass Congestion(in_flight: Int, window: Int, threshold: Int, recovery: Int)
NewReno: bytes in flight in 1-RTT packets, the congestion window, the slow-start threshold, and the first packet number sent after the last window reduction (losses below it do not reduce the window again).
in_flight: Int
Intwindow: Int
Intthreshold: Int
Intrecovery: Int
Int
fn(Int, Int, Int, Int) -> whiplash/quic/connection.Congestionclass Receiving(
data_max: Int,
data_received: Int,
bidi_max: Int,
uni_max: Int,
finished: Dict(Int, Nil),
bidi_floor: Int,
uni_floor: Int,
opened_bidi: Int
)
The receiving side: this end's connection limit and the bytes counted
against it, the client stream counts allowed, streams whose receiving
side has ended (below the floors, or in finished), and the highest
bidirectional stream count the client has opened.
data_max: Int
Intdata_received: Int
Intbidi_max: Int
Intuni_max: Int
Intfinished: Dict(Int, Nil)
$package/pooka_stdlib/pooka/dict.Dict(Int, Nil)bidi_floor: Int
Intuni_floor: Int
Intopened_bidi: Int
Int
fn(Int, Int, Int, Int, $package/pooka_stdlib/pooka/dict.Dict(Int, Nil), Int, Int, Int) -> whiplash/quic/connection.Receivingclass Flow(sending: Sending, congestion: Congestion, receiving: Receiving)
sending: Sending
whiplash/quic/connection.Sendingcongestion: Congestion
receiving: Receiving
class Connection(
original: BitArray,
local: BitArray,
peer: BitArray,
initial: Space,
handshake: Space,
application: Space,
identity: tls.Identity,
flight: Option(tls.Flight),
connected: Bool,
closed: Bool,
streams: Dict(Int, Incoming),
flow: Flow,
received: Int,
sent_bytes: Int,
keys: Phases,
recovery: Recovery,
path: Path
)
original: BitArray
BitArraylocal: BitArray
BitArraypeer: BitArray
BitArrayinitial: Space
whiplash/quic/connection.Spacehandshake: Space
whiplash/quic/connection.Spaceapplication: Space
whiplash/quic/connection.Spaceidentity: tls.Identity
whiplash/quic/tls.Identityflight: Option(tls.Flight)
Option(whiplash/quic/tls.Flight)connected: Bool
Boolclosed: Bool
Boolstreams: Dict(Int, Incoming)
$package/pooka_stdlib/pooka/dict.Dict(Int, whiplash/quic/connection.Incoming)flow: Flow
whiplash/quic/connection.Flowreceived: Int
Intsent_bytes: Int
Intkeys: Phases
whiplash/quic/connection.Phasesrecovery: Recovery
path: Path
whiplash/quic/connection.Path
fn(BitArray, BitArray, BitArray, whiplash/quic/connection.Space, whiplash/quic/connection.Space, whiplash/quic/connection.Space, whiplash/quic/tls.Identity, Option(whiplash/quic/tls.Flight), Bool, Bool, $package/pooka_stdlib/pooka/dict.Dict(Int, whiplash/quic/connection.Incoming), whiplash/quic/connection.Flow, Int, Int, whiplash/quic/connection.Phases, whiplash/quic/connection.Recovery, whiplash/quic/connection.Path) -> whiplash/quic/connection.Connectionclass Sent(
packets: Dict(Int, #(Int, Int, List(Frame))),
oldest: Int,
acked: Int,
last: Int,
loss_at: Int
)
Packets sent in one space and not yet acknowledged or declared lost, by
packet number: when each was sent, its size, and its frames. Numbers below
oldest are all settled, so acknowledgement and loss detection walk only
what is still in flight. Also the largest number the peer acknowledged
(-1 before any), when the last ack-eliciting packet went (-1 before any),
and when the next packet would be declared lost by time (-1 for none).
packets: Dict(Int, #(Int, Int, List(Frame)))
$package/pooka_stdlib/pooka/dict.Dict(Int, #(Int, Int, List(whiplash/quic.Frame)))oldest: Int
Intacked: Int
Intlast: Int
Intloss_at: Int
Int
fn($package/pooka_stdlib/pooka/dict.Dict(Int, #(Int, Int, List(whiplash/quic.Frame))), Int, Int, Int, Int) -> whiplash/quic/connection.Sentclass Phases(
phase: Int,
rx_secret: BitArray,
tx_secret: BitArray,
next_rx: Option(crypto.Keys),
previous_rx: Option(crypto.Keys),
rx_since: Int,
tx_since: Int,
confirmed: Bool,
early: Option(crypto.Keys)
)
Key update for 1-RTT packets (RFC 9001 section 6): the current key phase bit, the secrets of the current phase, the peer's keys for the next phase (ready before it updates) and for the previous one (for late packets), the first packet number received in this phase (-1 until one arrives), the first packet number sent in it, whether one of those was acknowledged, without which this end may not update again, and the keys of the client's 0-RTT packets while they are accepted.
phase: Int
Intrx_secret: BitArray
BitArraytx_secret: BitArray
BitArraynext_rx: Option(crypto.Keys)
Option(whiplash/quic/crypto.Keys)previous_rx: Option(crypto.Keys)
Option(whiplash/quic/crypto.Keys)rx_since: Int
Inttx_since: Int
Intconfirmed: Bool
Boolearly: Option(crypto.Keys)
Option(whiplash/quic/crypto.Keys)
fn(Int, BitArray, BitArray, Option(whiplash/quic/crypto.Keys), Option(whiplash/quic/crypto.Keys), Int, Int, Bool, Option(whiplash/quic/crypto.Keys)) -> whiplash/quic/connection.Phasesclass Recovery(
latest: Int,
smoothed: Int,
variance: Int,
minimum: Int,
sampled: Bool,
pto_count: Int,
max_ack_delay: Int,
ack_exponent: Int,
probes: Int,
tokens: Int,
refilled: Int
)
Round-trip estimates and probe timeouts (RFC 9002 sections 5 and 6), in milliseconds: the latest sample, the smoothed estimate, its variation, the minimum seen, and whether any sample was taken; how many probe timeouts passed without an acknowledgement; the peer's max_ack_delay and ack_delay_exponent; probe packets owed that may exceed the congestion window; and the pacer's bytes in hand and when it last refilled.
latest: Int
Intsmoothed: Int
Intvariance: Int
Intminimum: Int
Intsampled: Bool
Boolpto_count: Int
Intmax_ack_delay: Int
Intack_exponent: Int
Intprobes: Int
Inttokens: Int
Intrefilled: Int
Int
fn(Int, Int, Int, Int, Bool, Int, Int, Int, Int, Int, Int) -> whiplash/quic/connection.Recoveryclass Path(
validated: Bool,
challenge: Option(BitArray),
ids: Dict(Int, BitArray),
issued: Int,
peer_ids: Dict(Int, BitArray),
peer_sequence: Int,
peer_limit: Int,
retried: Option(BitArray),
newest: Bool,
mtu: Int,
probe: Int,
probing: Int
)
The network path and connection IDs (RFC 9000 sections 5.1, 8 and 9): whether the peer's address is validated, the PATH_CHALLENGE data awaiting a response, this end's connection IDs by sequence number and the next sequence to issue, the peer's IDs by sequence and the sequence of the one in use, how many IDs the peer accepts, the original destination ID when the client came back after a Retry, and whether the datagram being read carried the peer's newest packet that is not only probing. Then path MTU discovery (RFC 9000 section 14.3): the largest datagram known to get through, the packet number of a probe in flight (-1 for none), and the size to probe next (0 when done).
validated: Bool
Boolchallenge: Option(BitArray)
Option(BitArray)ids: Dict(Int, BitArray)
$package/pooka_stdlib/pooka/dict.Dict(Int, BitArray)issued: Int
Intpeer_ids: Dict(Int, BitArray)
$package/pooka_stdlib/pooka/dict.Dict(Int, BitArray)peer_sequence: Int
Intpeer_limit: Int
Intretried: Option(BitArray)
Option(BitArray)newest: Bool
Boolmtu: Int
Intprobe: Int
Intprobing: Int
Int
fn(Bool, Option(BitArray), $package/pooka_stdlib/pooka/dict.Dict(Int, BitArray), Int, $package/pooka_stdlib/pooka/dict.Dict(Int, BitArray), Int, Int, Option(BitArray), Bool, Int, Int, Int) -> whiplash/quic/connection.Pathaccept(datagram: BitArray, identity: tls.Identity, now: Int) -> Result(
#(Connection, List(Event), List(BitArray)),
quic.QuicError
)
fn(BitArray, whiplash/quic/tls.Identity, Int) -> Result(#(whiplash/quic/connection.Connection, List(whiplash/quic/connection.Event), List(BitArray)), whiplash/quic.QuicError)A connection for a client's first Initial datagram, and what it leads to.
accept_validated(datagram: BitArray, identity: tls.Identity, now: Int) -> Result(
#(Connection, List(Event), List(BitArray)),
quic.QuicError
)
fn(BitArray, whiplash/quic/tls.Identity, Int) -> Result(#(whiplash/quic/connection.Connection, List(whiplash/quic/connection.Event), List(BitArray)), whiplash/quic.QuicError)accept for a client whose Initial carried a token this server gave it
with NEW_TOKEN on an earlier connection: its address is already proven, so
nothing limits what the server sends it, and no Retry is needed.
send_token(connection: Connection, token: BitArray) -> Connection
fn(whiplash/quic/connection.Connection, BitArray) -> whiplash/quic/connection.ConnectionGive the client a token for its next connection (NEW_TOKEN, RFC 9000 section 8.1.3), sent in 1-RTT packets.
accept_retried(
datagram: BitArray,
identity: tls.Identity,
original: BitArray,
now: Int
) -> Result(#(Connection, List(Event), List(BitArray)), quic.QuicError)
fn(BitArray, whiplash/quic/tls.Identity, BitArray, Int) -> Result(#(whiplash/quic/connection.Connection, List(whiplash/quic/connection.Event), List(BitArray)), whiplash/quic.QuicError)accept for a client that came back with the token of a Retry: original
is the destination ID of its very first Initial, which the token carries.
Its address is proven, so nothing limits what the server sends it.
refuse(
datagram: BitArray,
identity: tls.Identity,
code: Int,
reason: String,
now: Int
) -> Result(List(BitArray), Nil)
fn(BitArray, whiplash/quic/tls.Identity, Int, String, Int) -> Result(List(BitArray), Nil)Refuse a client's Initial with CONNECTION_CLOSE in an Initial packet, as for a Retry token that does not check out (INVALID_TOKEN, 0x0b). Returns the datagrams to send; an error when the datagram is no Initial.
initial_token(datagram: BitArray) -> Result(BitArray, Nil)
fn(BitArray) -> Result(BitArray, Nil)The token of a client's Initial packet (RFC 9000 section 17.2.2); empty when it has none. An error when the datagram is no Initial.
retry(datagram: BitArray, source: BitArray, token: BitArray) -> Result(
BitArray,
Nil
)
fn(BitArray, BitArray, BitArray) -> Result(BitArray, Nil)A Retry packet answering a client's Initial (RFC 9000 section 17.2.5),
from the new connection ID source and carrying token, with its
integrity tag. The client sends its Initial again, to source, with the
token; an error when the datagram is no Initial.
let assert Ok(packet) = connection.retry(datagram, id, token)
local_id(connection: Connection) -> BitArray
fn(whiplash/quic/connection.Connection) -> BitArrayThis end's connection ID: route datagrams carrying it here.
ids(connection: Connection) -> List(BitArray)
fn(whiplash/quic/connection.Connection) -> List(BitArray)Every connection ID that routes to this connection: the client's original destination ID and each ID this end has issued and the peer not retired. It changes as the peer retires IDs and new ones replace them.
original_id(connection: Connection) -> BitArray
fn(whiplash/quic/connection.Connection) -> BitArrayThe client's original destination ID, which routes its first packets.
is_closed(connection: Connection) -> Bool
fn(whiplash/quic/connection.Connection) -> Boolreceive(connection: Connection, datagram: BitArray, now: Int) -> Result(
#(Connection, List(Event), List(BitArray)),
quic.QuicError
)
fn(whiplash/quic/connection.Connection, BitArray, Int) -> Result(#(whiplash/quic/connection.Connection, List(whiplash/quic/connection.Event), List(BitArray)), whiplash/quic.QuicError)Read a datagram: every packet in it, every frame in each packet. Returns the events and the datagrams to send now.
receive_from(
connection: Connection,
datagram: BitArray,
moved: Bool,
now: Int
) -> Result(#(Connection, List(Event), List(BitArray)), quic.QuicError)
fn(whiplash/quic/connection.Connection, BitArray, Bool, Int) -> Result(#(whiplash/quic/connection.Connection, List(whiplash/quic/connection.Event), List(BitArray)), whiplash/quic.QuicError)receive, saying whether the datagram came from an address other than
the one this end sends to. The datagrams returned belong to the address it
came from; a PATH_RESPONSE must go back where its challenge came from. When
it carries the peer's newest packet that is not only probing, the peer has
moved (RFC 9000 section 9): the events include Migrated, everything goes
to the new address from then on, and the connection validates it, sending
at most three times what arrives from it until it answers.
let moved = from != address
let assert Ok(#(c, events, out)) = connection.receive_from(c, datagram, moved, now)
transport_parameters(connection: Connection) -> BitArray
fn(whiplash/quic/connection.Connection) -> BitArrayThe transport parameters this server sends (RFC 9000 section 18.2).
send(connection: Connection, stream: Int, data: BitArray, fin: Bool) -> Connection
fn(whiplash/quic/connection.Connection, Int, BitArray, Bool) -> whiplash/quic/connection.ConnectionGive bytes to a stream; fin ends it. They are sent, in 1-RTT packets,
as flow control and the congestion window allow.
pending(connection: Connection, stream: Int) -> Int
fn(whiplash/quic/connection.Connection, Int) -> IntBytes given to send on a stream and not yet put in packets.
flush(connection: Connection, now: Int) -> #(List(BitArray), Connection)
fn(whiplash/quic/connection.Connection, Int) -> #(List(BitArray), whiplash/quic/connection.Connection)Every datagram ready to send now: acknowledgements and queued frames, space by space. Initial and Handshake packets share datagrams where they fit (RFC 9000 section 12.2); 1-RTT packets go as the congestion window and the pacer allow (RFC 9002 section 7.7).
max_datagram(connection: Connection) -> Int
fn(whiplash/quic/connection.Connection) -> IntThe largest datagram this connection sends: 1,200 bytes until path MTU discovery finds more room.
probe_timeout(connection: Connection, space: Int) -> Int
fn(whiplash/quic/connection.Connection, Int) -> IntThe probe timeout of a packet number space, in milliseconds (RFC 9002 section 6.2.1): the smoothed round trip, four times its variation, and for 1-RTT the peer's max_ack_delay; it doubles with each timeout that passes without an acknowledgement.
on_timeout(connection: Connection, now: Int) -> #(List(BitArray), Connection)
fn(whiplash/quic/connection.Connection, Int) -> #(List(BitArray), whiplash/quic/connection.Connection)Run the timers that are due: declare lost what the loss timer waited for, or after a probe timeout send probes (RFC 9002 section 6.2.4): the frames of the oldest packets in flight again, in up to two packets that may exceed the congestion window. Then send whatever the pacer now allows.
next_timeout(connection: Connection) -> Option(Int)
fn(whiplash/quic/connection.Connection) -> Option(Int)When on_timeout should next run: a loss timer, a probe timeout, or the
pacer letting the next packet go. None when nothing waits.
close(connection: Connection, code: Int, reason: String, now: Int) -> #(
List(BitArray),
Connection
)
fn(whiplash/quic/connection.Connection, Int, String, Int) -> #(List(BitArray), whiplash/quic/connection.Connection)Close with a transport error code, telling the peer.
fail(connection: Connection, code: Int, reason: String) -> Connection
fn(whiplash/quic/connection.Connection, Int, String) -> whiplash/quic/connection.ConnectionClose because of an error the application found, such as an HTTP/3 error: CONNECTION_CLOSE of the application kind, sent by the next flush.
handshake_flight(connection: Connection) -> Option(tls.Flight)
fn(whiplash/quic/connection.Connection) -> Option(whiplash/quic/tls.Flight)The handshake's flight and secrets, once the ClientHello has been answered. For diagnostics and key logging.
reset(connection: Connection, stream: Int, code: Int) -> Connection
fn(whiplash/quic/connection.Connection, Int, Int) -> whiplash/quic/connection.ConnectionAbandon sending on a stream (RESET_STREAM with code): what waits is
dropped, and so is whatever is sent on it later; a send with fin
forgets the stream.
stop(connection: Connection, stream: Int, code: Int) -> Connection
fn(whiplash/quic/connection.Connection, Int, Int) -> whiplash/quic/connection.ConnectionAsk the peer to stop sending on a stream (STOP_SENDING with code); what
it sends meanwhile is still counted, and dropped by the caller.
manual(connection: Connection, stream: Int) -> Connection
fn(whiplash/quic/connection.Connection, Int) -> whiplash/quic/connection.ConnectionFrom now on, a stream's window grows only as the application reports
bytes consumed with consume, not as they are delivered: a slow reader
holds the peer back. Bytes delivered so far count as consumed.
consume(connection: Connection, stream: Int, size: Int) -> Connection
fn(whiplash/quic/connection.Connection, Int, Int) -> whiplash/quic/connection.ConnectionThe application consumed size delivered bytes of a manual stream;
the peer may send more once half the window is used.
key_phase(connection: Connection) -> Int
fn(whiplash/quic/connection.Connection) -> IntThe key phase 1-RTT packets are protected with, 0 or 1. It flips with every key update, whichever end starts it.
update_keys(connection: Connection) -> Result(Connection, Nil)
fn(whiplash/quic/connection.Connection) -> Result(whiplash/quic/connection.Connection, Nil)Start a key update (RFC 9001 section 6.1): new 1-RTT keys in both directions from the next packet on. An error before the handshake is confirmed, or while no packet sent with the current keys has been acknowledged. The connection also updates by itself before its keys have protected a million packets, well inside AES-GCM's limits.
let assert Ok(c) = connection.update_keys(c)