Improve error when connecting with an unsupported version

If the cryptographic layer supports a version not in the local
endpoint's supported versions list, a connection could have been
initiated with that version for which all packets returned by a
compatible peer would hav ebeendropped. This is a relatively easy
configuration error to make.
This commit is contained in:
Benjamin Saunders
2023-01-24 12:08:44 -08:00
parent e5a5d3eeb8
commit d00a71c695
+4 -1
View File
@@ -369,6 +369,9 @@ impl Endpoint {
if remote.port() == 0 || remote.ip().is_unspecified() {
return Err(ConnectError::InvalidRemoteAddress(remote));
}
if !self.config.supported_versions.contains(&config.version) {
return Err(ConnectError::UnsupportedVersion);
}
let remote_id = RandomConnectionIdGenerator::new(MAX_CID_SIZE).generate_cid();
trace!(initial_dcid = %remote_id);
@@ -830,7 +833,7 @@ pub enum ConnectError {
/// Use `Endpoint::connect_with` to specify a client configuration.
#[error("no default client config")]
NoDefaultClientConfig,
/// The cryptographic layer does not support the specified QUIC version
/// The local endpoint does not support the QUIC version specified in the client configuration
#[error("unsupported QUIC version")]
UnsupportedVersion,
}