Add cid len check to enable multipath

This commit is contained in:
Floris Bruynooghe
2025-02-27 15:27:36 +01:00
parent 67ccddb860
commit ea23a93080
2 changed files with 6 additions and 2 deletions
+2 -2
View File
@@ -1437,9 +1437,9 @@ impl Connection {
/// Multipath is only enabled after the handshake is completed and if it was negotiated
/// by both peers.
pub fn is_multipath_enabled(&self) -> bool {
// TODO(flub): Multipath can only be enabled if both sides use non-zero length CIDs.
// Also check that.
!self.is_handshaking()
&& self.handshake_cid.len() > 0
&& self.rem_handshake_cid.len() > 0
&& self.config.initial_max_path_id.is_some()
&& self.peer_params.initial_max_path_id.is_some()
}
+4
View File
@@ -98,6 +98,10 @@ impl ConnectionId {
res
}
pub(crate) fn len(&self) -> usize {
self.len as usize
}
/// Decode from long header format
pub(crate) fn decode_long(buf: &mut impl Buf) -> Option<Self> {
let len = buf.get::<u8>().ok()? as usize;