Struct thrussh::client::Connection
[−]
[src]
pub struct Connection<H: Handler> { pub session: Option<Session>, // some fields omitted }
Client connection.
Fields
session: Option<Session>
Session of this connection.
Methods
impl<H: Handler> Connection<H>
[src]
fn new(config: Arc<Config>,
stream: TcpStream,
handler: H,
timeout: Option<Timeout>)
-> Result<Self, Error>
stream: TcpStream,
handler: H,
timeout: Option<Timeout>)
-> Result<Self, Error>
Create a new client connection.
impl<H: Handler> Connection<H>
[src]
fn authenticate_password(self, user: &str, password: String) -> Authenticate<H>
Try to authenticate this client using a password.
fn authenticate_key(self, user: &str, key: Algorithm) -> Authenticate<H>
Try to authenticate this client using a key pair.
fn channel_open_session(self) -> ChannelOpen<H, SessionChannel>
Ask the server to open a session channel.
fn channel_open_x11(self,
originator_address: &str,
originator_port: u32)
-> ChannelOpen<H, X11Channel>
originator_address: &str,
originator_port: u32)
-> ChannelOpen<H, X11Channel>
Ask the server to open an X11 forwarding channel.
fn channel_open_direct_tcpip(self,
host_to_connect: &str,
port_to_connect: u32,
originator_address: &str,
originator_port: u32)
-> ChannelOpen<H, DirectTcpIpChannel>
host_to_connect: &str,
port_to_connect: u32,
originator_address: &str,
originator_port: u32)
-> ChannelOpen<H, DirectTcpIpChannel>
Ask the server to open a direct TCP/IP forwarding channel.
fn channel_close(self, channel: ChannelId)
Ask the server to close a channel, finishing any pending write and read.
fn wait<F: Fn(&Connection<H>) -> bool>(self, f: F) -> Wait<H, F>
Wait until a condition is met on the connection.
fn flush(self) -> Flush<H>
Flush the session, sending any pending message.
fn handler(&self) -> &H
Gets a borrow to the connection's handler.
fn handler_mut(&mut self) -> &mut H
Gets a mutable borrow to the connection's handler.
Methods from Deref<Target=Session>
fn config(&self) -> &Config
Retrieves the configuration of this session.
fn auth_user(&self) -> &str
Retrieves the current user.
fn disconnect(&mut self,
reason: Disconnect,
description: &str,
language_tag: &str)
reason: Disconnect,
description: &str,
language_tag: &str)
Sends a disconnect message.
fn is_authenticated(&self) -> bool
Whether the client is authenticated.
fn is_disconnected(&self) -> bool
Whether the client is disconnected.
fn channel_is_open(&self, channel: ChannelId) -> bool
Check whether a channel has been confirmed.
fn has_auth_method(&self) -> bool
Tests whether we need an authentication method (for instance if the last attempt failed).
fn valid_auth_methods(&self) -> Option<MethodSet>
Returns the set of authentication methods that can continue, or None if this is not valid.
fn channel_eof(&mut self, channel: ChannelId)
Send EOF to a channel
fn data(&mut self,
channel: ChannelId,
extended: Option<u32>,
data: &[u8])
-> Result<usize, Error>
channel: ChannelId,
extended: Option<u32>,
data: &[u8])
-> Result<usize, Error>
Send data or "extended data" to the given channel. Extended data can be used to multiplex different data streams into a single channel.
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)])
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.
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)
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.
fn set_env(&mut self,
channel: ChannelId,
want_reply: bool,
variable_name: &str,
variable_value: &str)
channel: ChannelId,
want_reply: bool,
variable_name: &str,
variable_value: &str)
Set a remote environment variable.
fn request_shell(&mut self, want_reply: bool, channel: ChannelId)
Request a remote shell.
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).
fn signal(&mut self, channel: ChannelId, signal: Sig)
Signal a remote process.
fn request_subsystem(&mut self,
want_reply: bool,
channel: ChannelId,
name: &str)
want_reply: bool,
channel: ChannelId,
name: &str)
Request the start of a subsystem with the given name.
fn window_change(&mut self,
channel: ChannelId,
col_width: u32,
row_height: u32,
pix_width: u32,
pix_height: u32)
channel: ChannelId,
col_width: u32,
row_height: u32,
pix_width: u32,
pix_height: u32)
Inform the server that our window size has changed.
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()
).
fn cancel_tcpip_forward(&mut self, want_reply: bool, address: &str, port: u32)
Cancel a previous forwarding request.
Trait Implementations
impl<H: Handler> Deref for Connection<H>
[src]
type Target = Session
The resulting type after dereferencing
fn deref(&self) -> &Self::Target
The method called to dereference a value
impl<H: Handler> DerefMut for Connection<H>
[src]
impl<H: Handler> Future for Connection<H>
[src]
type Item = ()
The type of value that this future will resolved with if it is successful. Read more
type Error = HandlerError<H::Error>
The type of error that this future will resolve with if it fails in a normal fashion. Read more
fn poll(&mut self) -> Poll<Self::Item, Self::Error>
Query this future to see if its value has become available, registering interest if it is not. Read more
fn wait(self) -> Result<Self::Item, Self::Error>
Block the current thread until this future is resolved. Read more
fn boxed(self)
-> Box<Future<Error=Self::Error, Item=Self::Item> + 'static + Send> where Self: Send + 'static
-> Box<Future<Error=Self::Error, Item=Self::Item> + 'static + Send> where Self: Send + 'static
Convenience function for turning this future into a trait object. Read more
fn map<F, U>(self, f: F) -> Map<Self, F> where F: FnOnce(Self::Item) -> U
Map this future's result to a different type, returning a new future of the resulting type. Read more
fn map_err<F, E>(self, f: F) -> MapErr<Self, F> where F: FnOnce(Self::Error) -> E
Map this future's error to a different error, returning a new future. Read more
fn from_err<F, E>(self) -> FromErr<Self, E> where E: From<Self::Error>
Map this future's error to any error implementing From
for this future's Error
, returning a new future. Read more
fn then<F, B>(self, f: F) -> Then<Self, B, F> where B: IntoFuture, F: FnOnce(Result<Self::Item, Self::Error>) -> B
Chain on a computation for when a future finished, passing the result of the future to the provided closure f
. Read more
fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where B: IntoFuture<Error=Self::Error>, F: FnOnce(Self::Item) -> B
Execute another future after this one has resolved successfully. Read more
fn or_else<F, B>(self, f: F) -> OrElse<Self, B, F> where B: IntoFuture<Item=Self::Item>, F: FnOnce(Self::Error) -> B
Execute another future if this one resolves with an error. Read more
fn select<B>(self, other: B) -> Select<Self, B::Future> where B: IntoFuture<Item=Self::Item, Error=Self::Error>
Waits for either one of two futures to complete. Read more
fn join<B>(self, other: B) -> Join<Self, B::Future> where B: IntoFuture<Error=Self::Error>
Joins the result of two futures, waiting for them both to complete. Read more
fn join3<B, C>(self, b: B, c: C) -> Join3<Self, B::Future, C::Future> where B: IntoFuture<Error=Self::Error>, C: IntoFuture<Error=Self::Error>
Same as join
, but with more futures.
fn join4<B, C, D>(self,
b: B,
c: C,
d: D)
-> Join4<Self, B::Future, C::Future, D::Future> where B: IntoFuture<Error=Self::Error>,
C: IntoFuture<Error=Self::Error>,
D: IntoFuture<Error=Self::Error>
b: B,
c: C,
d: D)
-> Join4<Self, B::Future, C::Future, D::Future> where B: IntoFuture<Error=Self::Error>,
C: IntoFuture<Error=Self::Error>,
D: IntoFuture<Error=Self::Error>
Same as join
, but with more futures.
fn join5<B, C, D, E>(self,
b: B,
c: C,
d: D,
e: E)
-> Join5<Self, B::Future, C::Future, D::Future, E::Future> where B: IntoFuture<Error=Self::Error>,
C: IntoFuture<Error=Self::Error>,
D: IntoFuture<Error=Self::Error>,
E: IntoFuture<Error=Self::Error>
b: B,
c: C,
d: D,
e: E)
-> Join5<Self, B::Future, C::Future, D::Future, E::Future> where B: IntoFuture<Error=Self::Error>,
C: IntoFuture<Error=Self::Error>,
D: IntoFuture<Error=Self::Error>,
E: IntoFuture<Error=Self::Error>
Same as join
, but with more futures.
fn into_stream(self) -> IntoStream<Self>
Convert this future into single element stream. Read more
fn flatten(self) -> Flatten<Self> where Self::Item: IntoFuture, Self::Item::Error: From<Self::Error>
Flatten the execution of this future when the successful result of this future is itself another future. Read more
fn flatten_stream(self) -> FlattenStream<Self> where Self::Item: Stream, Self::Item::Error == Self::Error
Flatten the execution of this future when the successful result of this future is a stream. Read more
fn fuse(self) -> Fuse<Self>
Fuse a future such that poll
will never again be called once it has completed. Read more
fn catch_unwind(self) -> CatchUnwind<Self> where Self: UnwindSafe
Catches unwinding panics while polling the future. Read more
Convert this future into Shared
future. Read more