From e8068160235738ce8137d7abad5c154a422d6014 Mon Sep 17 00:00:00 2001 From: Robert Ream Date: Sun, 26 May 2024 18:07:22 -0700 Subject: [PATCH] fix rejection --- srt-protocol/src/protocol/pending_connection/listen.rs | 7 ++++--- .../src/protocol/pending_connection/rendezvous.rs | 4 ++-- srt-tokio/src/socket/listen.rs | 7 ++++++- srt-tokio/src/socket/rendezvous.rs | 8 +++++++- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/srt-protocol/src/protocol/pending_connection/listen.rs b/srt-protocol/src/protocol/pending_connection/listen.rs index fbc0553a..7b863fea 100644 --- a/srt-protocol/src/protocol/pending_connection/listen.rs +++ b/srt-protocol/src/protocol/pending_connection/listen.rs @@ -96,7 +96,7 @@ impl Listen { } pub fn handle_timer(&self, _now: Instant) -> ConnectionResult { - ConnectionResult::NoAction + NoAction } fn handle_control_packets( @@ -299,13 +299,14 @@ impl Listen { } fn make_rejection( - &self, + &mut self, response_to: &HandshakeControlInfo, from: SocketAddr, timestamp: TimeStamp, r: ConnectionReject, ) -> ConnectionResult { - ConnectionResult::Reject( + self.state = InductionWait; + Reject( Some(( ControlPacket { timestamp, diff --git a/srt-protocol/src/protocol/pending_connection/rendezvous.rs b/srt-protocol/src/protocol/pending_connection/rendezvous.rs index c211e69f..5bef6cd4 100644 --- a/srt-protocol/src/protocol/pending_connection/rendezvous.rs +++ b/srt-protocol/src/protocol/pending_connection/rendezvous.rs @@ -166,12 +166,12 @@ impl Rendezvous { // } fn make_rejection( - &self, + &mut self, response_to: &HandshakeControlInfo, timestamp: TimeStamp, r: ConnectionReject, ) -> ConnectionResult { - ConnectionResult::Reject( + Reject( Some(( ControlPacket { timestamp, diff --git a/srt-tokio/src/socket/listen.rs b/srt-tokio/src/socket/listen.rs index 7202feb1..9ae7c71e 100644 --- a/srt-tokio/src/socket/listen.rs +++ b/srt-tokio/src/socket/listen.rs @@ -34,7 +34,12 @@ pub async fn bind_with( NotHandled(e) => { warn!("{:?}", e); } - Reject(_, _) => todo!(), + Reject(packet, e) => { + warn!("{:?}", e); + if let Some(packet) = packet { + let _ = socket.send(packet).await?; + } + } Connected(p, connection) => { if let Some(packet) = p { let _ = socket.send(packet).await?; diff --git a/srt-tokio/src/socket/rendezvous.rs b/srt-tokio/src/socket/rendezvous.rs index dfcf3daf..c9e8ccbf 100644 --- a/srt-tokio/src/socket/rendezvous.rs +++ b/srt-tokio/src/socket/rendezvous.rs @@ -43,7 +43,13 @@ pub async fn bind_with( NotHandled(e) => { warn!("rendezvous {:?} error: {}", socket_id, e); } - Reject(_, _) => todo!(), + Reject(p, e) => { + warn!("rendezvous {:?} error: {}", socket_id, e); + if let Some(packet) = p { + let _ = socket.send(packet).await?; + } + return Err(io::Error::new(io::ErrorKind::ConnectionRefused, e)); + } Connected(p, connection) => { if let Some(packet) = p { let _ = socket.send(packet).await?;