From 7cd5ed6fc6f3f27a0da27f3c3522dd3e1fd17122 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 29 Jun 2019 16:48:11 +0900 Subject: [PATCH] Handle Retry --- src/h2load_quic.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/h2load_quic.cc b/src/h2load_quic.cc index a591b68b..0467d2d6 100644 --- a/src/h2load_quic.cc +++ b/src/h2load_quic.cc @@ -107,6 +107,21 @@ int Client::quic_handshake_completed() { return connection_made(); } +namespace { +int recv_retry(ngtcp2_conn *conn, const ngtcp2_pkt_hd *hd, + const ngtcp2_pkt_retry *retry, void *user_data) { + // Re-generate handshake secrets here because connection ID might + // change. + auto c = static_cast(user_data); + + if (c->quic_setup_initial_crypto() != 0) { + return NGTCP2_ERR_CALLBACK_FAILURE; + } + + return 0; +} +} // namespace + namespace { ssize_t in_encrypt(ngtcp2_conn *conn, uint8_t *dest, size_t destlen, const uint8_t *plaintext, size_t plaintextlen, @@ -550,7 +565,7 @@ int Client::quic_init(const sockaddr *local_addr, socklen_t local_addrlen, nullptr, // stream_open h2load::stream_close, nullptr, // recv_stateless_reset - nullptr, // recv_retry + h2load::recv_retry, h2load::extend_max_local_streams_bidi, nullptr, // extend_max_local_streams_uni nullptr, // rand