Struct thrussh::client::Connection
source · pub struct Connection<R: AsyncRead + AsyncWrite, H: Handler> { /* private fields */ }
Expand description
Client connection. A connection implements Future
, returning
()
when it finishes (for instance if the client and server agree
to close the connection).
Implementations
sourceimpl<R: AsyncRead + AsyncWrite, H: Handler> Connection<R, H>
impl<R: AsyncRead + AsyncWrite, H: Handler> Connection<R, H>
sourcepub fn channel_close(&mut self, channel: ChannelId)
pub fn channel_close(&mut self, channel: ChannelId)
Ask the server to close a channel, finishing any pending write and read.
sourcepub fn handler_mut(&mut self) -> &mut H
pub fn handler_mut(&mut self) -> &mut H
Gets a mutable borrow to the connection’s handler.
sourcepub fn is_channel_open(&self, channel: ChannelId) -> bool
pub fn is_channel_open(&self, channel: ChannelId) -> bool
Tests whether a channel is open.
sourceimpl<R: AsyncRead + AsyncWrite, H: Handler> Connection<R, H>
impl<R: AsyncRead + AsyncWrite, H: Handler> Connection<R, H>
sourceimpl<R: AsyncRead + AsyncWrite + Tcp, H: Handler> Connection<R, H>
impl<R: AsyncRead + AsyncWrite + Tcp, H: Handler> Connection<R, H>
sourcepub fn authenticate_password(
self,
user: &str,
password: String
) -> Authenticate<R, H>
pub fn authenticate_password(
self,
user: &str,
password: String
) -> Authenticate<R, H>
Try to authenticate this client using a password.
sourcepub fn authenticate_key(self, user: &str, key: Arc<KeyPair>) -> Authenticate<R, H>
pub fn authenticate_key(self, user: &str, key: Arc<KeyPair>) -> Authenticate<R, H>
Try to authenticate this client using a key pair.
sourcepub fn authenticate_key_future(
self,
user: &str,
key: PublicKey
) -> Authenticate<R, H>
pub fn authenticate_key_future(
self,
user: &str,
key: PublicKey
) -> Authenticate<R, H>
Try to authenticate this client using a key pair.
sourceimpl<R: AsyncRead + AsyncWrite, H: Handler> Connection<R, H>
impl<R: AsyncRead + AsyncWrite, H: Handler> Connection<R, H>
sourcepub fn channel_open_session(self) -> ChannelOpen<R, H, SessionChannel>
pub fn channel_open_session(self) -> ChannelOpen<R, H, SessionChannel>
Ask the server to open a session channel.
sourcepub fn channel_open_x11(
self,
originator_address: &str,
originator_port: u32
) -> ChannelOpen<R, H, X11Channel>
pub fn channel_open_x11(
self,
originator_address: &str,
originator_port: u32
) -> ChannelOpen<R, H, X11Channel>
Ask the server to open an X11 forwarding channel.
sourcepub fn channel_open_direct_tcpip(
self,
host_to_connect: &str,
port_to_connect: u32,
originator_address: &str,
originator_port: u32
) -> ChannelOpen<R, H, DirectTcpIpChannel>
pub fn channel_open_direct_tcpip(
self,
host_to_connect: &str,
port_to_connect: u32,
originator_address: &str,
originator_port: u32
) -> ChannelOpen<R, H, DirectTcpIpChannel>
Ask the server to open a direct TCP/IP forwarding channel.
sourceimpl<R: AsyncRead + AsyncWrite, H: Handler> Connection<R, H>
impl<R: AsyncRead + AsyncWrite, H: Handler> Connection<R, H>
sourcepub fn wait<F: Fn(&Connection<R, H>) -> bool>(self, f: F) -> Wait<R, H, F>
pub fn wait<F: Fn(&Connection<R, H>) -> bool>(self, f: F) -> Wait<R, H, F>
Wait until a condition is met on the connection.
sourcepub fn wait_flush(self) -> WaitFlush<R, H>
pub fn wait_flush(self) -> WaitFlush<R, H>
Flush the session, sending any pending message.
Methods from Deref<Target = Session>
sourcepub fn flush(&mut self) -> Result<(), Error>
pub fn flush(&mut self) -> Result<(), Error>
Flush the temporary cleartext buffer into the encryption buffer. This does not flush to the socket.
sourcepub fn disconnect(
&mut self,
reason: Disconnect,
description: &str,
language_tag: &str
)
pub fn disconnect(
&mut self,
reason: Disconnect,
description: &str,
language_tag: &str
)
Sends a disconnect message.
sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Whether the client is authenticated.
sourcepub fn is_disconnected(&self) -> bool
pub fn is_disconnected(&self) -> bool
Whether the client is disconnected.
sourcepub fn channel_is_open(&self, channel: ChannelId) -> bool
pub fn channel_is_open(&self, channel: ChannelId) -> bool
Check whether a channel has been confirmed.
sourcepub fn has_auth_method(&self) -> bool
pub fn has_auth_method(&self) -> bool
Tests whether we need an authentication method (for instance if the last attempt failed).
sourcepub fn valid_auth_methods(&self) -> Option<MethodSet>
pub fn valid_auth_methods(&self) -> Option<MethodSet>
Returns the set of authentication methods that can continue, or None if this is not valid.
sourcepub fn channel_open_session(&mut self) -> Result<ChannelId, Error>
pub fn channel_open_session(&mut self) -> Result<ChannelId, Error>
Request a session channel (the most basic type of
channel). This function returns Some(..)
immediately if the
connection is authenticated, but the channel only becomes
usable when it’s confirmed by the server, as indicated by the
confirmed
field of the corresponding Channel
.
sourcepub fn channel_open_x11(
&mut self,
originator_address: &str,
originator_port: u32
) -> Result<ChannelId, Error>
pub fn channel_open_x11(
&mut self,
originator_address: &str,
originator_port: u32
) -> Result<ChannelId, Error>
Request an X11 channel, on which the X11 protocol may be tunneled.
sourcepub fn channel_open_direct_tcpip(
&mut self,
host_to_connect: &str,
port_to_connect: u32,
originator_address: &str,
originator_port: u32
) -> Result<ChannelId, Error>
pub fn channel_open_direct_tcpip(
&mut self,
host_to_connect: &str,
port_to_connect: u32,
originator_address: &str,
originator_port: u32
) -> Result<ChannelId, Error>
Open a TCP/IP forwarding channel. This is usually done when a
connection comes to a locally forwarded TCP/IP port. See
RFC4254. The
TCP/IP packets can then be tunneled through the channel using
.data()
.
sourcepub fn channel_eof(&mut self, channel: ChannelId)
pub fn channel_eof(&mut self, channel: ChannelId)
Send EOF to a channel
sourcepub fn request_pty(
&mut self,
channel: ChannelId,
want_reply: bool,
term: &str,
col_width: u32,
row_height: u32,
pix_width: u32,
pix_height: u32,
terminal_modes: &[(Pty, u32)]
)
pub fn request_pty(
&mut self,
channel: ChannelId,
want_reply: bool,
term: &str,
col_width: u32,
row_height: u32,
pix_width: u32,
pix_height: u32,
terminal_modes: &[(Pty, u32)]
)
Request a pseudo-terminal with the given characteristics.
sourcepub fn request_x11(
&mut self,
channel: ChannelId,
want_reply: bool,
single_connection: bool,
x11_authentication_protocol: &str,
x11_authentication_cookie: &str,
x11_screen_number: u32
)
pub fn request_x11(
&mut self,
channel: ChannelId,
want_reply: bool,
single_connection: bool,
x11_authentication_protocol: &str,
x11_authentication_cookie: &str,
x11_screen_number: u32
)
Request X11 forwarding through an already opened X11 channel. See RFC4254 for security issues related to cookies.
sourcepub fn set_env(
&mut self,
channel: ChannelId,
want_reply: bool,
variable_name: &str,
variable_value: &str
)
pub fn set_env(
&mut self,
channel: ChannelId,
want_reply: bool,
variable_name: &str,
variable_value: &str
)
Set a remote environment variable.
sourcepub fn request_shell(&mut self, want_reply: bool, channel: ChannelId)
pub fn request_shell(&mut self, want_reply: bool, channel: ChannelId)
Request a remote shell.
sourcepub fn exec(&mut self, channel: ChannelId, want_reply: bool, command: &str)
pub fn exec(&mut self, channel: ChannelId, want_reply: bool, command: &str)
Execute a remote program (will be passed to a shell). This can be used to implement scp (by calling a remote scp and tunneling to its standard input).
sourcepub fn request_subsystem(
&mut self,
want_reply: bool,
channel: ChannelId,
name: &str
)
pub fn request_subsystem(
&mut self,
want_reply: bool,
channel: ChannelId,
name: &str
)
Request the start of a subsystem with the given name.
sourcepub fn window_change(
&mut self,
channel: ChannelId,
col_width: u32,
row_height: u32,
pix_width: u32,
pix_height: u32
)
pub fn window_change(
&mut self,
channel: ChannelId,
col_width: u32,
row_height: u32,
pix_width: u32,
pix_height: u32
)
Inform the server that our window size has changed.
sourcepub fn tcpip_forward(&mut self, want_reply: bool, address: &str, port: u32)
pub fn tcpip_forward(&mut self, want_reply: bool, address: &str, port: u32)
Request the forwarding of a remote port to the client. The
server will then open forwarding channels (which cause the
client to call .channel_open_forwarded_tcpip()
).
sourcepub fn cancel_tcpip_forward(&mut self, want_reply: bool, address: &str, port: u32)
pub fn cancel_tcpip_forward(&mut self, want_reply: bool, address: &str, port: u32)
Cancel a previous forwarding request.
Trait Implementations
sourceimpl<R: AsyncRead + AsyncWrite, H: Handler> Deref for Connection<R, H>
impl<R: AsyncRead + AsyncWrite, H: Handler> Deref for Connection<R, H>
sourceimpl<R: AsyncRead + AsyncWrite, H: Handler> DerefMut for Connection<R, H>
impl<R: AsyncRead + AsyncWrite, H: Handler> DerefMut for Connection<R, H>
sourceimpl<R: AsyncRead + AsyncWrite + Tcp, H: Handler> Future for Connection<R, H>
impl<R: AsyncRead + AsyncWrite + Tcp, H: Handler> Future for Connection<R, H>
type Error = HandlerError<<H as Handler>::Error>
type Error = HandlerError<<H as Handler>::Error>
sourcefn poll(&mut self) -> Poll<Self::Item, Self::Error>
fn poll(&mut self) -> Poll<Self::Item, Self::Error>
sourcefn wait(self) -> Result<Self::Item, Self::Error>where
Self: Sized,
fn wait(self) -> Result<Self::Item, Self::Error>where
Self: Sized,
sourcefn map<F, U>(self, f: F) -> Map<Self, F>where
F: FnOnce(Self::Item) -> U,
Self: Sized,
fn map<F, U>(self, f: F) -> Map<Self, F>where
F: FnOnce(Self::Item) -> U,
Self: Sized,
sourcefn map_err<F, E>(self, f: F) -> MapErr<Self, F>where
F: FnOnce(Self::Error) -> E,
Self: Sized,
fn map_err<F, E>(self, f: F) -> MapErr<Self, F>where
F: FnOnce(Self::Error) -> E,
Self: Sized,
sourcefn from_err<E>(self) -> FromErr<Self, E>where
E: From<Self::Error>,
Self: Sized,
fn from_err<E>(self) -> FromErr<Self, E>where
E: From<Self::Error>,
Self: Sized,
From
for
this future’s Error
, returning a new future. Read moresourcefn then<F, B>(self, f: F) -> Then<Self, B, F>where
F: FnOnce(Result<Self::Item, Self::Error>) -> B,
B: IntoFuture,
Self: Sized,
fn then<F, B>(self, f: F) -> Then<Self, B, F>where
F: FnOnce(Result<Self::Item, Self::Error>) -> B,
B: IntoFuture,
Self: Sized,
f
. Read moresourcefn and_then<F, B>(self, f: F) -> AndThen<Self, B, F>where
F: FnOnce(Self::Item) -> B,
B: IntoFuture<Error = Self::Error>,
Self: Sized,
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F>where
F: FnOnce(Self::Item) -> B,
B: IntoFuture<Error = Self::Error>,
Self: Sized,
sourcefn or_else<F, B>(self, f: F) -> OrElse<Self, B, F>where
F: FnOnce(Self::Error) -> B,
B: IntoFuture<Item = Self::Item>,
Self: Sized,
fn or_else<F, B>(self, f: F) -> OrElse<Self, B, F>where
F: FnOnce(Self::Error) -> B,
B: IntoFuture<Item = Self::Item>,
Self: Sized,
sourcefn select<B>(self, other: B) -> Select<Self, <B as IntoFuture>::Future>where
B: IntoFuture<Item = Self::Item, Error = Self::Error>,
Self: Sized,
fn select<B>(self, other: B) -> Select<Self, <B as IntoFuture>::Future>where
B: IntoFuture<Item = Self::Item, Error = Self::Error>,
Self: Sized,
sourcefn select2<B>(self, other: B) -> Select2<Self, <B as IntoFuture>::Future>where
B: IntoFuture,
Self: Sized,
fn select2<B>(self, other: B) -> Select2<Self, <B as IntoFuture>::Future>where
B: IntoFuture,
Self: Sized,
sourcefn join<B>(self, other: B) -> Join<Self, <B as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
Self: Sized,
fn join<B>(self, other: B) -> Join<Self, <B as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
Self: Sized,
sourcefn join3<B, C>(
self,
b: B,
c: C
) -> Join3<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
Self: Sized,
fn join3<B, C>(
self,
b: B,
c: C
) -> Join3<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
Self: Sized,
join
, but with more futures.sourcefn join4<B, C, D>(
self,
b: B,
c: C,
d: D
) -> Join4<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
Self: Sized,
fn join4<B, C, D>(
self,
b: B,
c: C,
d: D
) -> Join4<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
Self: Sized,
join
, but with more futures.sourcefn join5<B, C, D, E>(
self,
b: B,
c: C,
d: D,
e: E
) -> Join5<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future, <E as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
E: IntoFuture<Error = Self::Error>,
Self: Sized,
fn join5<B, C, D, E>(
self,
b: B,
c: C,
d: D,
e: E
) -> Join5<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future, <E as IntoFuture>::Future>where
B: IntoFuture<Error = Self::Error>,
C: IntoFuture<Error = Self::Error>,
D: IntoFuture<Error = Self::Error>,
E: IntoFuture<Error = Self::Error>,
Self: Sized,
join
, but with more futures.sourcefn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
sourcefn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
completed. Read more