|
|
@ -26,10 +26,6 @@ use distant_core::{DistantApiServerHandler, DistantClient, DistantSingleKeyCrede
|
|
|
|
use log::*;
|
|
|
|
use log::*;
|
|
|
|
use smol::channel::Receiver as SmolReceiver;
|
|
|
|
use smol::channel::Receiver as SmolReceiver;
|
|
|
|
use tokio::sync::Mutex;
|
|
|
|
use tokio::sync::Mutex;
|
|
|
|
use wezterm_ssh::{
|
|
|
|
|
|
|
|
ChildKiller, Config as WezConfig, MasterPty, PtySize, Session as WezSession,
|
|
|
|
|
|
|
|
SessionEvent as WezSessionEvent,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mod api;
|
|
|
|
mod api;
|
|
|
|
mod process;
|
|
|
|
mod process;
|
|
|
@ -58,78 +54,6 @@ impl SshFamily {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Represents the backend to use for ssh operations
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
|
|
|
|
|
|
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
|
|
|
|
|
|
|
#[cfg_attr(feature = "serde", serde(rename_all = "lowercase"))]
|
|
|
|
|
|
|
|
pub enum SshBackend {
|
|
|
|
|
|
|
|
/// Use libssh as backend
|
|
|
|
|
|
|
|
#[cfg(feature = "libssh")]
|
|
|
|
|
|
|
|
LibSsh,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Use ssh2 as backend
|
|
|
|
|
|
|
|
#[cfg(feature = "ssh2")]
|
|
|
|
|
|
|
|
Ssh2,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl SshBackend {
|
|
|
|
|
|
|
|
pub const fn as_static_str(&self) -> &'static str {
|
|
|
|
|
|
|
|
match self {
|
|
|
|
|
|
|
|
#[cfg(feature = "libssh")]
|
|
|
|
|
|
|
|
Self::LibSsh => "libssh",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "ssh2")]
|
|
|
|
|
|
|
|
Self::Ssh2 => "ssh2",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Default for SshBackend {
|
|
|
|
|
|
|
|
/// Defaults to ssh2 if enabled, otherwise uses libssh by default
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// NOTE: There are currently bugs in libssh that cause our implementation to hang related to
|
|
|
|
|
|
|
|
/// process stdout/stderr and maybe other logic.
|
|
|
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
|
|
|
#[cfg(feature = "ssh2")]
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Self::Ssh2
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(feature = "ssh2"))]
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Self::LibSsh
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl FromStr for SshBackend {
|
|
|
|
|
|
|
|
type Err = &'static str;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
|
|
|
|
|
|
match s {
|
|
|
|
|
|
|
|
#[cfg(feature = "ssh2")]
|
|
|
|
|
|
|
|
s if s.trim().eq_ignore_ascii_case("ssh2") => Ok(Self::Ssh2),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "libssh")]
|
|
|
|
|
|
|
|
s if s.trim().eq_ignore_ascii_case("libssh") => Ok(Self::LibSsh),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ => Err("SSH backend must be \"libssh\" or \"ssh2\""),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl fmt::Display for SshBackend {
|
|
|
|
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
|
|
|
|
match self {
|
|
|
|
|
|
|
|
#[cfg(feature = "libssh")]
|
|
|
|
|
|
|
|
Self::LibSsh => write!(f, "libssh"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "ssh2")]
|
|
|
|
|
|
|
|
Self::Ssh2 => write!(f, "ssh2"),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Represents a singular authentication prompt for a new ssh client
|
|
|
|
/// Represents a singular authentication prompt for a new ssh client
|
|
|
|
#[derive(Debug)]
|
|
|
|
#[derive(Debug)]
|
|
|
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
|
|
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
|
|
@ -162,9 +86,6 @@ pub struct SshAuthEvent {
|
|
|
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
|
|
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
|
|
|
#[cfg_attr(feature = "serde", serde(default))]
|
|
|
|
#[cfg_attr(feature = "serde", serde(default))]
|
|
|
|
pub struct SshOpts {
|
|
|
|
pub struct SshOpts {
|
|
|
|
/// Represents the backend to use for ssh operations
|
|
|
|
|
|
|
|
pub backend: SshBackend,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// List of files from which the user's DSA, ECDSA, Ed25519, or RSA authentication identity
|
|
|
|
/// List of files from which the user's DSA, ECDSA, Ed25519, or RSA authentication identity
|
|
|
|
/// is read, defaulting to
|
|
|
|
/// is read, defaulting to
|
|
|
|
///
|
|
|
|
///
|
|
|
|