mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-21 02:33:23 +00:00
Fail accept immediately on stale Incoming
This commit is contained in:
committed by
Dirkjan Ochtman
parent
ff4663b696
commit
df7f58e19b
@@ -31,8 +31,8 @@ use crate::{
|
||||
},
|
||||
token::TokenDecodeError,
|
||||
transport_parameters::{PreferredAddress, TransportParameters},
|
||||
Instant, ResetToken, RetryToken, Side, SystemTime, Transmit, TransportConfig, TransportError,
|
||||
INITIAL_MTU, MAX_CID_SIZE, MIN_INITIAL_SIZE, RESET_TOKEN_SIZE,
|
||||
Duration, Instant, ResetToken, RetryToken, Side, SystemTime, Transmit, TransportConfig,
|
||||
TransportError, INITIAL_MTU, MAX_CID_SIZE, MIN_INITIAL_SIZE, RESET_TOKEN_SIZE,
|
||||
};
|
||||
|
||||
/// The main entry point to the library
|
||||
@@ -571,6 +571,23 @@ impl Endpoint {
|
||||
version,
|
||||
..
|
||||
} = incoming.packet.header;
|
||||
let server_config =
|
||||
server_config.unwrap_or_else(|| self.server_config.as_ref().unwrap().clone());
|
||||
|
||||
if server_config
|
||||
.transport
|
||||
.max_idle_timeout
|
||||
.is_some_and(|timeout| {
|
||||
incoming.received_at + Duration::from_millis(timeout.into()) <= now
|
||||
})
|
||||
{
|
||||
debug!("abandoning accept of stale initial");
|
||||
self.index.remove_initial(dst_cid);
|
||||
return Err(AcceptError {
|
||||
cause: ConnectionError::TimedOut,
|
||||
response: None,
|
||||
});
|
||||
}
|
||||
|
||||
if self.cids_exhausted() {
|
||||
debug!("refusing connection");
|
||||
@@ -588,9 +605,6 @@ impl Endpoint {
|
||||
});
|
||||
}
|
||||
|
||||
let server_config =
|
||||
server_config.unwrap_or_else(|| self.server_config.as_ref().unwrap().clone());
|
||||
|
||||
if incoming
|
||||
.crypto
|
||||
.packet
|
||||
|
||||
Reference in New Issue
Block a user