mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-21 10:43:25 +00:00
Move 0-RTT transport param validation to helper method
This commit is contained in:
committed by
Dirkjan Ochtman
parent
ac810125c1
commit
f18b95bbd7
@@ -1440,23 +1440,7 @@ where
|
||||
self.reject_0rtt();
|
||||
} else {
|
||||
self.accepted_0rtt = true;
|
||||
if params.initial_max_data < self.params.initial_max_data
|
||||
|| params.initial_max_stream_data_bidi_local
|
||||
< self.params.initial_max_stream_data_bidi_local
|
||||
|| params.initial_max_stream_data_bidi_remote
|
||||
< self.params.initial_max_stream_data_bidi_remote
|
||||
|| params.initial_max_stream_data_uni
|
||||
< self.params.initial_max_stream_data_uni
|
||||
|| params.initial_max_streams_bidi
|
||||
< self.params.initial_max_streams_bidi
|
||||
|| params.initial_max_streams_uni
|
||||
< self.params.initial_max_streams_uni
|
||||
{
|
||||
return Err(TransportError::PROTOCOL_VIOLATION(
|
||||
"flow control parameters were reduced wrt. 0-RTT",
|
||||
)
|
||||
.into());
|
||||
}
|
||||
params.validate_0rtt(&self.params)?;
|
||||
}
|
||||
}
|
||||
if let Some(token) = params.stateless_reset_token {
|
||||
|
||||
@@ -94,6 +94,24 @@ impl TransportParameters {
|
||||
..Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// Check that these parameters are legal when resuming from
|
||||
/// certain cached parameters
|
||||
pub fn validate_0rtt(&self, cached: &TransportParameters) -> Result<(), TransportError> {
|
||||
if cached.initial_max_data < self.initial_max_data
|
||||
|| cached.initial_max_stream_data_bidi_local < self.initial_max_stream_data_bidi_local
|
||||
|| cached.initial_max_stream_data_bidi_remote < self.initial_max_stream_data_bidi_remote
|
||||
|| cached.initial_max_stream_data_uni < self.initial_max_stream_data_uni
|
||||
|| cached.initial_max_streams_bidi < self.initial_max_streams_bidi
|
||||
|| cached.initial_max_streams_uni < self.initial_max_streams_uni
|
||||
{
|
||||
return Err(TransportError::PROTOCOL_VIOLATION(
|
||||
"0-RTT accepted with incompatible transport parameters",
|
||||
)
|
||||
.into());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
|
||||
Reference in New Issue
Block a user