Skip to content

Commit c0a7cad

Browse files
committed
cleanup
1 parent 8f7d150 commit c0a7cad

File tree

14 files changed

+40
-118
lines changed

14 files changed

+40
-118
lines changed

h3i/src/client/async_client.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,8 @@ pub async fn connect(
8080
close_trigger_frames: Option<CloseTriggerFrames>,
8181
) -> std::result::Result<BuildingConnectionSummary, ClientError> {
8282
let quic_settings = create_config(args);
83-
let mut connection_params = ConnectionParams::new_client(
84-
quic_settings,
85-
None,
86-
Hooks::default(),
87-
false,
88-
);
83+
let mut connection_params =
84+
ConnectionParams::new_client(quic_settings, None, Hooks::default());
8985

9086
connection_params.session = args.session.clone();
9187

@@ -431,9 +427,9 @@ impl ApplicationOverQuic for H3iDriver {
431427
&mut self, qconn: &mut QuicheConnection, _metrics: &M,
432428
_work_loop_result: &QuicResult<()>,
433429
) {
434-
let _ = self.record_tx.send(ConnectionRecord::Close(
435-
ConnectionCloseDetails::new(qconn, false),
436-
));
430+
let _ = self
431+
.record_tx
432+
.send(ConnectionRecord::Close(ConnectionCloseDetails::new(qconn)));
437433

438434
let _ = self
439435
.record_tx

h3i/src/client/connection_summary.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,6 @@ pub struct ConnectionCloseDetails {
394394
pub timed_out: bool,
395395
/// Return the session from the underlying connection.
396396
pub session: Option<Vec<u8>>,
397-
/// Early data was sent by the client.
398-
pub early_data_sent: bool,
399397
}
400398

401399
impl core::fmt::Debug for ConnectionCloseDetails {
@@ -410,14 +408,13 @@ impl core::fmt::Debug for ConnectionCloseDetails {
410408
}
411409

412410
impl ConnectionCloseDetails {
413-
pub fn new(qconn: &Connection, early_data_sent: bool) -> Self {
411+
pub fn new(qconn: &Connection) -> Self {
414412
let session = qconn.session().map(|s| s.to_vec());
415413
Self {
416414
peer_error: qconn.peer_error().cloned(),
417415
local_error: qconn.local_error().cloned(),
418416
timed_out: qconn.is_timed_out(),
419417
session,
420-
early_data_sent,
421418
}
422419
}
423420

h3i/src/client/sync_client.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,10 @@ pub fn connect(
208208
let (write, send_info) = conn.send(&mut out).expect("initial send failed");
209209

210210
let mut client = SyncClient::new(close_trigger_frames);
211-
let early_data_sent = match early_actions {
212-
Some(early_actions) if conn.is_in_early_data() => {
211+
// Send early data if connection is_in_early_data (resumption with 0-RTT was
212+
// successful) and if we have early_actions.
213+
if conn.is_in_early_data() {
214+
if let Some(early_actions) = early_actions {
213215
let mut early_action_iter = early_actions.iter();
214216
let mut wait_duration = None;
215217
let mut wait_instant = None;
@@ -223,10 +225,8 @@ pub fn connect(
223225
&mut waiting_for,
224226
client.stream_parsers_mut(),
225227
);
226-
true
227-
},
228-
_ => false,
229-
};
228+
}
229+
}
230230

231231
while let Err(e) = socket.send_to(&out[..write], send_info.to) {
232232
if e.kind() == std::io::ErrorKind::WouldBlock {
@@ -478,7 +478,7 @@ pub fn connect(
478478
stream_map: client.streams,
479479
stats: Some(conn.stats()),
480480
path_stats: conn.path_stats().collect(),
481-
conn_close_details: ConnectionCloseDetails::new(&conn, early_data_sent),
481+
conn_close_details: ConnectionCloseDetails::new(&conn),
482482
})
483483
}
484484

quiche/src/lib.rs

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7129,55 +7129,14 @@ impl<F: BufFactory> Connection<F> {
71297129
self.handshake.is_in_early_data()
71307130
}
71317131

7132-
// #[rustfmt::skip]
7133-
/// https://commondatastorage.googleapis.com/chromium-boringssl-docs/ssl.h.html#ssl_early_data_reason_t
7132+
/// Returns the early data reason for the connection.
71347133
///
7135-
/// // The handshake has not progressed far enough for the 0-RTT status to
7136-
/// // be known.
7137-
/// ssl_early_data_unknown = 0,
7134+
/// This status can be useful for logging and debugging. See [BoringSSL]
7135+
/// documentation for a definition of the reasons.
71387136
///
7139-
/// // 0-RTT is disabled for this connection.
7140-
/// ssl_early_data_disabled = 1,
7141-
///
7142-
/// // 0-RTT was accepted.
7143-
/// ssl_early_data_accepted = 2,
7144-
///
7145-
/// // The negotiated protocol version does not support 0-RTT.
7146-
/// ssl_early_data_protocol_version = 3,
7147-
///
7148-
/// // The peer declined to offer or accept 0-RTT for an unknown reason.
7149-
/// ssl_early_data_peer_declined = 4,
7150-
///
7151-
/// // The client did not offer a session.
7152-
/// ssl_early_data_no_session_offered = 5,
7153-
///
7154-
/// // The server declined to resume the session.
7155-
/// ssl_early_data_session_not_resumed = 6,
7156-
///
7157-
/// // The session does not support 0-RTT.
7158-
/// ssl_early_data_unsupported_for_session = 7,
7159-
///
7160-
/// // The server sent a HelloRetryRequest.
7161-
/// ssl_early_data_hello_retry_request = 8,
7162-
///
7163-
/// // The negotiated ALPN protocol did not match the session.
7164-
/// ssl_early_data_alpn_mismatch = 9,
7165-
///
7166-
/// // The connection negotiated Channel ID, which is incompatible with
7167-
/// // 0-RTT.
7168-
/// ssl_early_data_channel_id = 10,
7169-
///
7170-
/// // Value 11 is reserved. (It has historically
7171-
/// |ssl_early_data_token_binding|.) // The client and server ticket age
7172-
/// were too far apart. ssl_early_data_ticket_age_skew = 12,
7173-
///
7174-
/// // QUIC parameters differ between this connection and the original.
7175-
/// ssl_early_data_quic_parameter_mismatch = 13,
7176-
///
7177-
/// // The application settings did not match the session.
7178-
/// ssl_early_data_alps_mismatch = 14,
7137+
/// [BoringSSL]: https://commondatastorage.googleapis.com/chromium-boringssl-docs/ssl.h.html#ssl_early_data_reason_t
71797138
#[inline]
7180-
pub fn get_early_data_reason(&self) -> u32 {
7139+
pub fn early_data_reason(&self) -> u32 {
71817140
self.handshake.early_reason()
71827141
}
71837142

quiche/src/tls/boringssl.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ impl Handshake {
276276
}
277277

278278
pub fn early_reason(&self) -> u32 {
279-
// unsafe { SSL_in_early_data(self.as_ptr()) == 1 }
280279
let reuse_reason_status =
281280
unsafe { SSL_get_early_data_reason(self.as_ptr()) };
282281
reuse_reason_status.0
@@ -352,7 +351,6 @@ extern "C" {
352351

353352
fn SSL_in_early_data(ssl: *const SSL) -> c_int;
354353

355-
// enum ssl_early_data_reason_t SSL_get_early_data_reason(const SSL *ssl);
356354
fn SSL_get_early_data_reason(ssl: *const SSL) -> ssl_early_data_reason_t;
357355

358356
fn SSL_SESSION_to_bytes(

tokio-quiche/examples/async_http3_server/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ async fn main() {
6767
kind: CertificateKind::X509,
6868
},
6969
Hooks::default(),
70-
false,
7170
),
7271
SimpleConnectionIdGenerator,
7372
DefaultMetrics,

tokio-quiche/src/quic/io/connection_stage.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ impl ConnectionStage for Handshake {
122122
&mut self, qconn: &mut QuicheConnection,
123123
_ctx: &mut ConnectionStageContext<A>,
124124
) -> ControlFlow<QuicResult<()>> {
125+
// Transition to RunningApplication if we have 1-RTT keys (handshake is
126+
// complete) or if we have 0-RTT keys (in early data).
125127
if qconn.is_established() || qconn.is_in_early_data() {
126128
ControlFlow::Break(Ok(()))
127129
} else {

tokio-quiche/src/quic/router/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,6 @@ mod tests {
891891
quic_settings,
892892
tls_cert_settings,
893893
Hooks::default(),
894-
false,
895894
);
896895
let config = Config::new(&params, SocketCapabilities::default()).unwrap();
897896

tokio-quiche/src/settings/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ fn make_quiche_config(
203203
track_unknown_transport_params,
204204
);
205205
}
206-
if params.enable_early_data {
206+
if params.settings.enable_early_data {
207207
config.enable_early_data();
208208
}
209209

tokio-quiche/src/settings/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ pub struct ConnectionParams<'a> {
5555
pub hooks: Hooks,
5656
/// Set the session to attempt resumption.
5757
pub session: Option<Vec<u8>>,
58-
/// Enables early data.
59-
pub enable_early_data: bool,
6058
}
6159

6260
impl core::fmt::Debug for ConnectionParams<'_> {
@@ -76,14 +74,12 @@ impl<'a> ConnectionParams<'a> {
7674
#[inline]
7775
pub fn new_server(
7876
settings: QuicSettings, tls_cert: TlsCertificatePaths<'a>, hooks: Hooks,
79-
enable_early_data: bool,
8077
) -> Self {
8178
Self {
8279
settings,
8380
tls_cert: Some(tls_cert),
8481
hooks,
8582
session: None,
86-
enable_early_data,
8783
}
8884
}
8985

@@ -92,14 +88,13 @@ impl<'a> ConnectionParams<'a> {
9288
#[inline]
9389
pub fn new_client(
9490
settings: QuicSettings, tls_cert: Option<TlsCertificatePaths<'a>>,
95-
hooks: Hooks, enable_early_data: bool,
91+
hooks: Hooks,
9692
) -> Self {
9793
Self {
9894
settings,
9995
tls_cert,
10096
hooks,
10197
session: None,
102-
enable_early_data,
10398
}
10499
}
105100
}

0 commit comments

Comments
 (0)