Merge branch 'master' of github.com:chipsenkbeil/distant

pull/96/head
Chip Senkbeil 3 years ago
commit 92bbe55a13
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -43,6 +43,9 @@ pub enum SessionDetails {
/// Indicates session type is inmemory
Inmemory { tag: String },
/// Indicates session type is a custom type (such as ssh)
Custom { tag: String },
}
impl SessionDetails {
@ -52,6 +55,7 @@ impl SessionDetails {
Self::Tcp { tag, .. } => tag.as_str(),
Self::Socket { tag, .. } => tag.as_str(),
Self::Inmemory { tag } => tag.as_str(),
Self::Custom { tag } => tag.as_str(),
}
}

@ -436,6 +436,13 @@ where
{
let id = rand::random();
debug!(
"<Conn @ {} | Proc {}> Spawning {} {}",
conn_id,
id,
cmd,
args.join(" ")
);
let mut child = Command::new(cmd.to_string())
.args(args.clone())
.stdin(Stdio::piped())
@ -649,6 +656,10 @@ where
}
});
debug!(
"<Conn @ {} | Proc {}> Spawned successfully! Will enter post hook later",
conn_id, id
);
Ok(Outgoing {
data: ResponseData::ProcStart { id },
post_hook: Some(post_hook),

@ -616,6 +616,7 @@ where
let id = rand::random();
let cmd_string = format!("{} {}", cmd, args.join(" "));
debug!("<Ssh | Proc {}> Spawning {}", id, cmd_string);
let ExecResult {
mut stdin,
mut stdout,
@ -835,6 +836,10 @@ where
});
});
debug!(
"<Ssh | Proc {}> Spawned successfully! Will enter post hook later",
id
);
Ok(Outgoing {
data: ResponseData::ProcStart { id },
post_hook: Some(post_hook),

@ -358,8 +358,21 @@ impl Ssh2Session {
}
// Determine distinct candidate ip addresses for connecting
//
// NOTE: This breaks when the host is an alias defined within an ssh config; however,
// we need to be able to resolve the IP address(es) for use in TCP connect. The
// end solution would be to have wezterm-ssh provide some means to determine the
// IP address of the end machine it is connected to, but that probably isn't
// possible with ssh. So, for now, connecting to a distant server from an
// established ssh connection requires that we can resolve the specified host
let mut candidate_ips = tokio::net::lookup_host(format!("{}:{}", self.host, self.port))
.await?
.await
.map_err(|x| {
io::Error::new(
x.kind(),
format!("{} needs to be resolvable outside of ssh: {}", self.host, x),
)
})?
.into_iter()
.map(|addr| addr.ip())
.collect::<Vec<IpAddr>>();
@ -488,19 +501,8 @@ impl Ssh2Session {
}
let (t1, t2) = Transport::pair(1);
let addr = tokio::net::lookup_host(format!("{}:{}", self.host, self.port))
.await?
.next()
.ok_or_else(|| {
io::Error::new(
io::ErrorKind::AddrNotAvailable,
format!("Failed to resolve host: {}", self.host),
)
})?;
let tag = t1.to_connection_tag();
let session =
Session::initialize_with_details(t1, Some(SessionDetails::Tcp { addr, tag }))?;
let tag = format!("ssh {}:{}", self.host, self.port);
let session = Session::initialize_with_details(t1, Some(SessionDetails::Custom { tag }))?;
// Spawn tasks that forward requests to the ssh session
// and send back responses from the ssh session

Loading…
Cancel
Save