Skip to main content

ssh_commander_core/
lib.rs

1//! ssh-commander-core: Rust domain layer for R-Shell.
2//!
3//! This crate owns all connection and protocol logic:
4//! SSH, PTY lifecycle, host-key handling, connection manager,
5//! SFTP, FTP, desktop protocol (RDP/VNC), and Keychain integration.
6//!
7//! # Thread Safety
8//!
9//! - `ConnectionManager`: `Send + Sync`. All public methods are `async`.
10//!   Callers must be running inside a Tokio runtime. Internally uses
11//!   `Arc<RwLock<HashMap>>` — fine to call from any task, but the task
12//!   must live on the Tokio runtime.
13//! - `SshClient`: `Send` (not `Sync`). Single-owner state; wrap in
14//!   `Arc<RwLock<SshClient>>` to share across tasks (as `ConnectionManager` does).
15//! - `StandaloneSftpClient`, `FtpClient`: Same pattern as `SshClient`.
16//! - `HostKeyStore`: `Send + Sync`. Uses `tokio::sync::Mutex` internally.
17//!   Safe to share via `Arc`.
18//! - `keychain` module: Synchronous only. Do **not** call from a Tokio
19//!   `spawn_blocking` is fine; do not hold an `.await` across a keychain call.
20//! - `PtySession`: `Send`. The `output_rx` field is `Arc<Mutex<Receiver>>`
21//!   for sharing. `input_tx` and `resize_tx` are cloneable `Sender`s.
22//! - `DesktopProtocol` trait: Requires `Send + Sync`. Implementations
23//!   (`RdpClient`, `VncClient`) are `Send` (not `Sync`) — wrap in
24//!   `Arc<RwLock<Box<dyn DesktopProtocol>>>`.
25
26pub mod connection_manager;
27pub mod desktop_protocol;
28pub mod ftp_client;
29pub mod keychain;
30pub mod postgres;
31pub mod rdp_client;
32pub mod sftp_client;
33pub mod ssh;
34pub mod tools;
35pub mod vnc_client;
36
37pub mod event_bus;
38
39pub use connection_manager::{ConnectionManager, ManagedConnection, ProtocolKind};
40pub use desktop_protocol::{
41    DesktopConnectRequest, DesktopConnectResponse, DesktopKind, DesktopProtocol, FrameUpdate,
42    RdpConfig, VncConfig,
43};
44pub use event_bus::CoreEvent;
45pub use keychain::{
46    CredentialKind, delete_password, is_supported, list_accounts, load_password, save_password,
47};
48pub use postgres::{
49    ActiveCursor, BROWSER_SESSION_ID, ColumnDetail, ColumnMeta, DbSummary, ExecutionOutcome,
50    InsertColumnInput, InsertedRow, ObjectType, ObjectTypeKind, PageResult, PgAuthMethod, PgConfig,
51    PgError, PgPool, PgTlsMode, Relation, RelationKind, Routine, RoutineKind, SchemaContents,
52    SchemaSummary, Sequence, SshTunnelRef, UpdateOutcome,
53};
54pub use sftp_client::{
55    FileEntry, FileEntryType, RemoteFileEntry, SftpAuthMethod, SftpConfig, StandaloneSftpClient,
56};
57pub use ssh::{
58    AuthMethod, CommandOutput, HostKeyMismatch, HostKeyStore, HostKeyStoreAccessError,
59    HostKeyVerificationFailure, PtySession, SshClient, SshConfig,
60};
61pub use tools::{
62    DnsAnswer, DnsQuery, GitStatus, ListeningPort, TcpdumpEvent, TcpdumpRegistry, ToolsError,
63    dns_resolve_local, dns_resolve_remote, git_status, listening_ports,
64};
65
66pub fn core_version() -> &'static str {
67    env!("CARGO_PKG_VERSION")
68}