pub struct ConnectionManager { /* private fields */ }Expand description
The connection manager owns the mapping from connection_id → its backing protocol state. Previously this was eight parallel hashmaps held together by convention; invariants (e.g. “if connection_types says SFTP, the sftp hashmap contains the id”) are now enforced by the variant tag itself.
Implementations§
Source§impl ConnectionManager
impl ConnectionManager
pub fn new() -> Self
pub fn with_host_keys(host_keys: Arc<HostKeyStore>) -> Self
Sourcepub fn host_keys(&self) -> Arc<HostKeyStore> ⓘ
pub fn host_keys(&self) -> Arc<HostKeyStore> ⓘ
Access the shared host-key store. Used by the macOS bridge to
expose forget over FFI for the “Trust new key” flow on a
HostKeyMismatch.
Sourcepub async fn connection_kind(&self, id: &str) -> Option<ProtocolKind>
pub async fn connection_kind(&self, id: &str) -> Option<ProtocolKind>
Protocol of an existing connection, or None if not registered.
Sourcepub async fn get_connection_type(&self, id: &str) -> Option<String>
pub async fn get_connection_type(&self, id: &str) -> Option<String>
Backward-compatible string form of connection_kind. Returns “SSH”,
“SFTP”, “FTP”, “RDP”, or “VNC”. Prefer connection_kind in new code.
pub async fn list_connections(&self) -> Vec<String>
Sourcepub async fn get_connection(&self, id: &str) -> Option<Arc<RwLock<SshClient>>>
pub async fn get_connection(&self, id: &str) -> Option<Arc<RwLock<SshClient>>>
Return the SSH client for a connection if it is an SSH connection.
pub async fn get_sftp_client( &self, id: &str, ) -> Option<Arc<RwLock<StandaloneSftpClient>>>
pub async fn get_ftp_client(&self, id: &str) -> Option<Arc<RwLock<FtpClient>>>
pub async fn get_desktop_connection( &self, id: &str, ) -> Option<Arc<RwLock<Box<dyn DesktopProtocol>>>>
pub async fn get_postgres_pool(&self, id: &str) -> Option<Arc<PgPool>>
pub async fn create_connection( &self, connection_id: String, config: SshConfig, ) -> Result<()>
pub async fn cancel_pending_connection(&self, connection_id: &str) -> bool
Sourcepub async fn close_connection(&self, connection_id: &str) -> Result<()>
pub async fn close_connection(&self, connection_id: &str) -> Result<()>
Close the SSH connection for connection_id (if it is SSH). Also tears
down any associated PTY session and prunes the generation counter so it
cannot leak across reconnects.
Sourcepub async fn start_pty_connection(
&self,
connection_id: &str,
cols: u32,
rows: u32,
) -> Result<u64>
pub async fn start_pty_connection( &self, connection_id: &str, cols: u32, rows: u32, ) -> Result<u64>
Start a PTY shell connection (like ttyd does). Enables interactive commands: vim, less, more, top, htop, etc.
Sourcepub async fn write_to_pty(
&self,
connection_id: &str,
data: Vec<u8>,
) -> Result<()>
pub async fn write_to_pty( &self, connection_id: &str, data: Vec<u8>, ) -> Result<()>
Send data to PTY (user input).
Backpressure: if the input channel is full we await send, preserving
keystroke order.
Sourcepub async fn get_pty_session(
&self,
connection_id: &str,
) -> Option<Arc<PtySession>>
pub async fn get_pty_session( &self, connection_id: &str, ) -> Option<Arc<PtySession>>
Capture the active PtySession for a connection. Used by the macOS
bridge to spawn an output-forwarder task that holds a stable handle
to the session’s output_rx for the lifetime of that PTY, even if
start_pty_connection is later called again for the same connection
(which would replace the entry in pty_sessions).
Sourcepub async fn read_pty_burst(
&self,
connection_id: &str,
max_bytes: usize,
) -> Result<Vec<u8>>
pub async fn read_pty_burst( &self, connection_id: &str, max_bytes: usize, ) -> Result<Vec<u8>>
Read a burst of PTY output — blocks until data arrives, then drains any
additional already-queued chunks up to max_bytes.
Sourcepub async fn close_pty_connection(
&self,
connection_id: &str,
expected_gen: Option<u64>,
) -> Result<()>
pub async fn close_pty_connection( &self, connection_id: &str, expected_gen: Option<u64>, ) -> Result<()>
Close PTY connection, but only if the generation matches.
Sourcepub async fn get_pty_cancel_token(
&self,
connection_id: &str,
) -> Option<CancellationToken>
pub async fn get_pty_cancel_token( &self, connection_id: &str, ) -> Option<CancellationToken>
Get the cancellation token for a PTY session (used by WebSocket reader tasks).
Sourcepub async fn resize_pty(
&self,
connection_id: &str,
cols: u32,
rows: u32,
) -> Result<()>
pub async fn resize_pty( &self, connection_id: &str, cols: u32, rows: u32, ) -> Result<()>
Resize PTY terminal (send window-change to remote SSH channel)
pub async fn create_sftp_connection( &self, connection_id: String, config: SftpConfig, ) -> Result<()>
pub async fn close_sftp_connection(&self, connection_id: &str) -> Result<()>
pub async fn create_ftp_connection( &self, connection_id: String, config: FtpConfig, ) -> Result<()>
pub async fn close_ftp_connection(&self, connection_id: &str) -> Result<()>
pub async fn create_desktop_connection( &self, connection_id: String, request: &DesktopConnectRequest, ) -> Result<(u16, u16)>
pub async fn close_desktop_connection(&self, connection_id: &str) -> Result<()>
pub async fn create_postgres_connection( &self, connection_id: String, config: PgConfig, ) -> Result<()>
pub async fn close_postgres_connection(&self, connection_id: &str) -> Result<()>
Sourcepub async fn start_desktop_stream(
&self,
connection_id: &str,
frame_tx: UnboundedSender<FrameUpdate>,
cancel: CancellationToken,
) -> Result<()>
pub async fn start_desktop_stream( &self, connection_id: &str, frame_tx: UnboundedSender<FrameUpdate>, cancel: CancellationToken, ) -> Result<()>
Start the frame update loop for a desktop connection.
Not yet wired up to the WebSocket server — kept here so the RDP/VNC stubs have a concrete dispatch point once the protocol clients gain real implementations. Remove the allow once a caller appears.