diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 86eb117..851adef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -122,6 +122,24 @@ impl russh::server::Handler for Server { async fn channel_close(self, channel: ChannelId, session: Session) -> Result<(Self, Session)> { println!("[info] [{}] close session", channel); + + { + let mut clients = self.clients.lock().await; + + let mut del_id = None; + for ((id, ch), _) in clients.iter() { + if *ch == channel { + del_id = Some(*id); + } + } + + if let Some(id) = del_id { + clients.remove(&(id, channel)); + } else { + println!("[warn] [{}] no session", channel); + } + } + Ok((self, session)) } } |