pub async fn into_distant_session(self, opts: IntoDistantSessionOpts) -> io::Result<Session> {
        // Exit early if not authenticated as this is a requirement
        if !self.authenticated {
            return Err(io::Error::new(
                io::ErrorKind::PermissionDenied,
                "Not authenticated",
            ));
        }

        let timeout = opts.timeout;

        // 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
            .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>>();
        candidate_ips.sort_unstable();
        candidate_ips.dedup();
        if candidate_ips.is_empty() {
            return Err(io::Error::new(
                io::ErrorKind::AddrNotAvailable,
                format!("Unable to resolve {}:{}", self.host, self.port),
            ));
        }

        let info = self.into_distant_session_info(opts).await?;
        let key = info.key;
        let codec = XChaCha20Poly1305Codec::from(key);

        // Try each IP address with the same port to see if one works
        let mut err = None;
        for ip in candidate_ips {
            let addr = SocketAddr::new(ip, info.port);
            debug!("Attempting to connect to distant server @ {}", addr);
            match Session::tcp_connect_timeout(addr, codec.clone(), timeout).await {
                Ok(session) => return Ok(session),
                Err(x) => err = Some(x),
            }
        }

        // If all failed, return the last error we got
        Err(err.expect("Err set above"))
    }
/// Consume [`Ssh2Session`] and produce a distant [`Session`] that is connected to a remote
/// distant server that is spawned using the ssh session
Consume [`Ssh2Session`] and produce a distant [`Session`] that is connected to a remote
distant server that is spawned using the ssh session
Consume [ ` Ssh2Session ` ] and produce a distant [ ` Session ` ] that is connected to a remote distant server that is spawned using the ssh session
pub async fn into_distant_session(self, opts: IntoDistantSessionOpts) -> io::Result<Session> {
        // Exit early if not authenticated as this is a requirement
        if !self.authenticated {
            return Err(io::Error::new(
                io::ErrorKind::PermissionDenied,
                "Not authenticated",
            ));
        }
        let timeout = opts.timeout;
        // 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
            .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>>();
        candidate_ips.sort_unstable();
        candidate_ips.dedup();
        if candidate_ips.is_empty() {
            return Err(io::Error::new(
                io::ErrorKind::AddrNotAvailable,
                format!("Unable to resolve {}:{}", self.host, self.port),
            ));
        }
        let info = self.into_distant_session_info(opts).await?;
        let key = info.key;
        let codec = XChaCha20Poly1305Codec::from(key);
        // Try each IP address with the same port to see if one works
        let mut err = None;
        for ip in candidate_ips {
            let addr = SocketAddr::new(ip, info.port);
            debug!("Attempting to connect to distant server @ {}", addr);
            match Session::tcp_connect_timeout(addr, codec.clone(), timeout).await {
                Ok(session) => return Ok(session),
                Err(x) => err = Some(x),
            }
        }
        // If all failed, return the last error we got
        Err(err.expect("Err set above"))
    }
pub async fn into_distant_session ( self , opts : IntoDistantSessionOpts ) -> io :: Result < Session > { // Exit early if not authenticated as this is a requirement if ! self . authenticated { return Err ( io :: Error :: new ( io :: ErrorKind :: PermissionDenied , " " , ) ) ; } let timeout = opts . timeout ; // 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 . map_err ( | x | { io :: Error :: new ( x . kind ( ) , format ! ( " " self host x ) , ) } ) ? . into_iter ( ) . map ( | addr | addr . ip ( ) ) . collect :: < Vec < IpAddr > > ( ) ; candidate_ips . sort_unstable ( ) ; candidate_ips . dedup ( ) ; if candidate_ips . is_empty ( ) { return Err ( io :: Error :: new ( io :: ErrorKind :: AddrNotAvailable , format ! ( " " self host self port ) , ) ) ; } let info = self . into_distant_session_info ( opts ) . await ? ; let key = info . key ; let codec = XChaCha20Poly1305Codec :: from ( key ) ; // Try each IP address with the same port to see if one works let mut err = None ; for ip in candidate_ips { let addr = SocketAddr :: new ( ip , info . port ) ; debug ! ( " " addr ) ; match Session :: tcp_connect_timeout ( addr , codec . clone ( ) , timeout ) . await { Ok ( session ) => return Ok ( session ) , Err ( x ) => err = Some ( x ) , } } // If all failed, return the last error we got Err ( err . expect ( " " ) ) }
Consume [`Ssh2Session`] and produce a distant [`Session`] that is connected to a remote
distant server that is spawned using the ssh session
Consume [ ` Ssh2Session ` ] and produce a distant [ ` Session ` ] that is connected to a remote distant server that is spawned using the ssh session
self
opts
IntoDistantSessionOpts