diff --git a/neqo-bin/src/client/http09.rs b/neqo-bin/src/client/http09.rs index 07ea63923e..e7135fc0e7 100644 --- a/neqo-bin/src/client/http09.rs +++ b/neqo-bin/src/client/http09.rs @@ -20,8 +20,8 @@ use std::{ use neqo_common::{event::Provider, qdebug, qinfo, qwarn, Datagram}; use neqo_crypto::{AuthenticationStatus, ResumptionToken}; use neqo_transport::{ - CloseReason, Connection, ConnectionEvent, EmptyConnectionIdGenerator, Error, Output, State, - StreamId, StreamType, + CloseReason, Connection, ConnectionEvent, ConnectionIdGenerator, EmptyConnectionIdGenerator, + Error, Output, RandomConnectionIdGenerator, State, StreamId, StreamType, }; use url::Url; @@ -154,11 +154,17 @@ pub fn create_client( "hq-29" | "hq-30" | "hq-31" | "hq-32" => args.shared.alpn.as_str(), _ => "hq-interop", }; - + let cid_generator: Rc> = if args.cid_len == 0 { + Rc::new(RefCell::new(EmptyConnectionIdGenerator::default())) + } else { + Rc::new(RefCell::new(RandomConnectionIdGenerator::new( + args.cid_len.into(), + ))) + }; let mut client = Connection::new_client( hostname, &[alpn], - Rc::new(RefCell::new(EmptyConnectionIdGenerator::default())), + cid_generator, local_addr, remote_addr, args.shared.quic_parameters.get(alpn), diff --git a/neqo-bin/src/client/http3.rs b/neqo-bin/src/client/http3.rs index b847f9a5f4..3a5a777cb6 100644 --- a/neqo-bin/src/client/http3.rs +++ b/neqo-bin/src/client/http3.rs @@ -23,7 +23,7 @@ use neqo_crypto::{AuthenticationStatus, ResumptionToken}; use neqo_http3::{Error, Http3Client, Http3ClientEvent, Http3Parameters, Http3State, Priority}; use neqo_transport::{ AppError, CloseReason, Connection, EmptyConnectionIdGenerator, Error as TransportError, Output, - StreamId, + RandomConnectionIdGenerator, StreamId, }; use url::Url; @@ -64,10 +64,18 @@ pub fn create_client( hostname: &str, resumption_token: Option, ) -> Res { + let cid_generator: Rc> = if args.cid_len == 0 + { + Rc::new(RefCell::new(EmptyConnectionIdGenerator::default())) + } else { + Rc::new(RefCell::new(RandomConnectionIdGenerator::new( + args.cid_len.into(), + ))) + }; let mut transport = Connection::new_client( hostname, &[&args.shared.alpn], - Rc::new(RefCell::new(EmptyConnectionIdGenerator::default())), + cid_generator, local_addr, remote_addr, args.shared.quic_parameters.get(args.shared.alpn.as_str()), diff --git a/neqo-bin/src/client/mod.rs b/neqo-bin/src/client/mod.rs index 6b785c5eb6..78cd2c649f 100644 --- a/neqo-bin/src/client/mod.rs +++ b/neqo-bin/src/client/mod.rs @@ -169,6 +169,11 @@ pub struct Args { /// Print connection stats after close. #[arg(name = "stats", long)] stats: bool, + + /// The length of the local connection ID. + #[arg(name = "cid-length", short = 'l', long, default_value = "0", + value_parser = clap::value_parser!(u8).range(..=20))] + cid_len: u8, } impl Args { @@ -198,6 +203,7 @@ impl Args { test: None, upload_size: if upload { requests[0] } else { 100 }, stats: false, + cid_len: 0, } } @@ -245,13 +251,7 @@ impl Args { self.method = String::from("POST"); } } - "handshake" - | "transfer" - | "retry" - | "ecn" - | "rebind-port" - | "rebind-addr" - | "connectionmigration" => {} + "handshake" | "transfer" | "retry" | "ecn" => {} "resumption" => { if self.urls.len() < 2 { qerror!("Warning: resumption test won't work without >1 URL");