//! SSH server implementation using russh. pub mod git; pub mod handler; pub mod sftp; pub mod terminal; use std::net::SocketAddr; use std::path::PathBuf; use std::sync::Arc; use crate::api::MnwApiClient; /// SSH server that spawns a new handler per connection. pub struct MnwServer { api: MnwApiClient, staging_dir: Arc, git_user: Arc, } impl MnwServer { pub fn new(api: MnwApiClient, staging_dir: Arc, git_user: String) -> Self { Self { api, staging_dir, git_user: Arc::from(git_user), } } } impl russh::server::Server for MnwServer { type Handler = handler::MnwHandler; fn new_client(&mut self, peer_addr: Option) -> Self::Handler { tracing::info!(?peer_addr, "new SSH connection"); handler::MnwHandler::new( self.api.clone(), peer_addr, Arc::clone(&self.staging_dir), Arc::clone(&self.git_user), ) } }