Skip to content

Commit

Permalink
feat: Option for no zero-len CIDs for client (mozilla#2171)
Browse files Browse the repository at this point in the history
* feat: No zero-len CIDs for client

They break the upcoming QNS migration tests.

* Add command line parameter

* Fix message

* Don't enable for migration tests - not needed
  • Loading branch information
larseggert authored Nov 11, 2024
1 parent 02c5147 commit f11ce06
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
14 changes: 10 additions & 4 deletions neqo-bin/src/client/http09.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<RefCell<dyn ConnectionIdGenerator>> = 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),
Expand Down
12 changes: 10 additions & 2 deletions neqo-bin/src/client/http3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -64,10 +64,18 @@ pub fn create_client(
hostname: &str,
resumption_token: Option<ResumptionToken>,
) -> Res<Http3Client> {
let cid_generator: Rc<RefCell<dyn neqo_transport::ConnectionIdGenerator>> = 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()),
Expand Down
14 changes: 7 additions & 7 deletions neqo-bin/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -198,6 +203,7 @@ impl Args {
test: None,
upload_size: if upload { requests[0] } else { 100 },
stats: false,
cid_len: 0,
}
}

Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit f11ce06

Please sign in to comment.