Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Option for no zero-len CIDs for client #2171

Merged
merged 6 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -133,11 +133,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 @@ -69,10 +69,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
20 changes: 13 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: 100,
stats: false,
cid_len: 0,
}
}

Expand Down Expand Up @@ -245,13 +251,13 @@ impl Args {
self.method = String::from("POST");
}
}
"handshake"
| "transfer"
| "retry"
| "ecn"
| "rebind-port"
| "rebind-addr"
| "connectionmigration" => {}
"handshake" | "transfer" | "retry" | "ecn" => {}
larseggert marked this conversation as resolved.
Show resolved Hide resolved
"rebind-port" | "rebind-addr" | "connectionmigration" => {
if self.cid_len == 0 {
qinfo!("Rebind/migration test won't work with len-0 CID; overwriting to 8");
self.cid_len = 8;
}
larseggert marked this conversation as resolved.
Show resolved Hide resolved
}
"resumption" => {
if self.urls.len() < 2 {
qerror!("Warning: resumption test won't work without >1 URL");
Expand Down
Loading