Switch to 2024 style

This commit is contained in:
Dirkjan Ochtman
2025-02-21 10:08:18 +01:00
parent 1ef5e02afd
commit a8807131e4
62 changed files with 168 additions and 155 deletions
+1 -2
View File
@@ -11,10 +11,9 @@ use tokio::sync::Semaphore;
use tracing::{info, trace};
use bench::{
configure_tracing_subscriber, connect_client, drain_stream, rt, send_data_on_stream,
Opt, configure_tracing_subscriber, connect_client, drain_stream, rt, send_data_on_stream,
server_endpoint,
stats::{Stats, TransferResult},
Opt,
};
fn main() {
+1 -1
View File
@@ -11,8 +11,8 @@ use bytes::Bytes;
use clap::Parser;
use quinn::crypto::rustls::QuicClientConfig;
use rustls::{
pki_types::{CertificateDer, PrivateKeyDer},
RootCertStore,
pki_types::{CertificateDer, PrivateKeyDer},
};
use tokio::runtime::{Builder, Runtime};
use tracing::trace;
+1 -1
View File
@@ -4,8 +4,8 @@ extern crate proto;
use libfuzzer_sys::fuzz_target;
use proto::{
DEFAULT_SUPPORTED_VERSIONS, FixedLengthConnectionIdParser,
fuzzing::{PacketParams, PartialDecode},
FixedLengthConnectionIdParser, DEFAULT_SUPPORTED_VERSIONS,
};
fuzz_target!(|data: PacketParams| {
+1 -1
View File
@@ -7,7 +7,7 @@ use std::{
use anyhow::{Context, Result};
use bytes::Bytes;
use clap::Parser;
use quinn::{crypto::rustls::QuicClientConfig, TokioRuntime};
use quinn::{TokioRuntime, crypto::rustls::QuicClientConfig};
use rustls::pki_types::{CertificateDer, ServerName, UnixTime};
use tokio::sync::Semaphore;
use tracing::{debug, error, info};
+2 -2
View File
@@ -3,11 +3,11 @@ use std::{fs, net::SocketAddr, path::PathBuf, sync::Arc, time::Duration};
use anyhow::{Context, Result};
use bytes::Bytes;
use clap::Parser;
use quinn::{crypto::rustls::QuicServerConfig, TokioRuntime};
use quinn::{TokioRuntime, crypto::rustls::QuicServerConfig};
use rustls::pki_types::{CertificateDer, PrivatePkcs8KeyDer};
use tracing::{debug, error, info};
use perf::{bind_socket, noprotection::NoProtectionServerConfig, PERF_CIPHER_SUITES};
use perf::{PERF_CIPHER_SUITES, bind_socket, noprotection::NoProtectionServerConfig};
#[derive(Parser)]
#[clap(name = "server")]
+3 -3
View File
@@ -3,12 +3,12 @@ use std::sync::Arc;
use bytes::BytesMut;
use quinn_proto::{
ConnectionId, Side, TransportError,
crypto::{
self,
self, CryptoError,
rustls::{QuicClientConfig, QuicServerConfig},
CryptoError,
},
transport_parameters, ConnectionId, Side, TransportError,
transport_parameters,
};
/// A rustls TLS session which does not perform packet encryption/decryption (for debugging purpose)
+7 -3
View File
@@ -90,8 +90,12 @@ impl Stats {
println!("Stream metrics:\n");
println!(" │ Upload Duration │ Download Duration | FBL | Upload Throughput | Download Throughput");
println!("──────┼─────────────────┼───────────────────┼────────────┼───────────────────┼────────────────────");
println!(
" │ Upload Duration │ Download Duration | FBL | Upload Throughput | Download Throughput"
);
println!(
"──────┼─────────────────┼───────────────────┼────────────┼───────────────────┼────────────────────"
);
let print_metric = |label: &'static str, get_metric: fn(&Histogram<u64>) -> u64| {
println!(
@@ -244,7 +248,7 @@ mod json {
use crate::stats;
use crate::stats::{Stats, StreamIntervalStats};
use quinn::StreamId;
use serde::{self, ser::SerializeStruct, Serialize, Serializer};
use serde::{self, Serialize, Serializer, ser::SerializeStruct};
use std::io::Write;
use std::time::{SystemTime, UNIX_EPOCH};
+1 -1
View File
@@ -2,9 +2,9 @@ use std::hash::Hasher;
use rand::{Rng, RngCore};
use crate::shared::ConnectionId;
use crate::Duration;
use crate::MAX_CID_SIZE;
use crate::shared::ConnectionId;
/// Generates connection IDs for incoming connections
pub trait ConnectionIdGenerator: Send + Sync {
+1 -1
View File
@@ -1,6 +1,6 @@
use std::ops::Range;
use crate::{frame::NewConnectionId, ConnectionId, ResetToken};
use crate::{ConnectionId, ResetToken, frame::NewConnectionId};
/// DataType stored in CidQueue buffer
type CidData = (ConnectionId, Option<ResetToken>);
+3 -3
View File
@@ -12,13 +12,13 @@ use rustls::pki_types::{CertificateDer, PrivateKeyDer};
use thiserror::Error;
#[cfg(any(feature = "rustls-aws-lc-rs", feature = "rustls-ring"))]
use crate::crypto::rustls::{configured_provider, QuicServerConfig};
use crate::crypto::rustls::{QuicServerConfig, configured_provider};
use crate::{
DEFAULT_SUPPORTED_VERSIONS, Duration, MAX_CID_SIZE, NoneTokenLog, NoneTokenStore,
RandomConnectionIdGenerator, SystemTime, TokenLog, TokenStore, VarInt, VarIntBoundsExceeded,
cid_generator::{ConnectionIdGenerator, HashedConnectionIdGenerator},
crypto::{self, HandshakeTokenKey, HmacKey},
shared::ConnectionId,
Duration, NoneTokenLog, NoneTokenStore, RandomConnectionIdGenerator, SystemTime, TokenLog,
TokenStore, VarInt, VarIntBoundsExceeded, DEFAULT_SUPPORTED_VERSIONS, MAX_CID_SIZE,
};
mod transport;
+3 -3
View File
@@ -1,6 +1,6 @@
use std::{fmt, sync::Arc};
use crate::{congestion, Duration, VarInt, VarIntBoundsExceeded, INITIAL_MTU, MAX_UDP_PAYLOAD};
use crate::{Duration, INITIAL_MTU, MAX_UDP_PAYLOAD, VarInt, VarIntBoundsExceeded, congestion};
/// Parameters governing the core QUIC state machine
///
@@ -320,8 +320,8 @@ impl Default for TransportConfig {
fn default() -> Self {
const EXPECTED_RTT: u32 = 100; // ms
const MAX_STREAM_BANDWIDTH: u32 = 12500 * 1000; // bytes/s
// Window size needed to avoid pipeline
// stalls
// Window size needed to avoid pipeline
// stalls
const STREAM_RWND: u32 = MAX_STREAM_BANDWIDTH / 1000 * EXPECTED_RTT;
Self {
+1 -1
View File
@@ -1,7 +1,7 @@
//! Logic for controlling the rate at which data is sent
use crate::connection::RttEstimator;
use crate::Instant;
use crate::connection::RttEstimator;
use std::any::Any;
use std::sync::Arc;
+1 -1
View File
@@ -9,7 +9,7 @@ use crate::congestion::bbr::min_max::MinMax;
use crate::connection::RttEstimator;
use crate::{Duration, Instant};
use super::{Controller, ControllerFactory, BASE_DATAGRAM_SIZE};
use super::{BASE_DATAGRAM_SIZE, Controller, ControllerFactory};
mod bw_estimation;
mod min_max;
+1 -1
View File
@@ -2,7 +2,7 @@ use std::any::Any;
use std::cmp;
use std::sync::Arc;
use super::{Controller, ControllerFactory, BASE_DATAGRAM_SIZE};
use super::{BASE_DATAGRAM_SIZE, Controller, ControllerFactory};
use crate::connection::RttEstimator;
use crate::{Duration, Instant};
+2 -2
View File
@@ -1,9 +1,9 @@
use std::any::Any;
use std::sync::Arc;
use super::{Controller, ControllerFactory, BASE_DATAGRAM_SIZE};
use crate::connection::RttEstimator;
use super::{BASE_DATAGRAM_SIZE, Controller, ControllerFactory};
use crate::Instant;
use crate::connection::RttEstimator;
/// A simple, standard congestion controller
#[derive(Debug, Clone)]
+2 -2
View File
@@ -1,8 +1,8 @@
use crate::Duration;
use crate::connection::spaces::PendingAcks;
use crate::frame::AckFrequency;
use crate::transport_parameters::TransportParameters;
use crate::Duration;
use crate::{AckFrequencyConfig, TransportError, VarInt, TIMER_GRANULARITY};
use crate::{AckFrequencyConfig, TIMER_GRANULARITY, TransportError, VarInt};
/// State associated to ACK frequency
pub(super) struct AckFrequencyState {
+1 -1
View File
@@ -1,6 +1,6 @@
use std::{
cmp::Ordering,
collections::{binary_heap::PeekMut, BinaryHeap},
collections::{BinaryHeap, binary_heap::PeekMut},
mem,
};
+1 -1
View File
@@ -4,7 +4,7 @@ use std::collections::VecDeque;
use rustc_hash::FxHashSet;
use tracing::{debug, trace};
use crate::{shared::IssuedCid, Duration, Instant, TransportError};
use crate::{Duration, Instant, TransportError, shared::IssuedCid};
/// Local connection ID management
pub(super) struct CidState {
+1 -1
View File
@@ -6,8 +6,8 @@ use tracing::{debug, trace};
use super::Connection;
use crate::{
frame::{Datagram, FrameStruct},
TransportError,
frame::{Datagram, FrameStruct},
};
/// API to control datagram traffic
+6 -11
View File
@@ -9,11 +9,14 @@ use std::{
use bytes::{Bytes, BytesMut};
use frame::StreamMetaVec;
use rand::{rngs::StdRng, Rng, SeedableRng};
use rand::{Rng, SeedableRng, rngs::StdRng};
use thiserror::Error;
use tracing::{debug, error, trace, trace_span, warn};
use crate::{
Dir, Duration, EndpointConfig, Frame, INITIAL_MTU, Instant, MAX_CID_SIZE, MAX_STREAM_COUNT,
MIN_INITIAL_SIZE, Side, StreamId, TIMER_GRANULARITY, TokenStore, Transmit, TransportError,
TransportErrorCode, VarInt,
cid_generator::ConnectionIdGenerator,
cid_queue::CidQueue,
coding::BufMutExt,
@@ -31,9 +34,6 @@ use crate::{
},
token::{ResetToken, Token, TokenPayload},
transport_parameters::TransportParameters,
Dir, Duration, EndpointConfig, Frame, Instant, Side, StreamId, TokenStore, Transmit,
TransportError, TransportErrorCode, VarInt, INITIAL_MTU, MAX_CID_SIZE, MAX_STREAM_COUNT,
MIN_INITIAL_SIZE, TIMER_GRANULARITY,
};
mod ack_frequency;
@@ -1675,8 +1675,7 @@ impl Connection {
self.stats.path.lost_bytes += size_of_lost_packets;
trace!(
"packets lost: {:?}, bytes lost: {}",
lost_packets,
size_of_lost_packets
lost_packets, size_of_lost_packets
);
for &packet in &lost_packets {
@@ -3910,11 +3909,7 @@ pub enum Event {
}
fn instant_saturating_sub(x: Instant, y: Instant) -> Duration {
if x > y {
x - y
} else {
Duration::ZERO
}
if x > y { x - y } else { Duration::ZERO }
}
fn get_max_ack_delay(params: &TransportParameters) -> Duration {
+2 -2
View File
@@ -1,4 +1,4 @@
use crate::{packet::SpaceId, Instant, MtuDiscoveryConfig, MAX_UDP_PAYLOAD};
use crate::{Instant, MAX_UDP_PAYLOAD, MtuDiscoveryConfig, packet::SpaceId};
use std::cmp;
use tracing::trace;
@@ -518,9 +518,9 @@ const BLACK_HOLE_THRESHOLD: usize = 3;
#[cfg(test)]
mod tests {
use super::*;
use crate::packet::SpaceId;
use crate::Duration;
use crate::MAX_UDP_PAYLOAD;
use crate::packet::SpaceId;
use assert_matches::assert_matches;
fn default_mtud() -> MtuDiscovery {
+15 -9
View File
@@ -160,15 +160,21 @@ mod tests {
let new_instant = old_instant + Duration::from_micros(15);
let rtt = Duration::from_micros(400);
assert!(Pacer::new(rtt, 30000, 1500, new_instant)
.delay(Duration::from_micros(0), 0, 1500, 1, old_instant)
.is_none());
assert!(Pacer::new(rtt, 30000, 1500, new_instant)
.delay(Duration::from_micros(0), 1600, 1500, 1, old_instant)
.is_none());
assert!(Pacer::new(rtt, 30000, 1500, new_instant)
.delay(Duration::from_micros(0), 1500, 1500, 3000, old_instant)
.is_none());
assert!(
Pacer::new(rtt, 30000, 1500, new_instant)
.delay(Duration::from_micros(0), 0, 1500, 1, old_instant)
.is_none()
);
assert!(
Pacer::new(rtt, 30000, 1500, new_instant)
.delay(Duration::from_micros(0), 1600, 1500, 1, old_instant)
.is_none()
);
assert!(
Pacer::new(rtt, 30000, 1500, new_instant)
.delay(Duration::from_micros(0), 1500, 1500, 3000, old_instant)
.is_none()
);
}
#[test]
+3 -3
View File
@@ -2,12 +2,12 @@ use bytes::Bytes;
use rand::Rng;
use tracing::{trace, trace_span};
use super::{spaces::SentPacket, Connection, SentFrames};
use super::{Connection, SentFrames, spaces::SentPacket};
use crate::{
ConnectionId, Instant, TransportError, TransportErrorCode,
connection::ConnectionSide,
frame::{self, Close},
packet::{Header, InitialHeader, LongType, PacketNumber, PartialEncode, SpaceId, FIXED_BIT},
ConnectionId, Instant, TransportError, TransportErrorCode,
packet::{FIXED_BIT, Header, InitialHeader, LongType, PacketNumber, PartialEncode, SpaceId},
};
pub(super) struct PacketBuilder {
+2 -2
View File
@@ -1,11 +1,11 @@
use tracing::{debug, trace};
use crate::Instant;
use crate::connection::spaces::PacketSpace;
use crate::crypto::{HeaderKey, KeyPair, PacketKey};
use crate::packet::{Packet, PartialDecode, SpaceId};
use crate::token::ResetToken;
use crate::Instant;
use crate::{TransportError, RESET_TOKEN_SIZE};
use crate::{RESET_TOKEN_SIZE, TransportError};
/// Removes header protection of a packet, or returns `None` if the packet was dropped
pub(super) fn unprotect_header(
+1 -1
View File
@@ -7,7 +7,7 @@ use super::{
pacing::Pacer,
spaces::{PacketSpace, SentPacket},
};
use crate::{congestion, packet::SpaceId, Duration, Instant, TransportConfig, TIMER_GRANULARITY};
use crate::{Duration, Instant, TIMER_GRANULARITY, TransportConfig, congestion, packet::SpaceId};
/// Description of a particular network path
pub(super) struct PathData {
+1 -1
View File
@@ -2,7 +2,7 @@ use std::{collections::VecDeque, ops::Range};
use bytes::{Buf, Bytes};
use crate::{range_set::RangeSet, VarInt};
use crate::{VarInt, range_set::RangeSet};
/// Buffer of outgoing retransmittable stream data
#[derive(Default, Debug)]
+2 -2
View File
@@ -11,8 +11,8 @@ use tracing::trace;
use super::assembler::Assembler;
use crate::{
connection::StreamsState, crypto::Keys, frame, packet::SpaceId, range_set::ArrayRangeSet,
shared::IssuedCid, Dir, Duration, Instant, SocketAddr, StreamId, TransportError, VarInt,
Dir, Duration, Instant, SocketAddr, StreamId, TransportError, VarInt, connection::StreamsState,
crypto::Keys, frame, packet::SpaceId, range_set::ArrayRangeSet, shared::IssuedCid,
};
pub(super) struct PacketSpace {
+1 -1
View File
@@ -1,6 +1,6 @@
//! Connection statistics
use crate::{frame::Frame, Dir, Duration};
use crate::{Dir, Duration, frame::Frame};
/// Statistics about UDP datagrams transmitted or received on a connection
#[derive(Default, Debug, Copy, Clone)]
+3 -2
View File
@@ -1,5 +1,5 @@
use std::{
collections::{hash_map, BinaryHeap},
collections::{BinaryHeap, hash_map},
io,
};
@@ -9,8 +9,9 @@ use tracing::trace;
use super::spaces::{Retransmits, ThinRetransmits};
use crate::{
Dir, StreamId, VarInt,
connection::streams::state::{get_or_insert_recv, get_or_insert_send},
frame, Dir, StreamId, VarInt,
frame,
};
mod recv;
+1 -1
View File
@@ -8,7 +8,7 @@ use super::state::get_or_insert_recv;
use super::{ClosedStream, Retransmits, ShouldTransmit, StreamId, StreamsState};
use crate::connection::assembler::{Assembler, Chunk, IllegalOrderedRead};
use crate::connection::streams::state::StreamRecv;
use crate::{frame, TransportError, VarInt};
use crate::{TransportError, VarInt, frame};
#[derive(Debug, Default)]
pub(super) struct Recv {
+1 -1
View File
@@ -1,7 +1,7 @@
use bytes::Bytes;
use thiserror::Error;
use crate::{connection::send_buffer::SendBuffer, frame, VarInt};
use crate::{VarInt, connection::send_buffer::SendBuffer, frame};
#[derive(Debug)]
pub(super) struct Send {
+11 -10
View File
@@ -1,5 +1,5 @@
use std::{
collections::{hash_map, VecDeque},
collections::{VecDeque, hash_map},
convert::TryFrom,
mem,
};
@@ -13,11 +13,11 @@ use super::{
StreamHalf, ThinRetransmits,
};
use crate::{
Dir, MAX_STREAM_COUNT, Side, StreamId, TransportError, VarInt,
coding::BufMutExt,
connection::stats::FrameStats,
frame::{self, FrameStruct, StreamMetaVec},
transport_parameters::TransportParameters,
Dir, Side, StreamId, TransportError, VarInt, MAX_STREAM_COUNT,
};
/// Wrapper around `Recv` that facilitates reusing `Recv` instances
@@ -525,8 +525,7 @@ impl StreamsState {
self.sent_max_remote[dir as usize] = self.max_remote[dir as usize];
trace!(
value = self.max_remote[dir as usize],
"MAX_STREAMS ({:?})",
dir
"MAX_STREAMS ({:?})", dir
);
buf.write(match dir {
Dir::Uni => frame::FrameType::MAX_STREAMS_UNI,
@@ -980,8 +979,8 @@ pub(super) fn get_or_insert_recv(
mod tests {
use super::*;
use crate::{
connection::State as ConnState, connection::Streams, ReadableError, RecvStream, SendStream,
TransportErrorCode, WriteError,
ReadableError, RecvStream, SendStream, TransportErrorCode, WriteError,
connection::State as ConnState, connection::Streams,
};
use bytes::Bytes;
@@ -1300,10 +1299,12 @@ mod tests {
let error_code = 0u32.into();
stream.state.received_stop_sending(id, error_code);
assert!(stream
.state
.events
.contains(&StreamEvent::Stopped { id, error_code }));
assert!(
stream
.state
.events
.contains(&StreamEvent::Stopped { id, error_code })
);
stream.state.events.clear();
assert_eq!(stream.write(&[]), Err(WriteError::Stopped(error_code)));
+2 -2
View File
@@ -13,8 +13,8 @@ use std::{any::Any, str, sync::Arc};
use bytes::BytesMut;
use crate::{
shared::ConnectionId, transport_parameters::TransportParameters, ConnectError, Side,
TransportError,
ConnectError, Side, TransportError, shared::ConnectionId,
transport_parameters::TransportParameters,
};
/// Cryptography interface based on *ring*
+2 -3
View File
@@ -7,19 +7,18 @@ use bytes::BytesMut;
use ring::aead;
pub use rustls::Error;
use rustls::{
self,
self, CipherSuite,
client::danger::ServerCertVerifier,
pki_types::{CertificateDer, PrivateKeyDer, ServerName},
quic::{Connection, HeaderProtectionKey, KeyChange, PacketKey, Secrets, Suite, Version},
CipherSuite,
};
use crate::{
ConnectError, ConnectionId, Side, TransportError, TransportErrorCode,
crypto::{
self, CryptoError, ExportKeyingMaterialError, HeaderKey, KeyPair, Keys, UnsupportedVersion,
},
transport_parameters::TransportParameters,
ConnectError, ConnectionId, Side, TransportError, TransportErrorCode,
};
impl From<Side> for rustls::Side {
+12 -7
View File
@@ -1,5 +1,5 @@
use std::{
collections::{hash_map, HashMap},
collections::{HashMap, hash_map},
convert::TryFrom,
fmt, mem,
net::{IpAddr, SocketAddr},
@@ -8,13 +8,15 @@ use std::{
};
use bytes::{BufMut, Bytes, BytesMut};
use rand::{rngs::StdRng, Rng, RngCore, SeedableRng};
use rand::{Rng, RngCore, SeedableRng, rngs::StdRng};
use rustc_hash::FxHashMap;
use slab::Slab;
use thiserror::Error;
use tracing::{debug, error, trace, warn};
use crate::{
Duration, INITIAL_MTU, Instant, MAX_CID_SIZE, MIN_INITIAL_SIZE, RESET_TOKEN_SIZE, ResetToken,
Side, Transmit, TransportConfig, TransportError,
cid_generator::ConnectionIdGenerator,
coding::BufMutExt,
config::{ClientConfig, EndpointConfig, ServerConfig},
@@ -31,8 +33,6 @@ use crate::{
},
token::{IncomingToken, InvalidRetryTokenError, Token, TokenPayload},
transport_parameters::{PreferredAddress, TransportParameters},
Duration, Instant, ResetToken, Side, Transmit, TransportConfig, TransportError, INITIAL_MTU,
MAX_CID_SIZE, MIN_INITIAL_SIZE, RESET_TOKEN_SIZE,
};
/// The main entry point to the library
@@ -282,7 +282,10 @@ impl Endpoint {
let max_padding_len = match inciting_dgram_len.checked_sub(RESET_TOKEN_SIZE) {
Some(headroom) if headroom > MIN_PADDING_LEN => headroom - 1,
_ => {
debug!("ignoring unexpected {} byte packet: not larger than minimum stateless reset size", inciting_dgram_len);
debug!(
"ignoring unexpected {} byte packet: not larger than minimum stateless reset size",
inciting_dgram_len
);
return None;
}
};
@@ -1221,8 +1224,10 @@ impl IncomingImproperDropWarner {
impl Drop for IncomingImproperDropWarner {
fn drop(&mut self) {
warn!("quinn_proto::Incoming dropped without passing to Endpoint::accept/refuse/retry/ignore \
(may cause memory leak and eventual inability to accept new connections)");
warn!(
"quinn_proto::Incoming dropped without passing to Endpoint::accept/refuse/retry/ignore \
(may cause memory leak and eventual inability to accept new connections)"
);
}
}
+3 -7
View File
@@ -8,11 +8,11 @@ use bytes::{Buf, BufMut, Bytes};
use tinyvec::TinyVec;
use crate::{
Dir, MAX_CID_SIZE, RESET_TOKEN_SIZE, ResetToken, StreamId, TransportError, TransportErrorCode,
VarInt,
coding::{self, BufExt, BufMutExt, UnexpectedEnd},
range_set::ArrayRangeSet,
shared::{ConnectionId, EcnCodepoint},
Dir, ResetToken, StreamId, TransportError, TransportErrorCode, VarInt, MAX_CID_SIZE,
RESET_TOKEN_SIZE,
};
#[cfg(feature = "arbitrary")]
@@ -586,11 +586,7 @@ impl Iter {
error_code: self.bytes.get()?,
frame_type: {
let x = self.bytes.get_var()?;
if x == 0 {
None
} else {
Some(FrameType(x))
}
if x == 0 { None } else { Some(FrameType(x)) }
},
reason: self.take_len()?,
})),
+1 -5
View File
@@ -255,11 +255,7 @@ impl StreamId {
}
/// Which directions data flows in
pub fn dir(self) -> Dir {
if self.0 & 0x2 == 0 {
Dir::Bi
} else {
Dir::Uni
}
if self.0 & 0x2 == 0 { Dir::Bi } else { Dir::Uni }
}
/// Distinguishes streams of the same initiator and directionality
pub fn index(self) -> u64 {
+3 -2
View File
@@ -4,8 +4,9 @@ use bytes::{Buf, BufMut, Bytes, BytesMut};
use thiserror::Error;
use crate::{
ConnectionId,
coding::{self, BufExt, BufMutExt},
crypto, ConnectionId,
crypto,
};
/// Decodes a QUIC packet's invariant header
@@ -937,8 +938,8 @@ mod tests {
#[cfg(any(feature = "rustls-aws-lc-rs", feature = "rustls-ring"))]
#[test]
fn header_encoding() {
use crate::crypto::rustls::{initial_keys, initial_suite_from_provider};
use crate::Side;
use crate::crypto::rustls::{initial_keys, initial_suite_from_provider};
#[cfg(all(feature = "rustls-aws-lc-rs", not(feature = "rustls-ring")))]
use rustls::crypto::aws_lc_rs::default_provider;
#[cfg(feature = "rustls-ring")]
+1 -1
View File
@@ -1,7 +1,7 @@
use std::{
cmp,
cmp::Ordering,
collections::{btree_map, BTreeMap},
collections::{BTreeMap, btree_map},
ops::{
Bound::{Excluded, Included},
Range,
+1 -1
View File
@@ -2,7 +2,7 @@ use std::{fmt, net::SocketAddr};
use bytes::{Buf, BufMut, BytesMut};
use crate::{coding::BufExt, packet::PartialDecode, Instant, ResetToken, MAX_CID_SIZE};
use crate::{Instant, MAX_CID_SIZE, ResetToken, coding::BufExt, packet::PartialDecode};
/// Events sent from an Endpoint to a Connection
#[derive(Debug)]
+4 -4
View File
@@ -18,19 +18,19 @@ use rustls::crypto::aws_lc_rs::default_provider;
#[cfg(feature = "rustls-ring")]
use rustls::crypto::ring::default_provider;
use rustls::{
AlertDescription, RootCertStore,
pki_types::{CertificateDer, PrivateKeyDer, PrivatePkcs8KeyDer},
server::WebPkiClientVerifier,
AlertDescription, RootCertStore,
};
use tracing::info;
use super::*;
use crate::{
Duration, Instant,
cid_generator::{ConnectionIdGenerator, RandomConnectionIdGenerator},
crypto::rustls::QuicServerConfig,
frame::FrameStruct,
transport_parameters::TransportParameters,
Duration, Instant,
};
mod util;
use util::*;
@@ -1558,8 +1558,8 @@ fn cid_rotation() {
let mut stop = pair.time;
let end = pair.time + 5 * CID_TIMEOUT;
use crate::cid_queue::CidQueue;
use crate::LOC_CID_COUNT;
use crate::cid_queue::CidQueue;
let mut active_cid_num = CidQueue::LEN as u64 + 1;
active_cid_num = active_cid_num.min(LOC_CID_COUNT);
let mut left_bound = 0;
@@ -1606,8 +1606,8 @@ fn cid_retirement() {
assert!(!pair.server_conn_mut(server_ch).is_closed());
assert_matches!(pair.client_conn_mut(client_ch).active_rem_cid_seq(), 1);
use crate::cid_queue::CidQueue;
use crate::LOC_CID_COUNT;
use crate::cid_queue::CidQueue;
let mut active_cid_num = CidQueue::LEN as u64;
active_cid_num = active_cid_num.min(LOC_CID_COUNT);
+2 -2
View File
@@ -14,13 +14,13 @@ use assert_matches::assert_matches;
use bytes::BytesMut;
use lazy_static::lazy_static;
use rustls::{
KeyLogFile,
client::WebPkiServerVerifier,
pki_types::{CertificateDer, PrivateKeyDer},
KeyLogFile,
};
use tracing::{info_span, trace};
use super::crypto::rustls::{configured_provider, QuicClientConfig, QuicServerConfig};
use super::crypto::rustls::{QuicClientConfig, QuicServerConfig, configured_provider};
use super::*;
use crate::{Duration, Instant};
+2 -2
View File
@@ -8,11 +8,11 @@ use bytes::{Buf, BufMut, Bytes};
use rand::Rng;
use crate::{
Duration, RESET_TOKEN_SIZE, ServerConfig, SystemTime, UNIX_EPOCH,
coding::{BufExt, BufMutExt},
crypto::{HandshakeTokenKey, HmacKey},
packet::InitialHeader,
shared::ConnectionId,
Duration, ServerConfig, SystemTime, RESET_TOKEN_SIZE, UNIX_EPOCH,
};
/// Responsible for limiting clients' ability to reuse validation tokens
@@ -430,8 +430,8 @@ mod test {
#[test]
fn retry_token_sanity() {
use crate::cid_generator::{ConnectionIdGenerator, RandomConnectionIdGenerator};
use crate::MAX_CID_SIZE;
use crate::cid_generator::{ConnectionIdGenerator, RandomConnectionIdGenerator};
use crate::{Duration, UNIX_EPOCH};
use std::net::Ipv6Addr;
+3 -3
View File
@@ -12,17 +12,17 @@ use std::{
};
use bytes::{Buf, BufMut};
use rand::{seq::SliceRandom as _, Rng as _, RngCore};
use rand::{Rng as _, RngCore, seq::SliceRandom as _};
use thiserror::Error;
use crate::{
LOC_CID_COUNT, MAX_CID_SIZE, MAX_STREAM_COUNT, RESET_TOKEN_SIZE, ResetToken, Side,
TIMER_GRANULARITY, TransportError, VarInt,
cid_generator::ConnectionIdGenerator,
cid_queue::CidQueue,
coding::{BufExt, BufMutExt, UnexpectedEnd},
config::{EndpointConfig, ServerConfig, TransportConfig},
shared::ConnectionId,
ResetToken, Side, TransportError, VarInt, LOC_CID_COUNT, MAX_CID_SIZE, MAX_STREAM_COUNT,
RESET_TOKEN_SIZE, TIMER_GRANULARITY,
};
// Apply a given macro to a list of all the transport parameters having integer types, along with
+2 -2
View File
@@ -4,10 +4,10 @@ use std::{
net::{Ipv4Addr, Ipv6Addr, UdpSocket},
};
use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{Criterion, criterion_group, criterion_main};
use tokio::{io::Interest, runtime::Runtime};
use quinn_udp::{RecvMeta, Transmit, UdpSocketState, BATCH_SIZE};
use quinn_udp::{BATCH_SIZE, RecvMeta, Transmit, UdpSocketState};
pub fn criterion_benchmark(c: &mut Criterion) {
const TOTAL_BYTES: usize = 10 * 1024 * 1024;
+1 -1
View File
@@ -4,7 +4,7 @@ use std::{
time::Instant,
};
use super::{log_sendmsg_error, RecvMeta, Transmit, UdpSockRef, IO_ERROR_LOG_INTERVAL};
use super::{IO_ERROR_LOG_INTERVAL, RecvMeta, Transmit, UdpSockRef, log_sendmsg_error};
/// Fallback UDP socket interface that stubs out all special functionality
///
+8 -2
View File
@@ -165,8 +165,14 @@ fn log_sendmsg_error(
if now.saturating_duration_since(*last_send_error) > IO_ERROR_LOG_INTERVAL {
*last_send_error = now;
log::warn!(
"sendmsg error: {:?}, Transmit: {{ destination: {:?}, src_ip: {:?}, ecn: {:?}, len: {:?}, segment_size: {:?} }}",
err, transmit.destination, transmit.src_ip, transmit.ecn, transmit.contents.len(), transmit.segment_size);
"sendmsg error: {:?}, Transmit: {{ destination: {:?}, src_ip: {:?}, ecn: {:?}, len: {:?}, segment_size: {:?} }}",
err,
transmit.destination,
transmit.src_ip,
transmit.ecn,
transmit.contents.len(),
transmit.segment_size
);
}
}
+2 -2
View File
@@ -6,8 +6,8 @@ use std::{
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6},
os::unix::io::AsRawFd,
sync::{
atomic::{AtomicBool, AtomicUsize, Ordering},
Mutex,
atomic::{AtomicBool, AtomicUsize, Ordering},
},
time::Instant,
};
@@ -15,7 +15,7 @@ use std::{
use socket2::SockRef;
use super::{
cmsg, log_sendmsg_error, EcnCodepoint, RecvMeta, Transmit, UdpSockRef, IO_ERROR_LOG_INTERVAL,
EcnCodepoint, IO_ERROR_LOG_INTERVAL, RecvMeta, Transmit, UdpSockRef, cmsg, log_sendmsg_error,
};
// Adapted from https://github.com/apple-oss-distributions/xnu/blob/8d741a5de7ff4191bf97d57b9f54c2f6d4a15585/bsd/sys/socket_private.h
+2 -1
View File
@@ -13,9 +13,10 @@ use once_cell::sync::Lazy;
use windows_sys::Win32::Networking::WinSock;
use crate::{
EcnCodepoint, IO_ERROR_LOG_INTERVAL, RecvMeta, Transmit, UdpSockRef,
cmsg::{self, CMsgHdr},
log::debug,
log_sendmsg_error, EcnCodepoint, RecvMeta, Transmit, UdpSockRef, IO_ERROR_LOG_INTERVAL,
log_sendmsg_error,
};
/// QUIC-friendly UDP socket for Windows
+1 -1
View File
@@ -4,7 +4,7 @@ use std::{
thread,
};
use bencher::{benchmark_group, benchmark_main, Bencher};
use bencher::{Bencher, benchmark_group, benchmark_main};
use rustls::pki_types::{CertificateDer, PrivatePkcs8KeyDer};
use tokio::runtime::{Builder, Runtime};
use tracing::error_span;
+1 -1
View File
@@ -11,7 +11,7 @@ use std::{
time::{Duration, Instant},
};
use anyhow::{anyhow, Result};
use anyhow::{Result, anyhow};
use clap::Parser;
use proto::crypto::rustls::QuicClientConfig;
use rustls::pki_types::CertificateDer;
+2 -2
View File
@@ -55,8 +55,8 @@ fn configure_client(
}
/// Returns default server configuration along with its certificate.
fn configure_server(
) -> Result<(ServerConfig, CertificateDer<'static>), Box<dyn Error + Send + Sync + 'static>> {
fn configure_server()
-> Result<(ServerConfig, CertificateDer<'static>), Box<dyn Error + Send + Sync + 'static>> {
let cert = rcgen::generate_simple_self_signed(vec!["localhost".into()]).unwrap();
let cert_der = CertificateDer::from(cert.cert);
let priv_key = PrivatePkcs8KeyDer::from(cert.key_pair.serialize_der());
+1 -1
View File
@@ -10,7 +10,7 @@ use std::{
sync::Arc,
};
use anyhow::{anyhow, bail, Context, Result};
use anyhow::{Context, Result, anyhow, bail};
use clap::Parser;
use proto::crypto::rustls::QuicServerConfig;
use rustls::pki_types::{CertificateDer, PrivateKeyDer, PrivatePkcs8KeyDer};
+6 -5
View File
@@ -13,19 +13,20 @@ use bytes::Bytes;
use pin_project_lite::pin_project;
use rustc_hash::FxHashMap;
use thiserror::Error;
use tokio::sync::{futures::Notified, mpsc, oneshot, Notify};
use tracing::{debug_span, Instrument, Span};
use tokio::sync::{Notify, futures::Notified, mpsc, oneshot};
use tracing::{Instrument, Span, debug_span};
use crate::{
ConnectionEvent, Duration, Instant, VarInt,
mutex::Mutex,
recv_stream::RecvStream,
runtime::{AsyncTimer, AsyncUdpSocket, Runtime, UdpPoller},
send_stream::SendStream,
udp_transmit, ConnectionEvent, Duration, Instant, VarInt,
udp_transmit,
};
use proto::{
congestion::Controller, ConnectionError, ConnectionHandle, ConnectionStats, Dir, EndpointEvent,
StreamEvent, StreamId,
ConnectionError, ConnectionHandle, ConnectionStats, Dir, EndpointEvent, StreamEvent, StreamId,
congestion::Controller,
};
/// In-progress connection attempt future
+6 -5
View File
@@ -15,8 +15,9 @@ use std::{
#[cfg(all(not(wasm_browser), any(feature = "aws-lc-rs", feature = "ring")))]
use crate::runtime::default_runtime;
use crate::{
Instant,
runtime::{AsyncUdpSocket, Runtime},
udp_transmit, Instant,
udp_transmit,
};
use bytes::{Bytes, BytesMut};
use pin_project_lite::pin_project;
@@ -27,13 +28,13 @@ use proto::{
use rustc_hash::FxHashMap;
#[cfg(all(not(wasm_browser), any(feature = "aws-lc-rs", feature = "ring"),))]
use socket2::{Domain, Protocol, Socket, Type};
use tokio::sync::{futures::Notified, mpsc, Notify};
use tokio::sync::{Notify, futures::Notified, mpsc};
use tracing::{Instrument, Span};
use udp::{RecvMeta, BATCH_SIZE};
use udp::{BATCH_SIZE, RecvMeta};
use crate::{
connection::Connecting, incoming::Incoming, work_limiter::WorkLimiter, ConnectionEvent,
EndpointConfig, VarInt, IO_LOOP_BOUND, RECV_TIME_BOUND,
ConnectionEvent, EndpointConfig, IO_LOOP_BOUND, RECV_TIME_BOUND, VarInt,
connection::Connecting, incoming::Incoming, work_limiter::WorkLimiter,
};
/// A QUIC endpoint.
+8 -8
View File
@@ -67,13 +67,13 @@ pub(crate) use std::time::{Duration, Instant};
pub(crate) use web_time::{Duration, Instant};
pub use proto::{
congestion, crypto, AckFrequencyConfig, ApplicationClose, Chunk, ClientConfig, ClosedStream,
ConfigError, ConnectError, ConnectionClose, ConnectionError, ConnectionId,
ConnectionIdGenerator, ConnectionStats, Dir, EcnCodepoint, EndpointConfig, FrameStats,
FrameType, IdleTimeout, MtuDiscoveryConfig, NoneTokenLog, NoneTokenStore, PathStats,
ServerConfig, Side, StdSystemTime, StreamId, TimeSource, TokenLog, TokenReuseError, TokenStore,
Transmit, TransportConfig, TransportErrorCode, UdpStats, ValidationTokenConfig, VarInt,
VarIntBoundsExceeded, Written,
AckFrequencyConfig, ApplicationClose, Chunk, ClientConfig, ClosedStream, ConfigError,
ConnectError, ConnectionClose, ConnectionError, ConnectionId, ConnectionIdGenerator,
ConnectionStats, Dir, EcnCodepoint, EndpointConfig, FrameStats, FrameType, IdleTimeout,
MtuDiscoveryConfig, NoneTokenLog, NoneTokenStore, PathStats, ServerConfig, Side, StdSystemTime,
StreamId, TimeSource, TokenLog, TokenReuseError, TokenStore, Transmit, TransportConfig,
TransportErrorCode, UdpStats, ValidationTokenConfig, VarInt, VarIntBoundsExceeded, Written,
congestion, crypto,
};
#[cfg(any(feature = "rustls-aws-lc-rs", feature = "rustls-ring"))]
pub use rustls;
@@ -92,7 +92,7 @@ pub use crate::runtime::AsyncStdRuntime;
pub use crate::runtime::SmolRuntime;
#[cfg(feature = "runtime-tokio")]
pub use crate::runtime::TokioRuntime;
pub use crate::runtime::{default_runtime, AsyncTimer, AsyncUdpSocket, Runtime, UdpPoller};
pub use crate::runtime::{AsyncTimer, AsyncUdpSocket, Runtime, UdpPoller, default_runtime};
pub use crate::send_stream::{SendStream, StoppedError, WriteError};
#[cfg(test)]
+2 -2
View File
@@ -1,5 +1,5 @@
use std::{
future::{poll_fn, Future},
future::{Future, poll_fn},
io,
pin::Pin,
task::{Context, Poll},
@@ -10,7 +10,7 @@ use proto::{Chunk, Chunks, ClosedStream, ConnectionError, ReadableError, StreamI
use thiserror::Error;
use tokio::io::ReadBuf;
use crate::{connection::ConnectionRef, VarInt};
use crate::{VarInt, connection::ConnectionRef};
/// A stream that can only be used to receive data
///
+1 -1
View File
@@ -9,7 +9,7 @@ use std::{
use tokio::{
io::Interest,
time::{sleep_until, Sleep},
time::{Sleep, sleep_until},
};
use super::{AsyncTimer, AsyncUdpSocket, Runtime, UdpPollHelper};
+1 -1
View File
@@ -9,7 +9,7 @@ use bytes::Bytes;
use proto::{ClosedStream, ConnectionError, FinishError, StreamId, Written};
use thiserror::Error;
use crate::{connection::ConnectionRef, VarInt};
use crate::{VarInt, connection::ConnectionRef};
/// A stream that can only be used to send data
///
+3 -3
View File
@@ -16,11 +16,11 @@ use std::{
use crate::runtime::TokioRuntime;
use crate::{Duration, Instant};
use bytes::Bytes;
use proto::{crypto::rustls::QuicClientConfig, RandomConnectionIdGenerator};
use rand::{rngs::StdRng, RngCore, SeedableRng};
use proto::{RandomConnectionIdGenerator, crypto::rustls::QuicClientConfig};
use rand::{RngCore, SeedableRng, rngs::StdRng};
use rustls::{
pki_types::{CertificateDer, PrivateKeyDer, PrivatePkcs8KeyDer},
RootCertStore,
pki_types::{CertificateDer, PrivateKeyDer, PrivatePkcs8KeyDer},
};
use tokio::runtime::{Builder, Runtime};
use tracing::{error_span, info};
+1 -1
View File
@@ -102,8 +102,8 @@ async fn read_from_peer(mut stream: quinn::RecvStream) -> Result<(), quinn::Conn
Ok(())
}
Err(e) => {
use quinn::ReadToEndError::*;
use ReadError::*;
use quinn::ReadToEndError::*;
match e {
TooLong | Read(ClosedStream) | Read(ZeroRttRejected) | Read(IllegalOrderedRead) => {
unreachable!()
+1
View File
@@ -0,0 +1 @@
style_edition = "2024"