Skip to content

Commit

Permalink
support 0-RTT in DoQ
Browse files Browse the repository at this point in the history
  • Loading branch information
msoxzw authored and bluejekyll committed Jun 4, 2022
1 parent 327942b commit 170e3f7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/proto/src/quic/quic_client_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ impl QuicClientStreamBuilder {
if crypto_config.alpn_protocols.is_empty() {
crypto_config.alpn_protocols = vec![quic_stream::DOQ_ALPN.to_vec()];
}
let early_data_enabled = crypto_config.enable_early_data;

let mut client_config = ClientConfig::new(Arc::new(crypto_config));
client_config.transport = self.transport_config;
Expand All @@ -205,7 +206,14 @@ impl QuicClientStreamBuilder {
let connecting = endpoint.connect(name_server, &dns_name)?;
// TODO: for Client/Dynamic update, don't use RTT, for queries, do use it.

let connection = connecting.await?;
let connection = if early_data_enabled {
match connecting.into_0rtt() {
Ok((new_connection, _)) => new_connection,
Err(connecting) => connecting.await?,
}
} else {
connecting.await?
};
let NewConnection {
connection: quic_connection,
..
Expand Down

0 comments on commit 170e3f7

Please sign in to comment.