Remove dns resolution for ssh session and add disclaimer to distant session about dns resolution

pull/96/head
Chip Senkbeil 3 years ago
parent 0f56669ccd
commit 669d419672
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(),
}
}

@ -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