From dc1f75aee3487dddbe7abdd354e8315d7838b03b Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Sun, 20 Apr 2025 21:21:07 +0200 Subject: [PATCH] Close any remaining connections once the tui exits --- src/ssh/handler.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ssh/handler.rs b/src/ssh/handler.rs index 0ed3515..784b344 100644 --- a/src/ssh/handler.rs +++ b/src/ssh/handler.rs @@ -330,6 +330,26 @@ impl russh::server::Handler for Handler { Ok(session.channel_success(channel)?) } + async fn channel_close( + &mut self, + channel: ChannelId, + session: &mut Session, + ) -> Result<(), Self::Error> { + if let Some(pty_channel) = self.pty_channel + && pty_channel == channel + { + debug!("Pty channel closed"); + + session.disconnect( + russh::Disconnect::ByApplication, + "Remaining active connections have been closed", + "EN", + )?; + } + + Ok(()) + } + async fn tcpip_forward( &mut self, address: &str,