From d00a71c695faeee1caee194de84dc2c54c8c67f2 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Tue, 24 Jan 2023 12:08:44 -0800 Subject: [PATCH] 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. --- quinn-proto/src/endpoint.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/quinn-proto/src/endpoint.rs b/quinn-proto/src/endpoint.rs index cb97707fc..72046bbda 100644 --- a/quinn-proto/src/endpoint.rs +++ b/quinn-proto/src/endpoint.rs @@ -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, }