Slightly simplified error handling for ngtcp2_conn_read_pkt
This commit is contained in:
parent
76ffd6bf96
commit
59d6828848
|
@ -342,6 +342,7 @@ struct Client {
|
||||||
ev_timer pkt_timer;
|
ev_timer pkt_timer;
|
||||||
ngtcp2_conn *conn;
|
ngtcp2_conn *conn;
|
||||||
ngtcp2_connection_close_error last_error;
|
ngtcp2_connection_close_error last_error;
|
||||||
|
uint8_t tls_alert;
|
||||||
bool close_requested;
|
bool close_requested;
|
||||||
FILE *qlog_file;
|
FILE *qlog_file;
|
||||||
|
|
||||||
|
|
|
@ -574,10 +574,7 @@ int Client::quic_on_tx_secret(ngtcp2_crypto_level level, const uint8_t *secret,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::quic_set_tls_alert(uint8_t alert) {
|
void Client::quic_set_tls_alert(uint8_t alert) { quic.tls_alert = alert; }
|
||||||
ngtcp2_connection_close_error_set_transport_error_tls_alert(
|
|
||||||
&quic.last_error, alert, nullptr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Client::quic_write_client_handshake(ngtcp2_crypto_level level,
|
void Client::quic_write_client_handshake(ngtcp2_crypto_level level,
|
||||||
const uint8_t *data, size_t datalen) {
|
const uint8_t *data, size_t datalen) {
|
||||||
|
@ -656,8 +653,13 @@ int Client::read_quic() {
|
||||||
std::cerr << "ngtcp2_conn_read_pkt: " << ngtcp2_strerror(rv) << std::endl;
|
std::cerr << "ngtcp2_conn_read_pkt: " << ngtcp2_strerror(rv) << std::endl;
|
||||||
|
|
||||||
if (!quic.last_error.error_code) {
|
if (!quic.last_error.error_code) {
|
||||||
ngtcp2_connection_close_error_set_transport_error_liberr(
|
if (rv == NGTCP2_ERR_CRYPTO) {
|
||||||
&quic.last_error, rv, nullptr, 0);
|
ngtcp2_connection_close_error_set_transport_error_tls_alert(
|
||||||
|
&quic.last_error, quic.tls_alert, nullptr, 0);
|
||||||
|
} else {
|
||||||
|
ngtcp2_connection_close_error_set_transport_error_liberr(
|
||||||
|
&quic.last_error, rv, nullptr, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -1786,14 +1786,11 @@ int Http3Upstream::on_read(const UpstreamAddr *faddr,
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
case NGTCP2_ERR_REQUIRED_TRANSPORT_PARAM:
|
case NGTCP2_ERR_CRYPTO:
|
||||||
case NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM:
|
if (!last_error_.error_code) {
|
||||||
case NGTCP2_ERR_TRANSPORT_PARAM:
|
ngtcp2_connection_close_error_set_transport_error_tls_alert(
|
||||||
// If rv indicates transport_parameters related error, we should
|
&last_error_, tls_alert_, nullptr, 0);
|
||||||
// send TRANSPORT_PARAMETER_ERROR even if last_error_.code is
|
}
|
||||||
// already set. This is because OpenSSL might set Alert.
|
|
||||||
ngtcp2_connection_close_error_set_transport_error_liberr(&last_error_, rv,
|
|
||||||
nullptr, 0);
|
|
||||||
break;
|
break;
|
||||||
case NGTCP2_ERR_DROP_CONN:
|
case NGTCP2_ERR_DROP_CONN:
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue