[][src]Trait thrussh::server::Handler

pub trait Handler: Sized {
    type FutureAuth: Future<Output = Result<(Self, Auth), Error>> + Send;
    type FutureUnit: Future<Output = Result<(Self, Session), Error>> + Send;
    type FutureBool: Future<Output = Result<(Self, Session, bool), Error>> + Send;
    fn finished_auth(self, auth: Auth) -> Self::FutureAuth;
fn finished_bool(self, b: bool, session: Session) -> Self::FutureBool;
fn finished(self, session: Session) -> Self::FutureUnit; fn auth_none(self, user: &str) -> Self::FutureAuth { ... }
fn auth_password(self, user: &str, password: &str) -> Self::FutureAuth { ... }
fn auth_publickey(
        self,
        user: &str,
        public_key: &PublicKey
    ) -> Self::FutureAuth { ... }
fn auth_keyboard_interactive(
        self,
        user: &str,
        submethods: &str,
        response: Option<Response>
    ) -> Self::FutureAuth { ... }
fn channel_close(
        self,
        channel: ChannelId,
        session: Session
    ) -> Self::FutureUnit { ... }
fn channel_eof(
        self,
        channel: ChannelId,
        session: Session
    ) -> Self::FutureUnit { ... }
fn channel_open_session(
        self,
        channel: ChannelId,
        session: Session
    ) -> Self::FutureUnit { ... }
fn channel_open_x11(
        self,
        channel: ChannelId,
        originator_address: &str,
        originator_port: u32,
        session: Session
    ) -> Self::FutureUnit { ... }
fn channel_open_direct_tcpip(
        self,
        channel: ChannelId,
        host_to_connect: &str,
        port_to_connect: u32,
        originator_address: &str,
        originator_port: u32,
        session: Session
    ) -> Self::FutureUnit { ... }
fn data(
        self,
        channel: ChannelId,
        data: &[u8],
        session: Session
    ) -> Self::FutureUnit { ... }
fn extended_data(
        self,
        channel: ChannelId,
        code: u32,
        data: &[u8],
        session: Session
    ) -> Self::FutureUnit { ... }
fn window_adjusted(
        self,
        channel: ChannelId,
        new_window_size: usize,
        session: Session
    ) -> Self::FutureUnit { ... }
fn pty_request(
        self,
        channel: ChannelId,
        term: &str,
        col_width: u32,
        row_height: u32,
        pix_width: u32,
        pix_height: u32,
        modes: &[(Pty, u32)],
        session: Session
    ) -> Self::FutureUnit { ... }
fn x11_request(
        self,
        channel: ChannelId,
        single_connection: bool,
        x11_auth_protocol: &str,
        x11_auth_cookie: &str,
        x11_screen_number: u32,
        session: Session
    ) -> Self::FutureUnit { ... }
fn env_request(
        self,
        channel: ChannelId,
        variable_name: &str,
        variable_value: &str,
        session: Session
    ) -> Self::FutureUnit { ... }
fn shell_request(
        self,
        channel: ChannelId,
        session: Session
    ) -> Self::FutureUnit { ... }
fn exec_request(
        self,
        channel: ChannelId,
        data: &[u8],
        session: Session
    ) -> Self::FutureUnit { ... }
fn subsystem_request(
        self,
        channel: ChannelId,
        name: &str,
        session: Session
    ) -> Self::FutureUnit { ... }
fn window_change_request(
        self,
        channel: ChannelId,
        col_width: u32,
        row_height: u32,
        pix_width: u32,
        pix_height: u32,
        session: Session
    ) -> Self::FutureUnit { ... }
fn signal(
        self,
        channel: ChannelId,
        signal_name: Sig,
        session: Session
    ) -> Self::FutureUnit { ... }
fn tcpip_forward(
        self,
        address: &str,
        port: u32,
        session: Session
    ) -> Self::FutureBool { ... }
fn cancel_tcpip_forward(
        self,
        address: &str,
        port: u32,
        session: Session
    ) -> Self::FutureBool { ... } }

Server handler. Each client will have their own handler.

Associated Types

type FutureAuth: Future<Output = Result<(Self, Auth), Error>> + Send

The type of authentications, which can be a future ultimately resolving to

type FutureUnit: Future<Output = Result<(Self, Session), Error>> + Send

The type of units returned by some parts of this handler.

type FutureBool: Future<Output = Result<(Self, Session, bool), Error>> + Send

The type of future bools returned by some parts of this handler.

Loading content...

Required methods

fn finished_auth(self, auth: Auth) -> Self::FutureAuth

Convert an Auth to Self::FutureAuth. This is used to produce the default handlers.

fn finished_bool(self, b: bool, session: Session) -> Self::FutureBool

Convert a bool to Self::FutureBool. This is used to produce the default handlers.

fn finished(self, session: Session) -> Self::FutureUnit

Produce a Self::FutureUnit. This is used to produce the default handlers.

Loading content...

Provided methods

fn auth_none(self, user: &str) -> Self::FutureAuth

Check authentication using the "none" method. Thrussh makes sure rejection happens in time config.auth_rejection_time, except if this method takes more than that.

fn auth_password(self, user: &str, password: &str) -> Self::FutureAuth

Check authentication using the "password" method. Thrussh makes sure rejection happens in time config.auth_rejection_time, except if this method takes more than that.

fn auth_publickey(self, user: &str, public_key: &PublicKey) -> Self::FutureAuth

Check authentication using the "publickey" method. This method should just check whether the public key matches the authorized ones. Thrussh then checks the signature. If the key is unknown, or the signature is invalid, Thrussh guarantees that rejection happens in constant time config.auth_rejection_time, except if this method takes more time than that.

fn auth_keyboard_interactive(
    self,
    user: &str,
    submethods: &str,
    response: Option<Response>
) -> Self::FutureAuth

Check authentication using the "keyboard-interactive" method. Thrussh makes sure rejection happens in time config.auth_rejection_time, except if this method takes more than that.

fn channel_close(self, channel: ChannelId, session: Session) -> Self::FutureUnit

Called when the client closes a channel.

fn channel_eof(self, channel: ChannelId, session: Session) -> Self::FutureUnit

Called when the client sends EOF to a channel.

fn channel_open_session(
    self,
    channel: ChannelId,
    session: Session
) -> Self::FutureUnit

Called when a new session channel is created.

fn channel_open_x11(
    self,
    channel: ChannelId,
    originator_address: &str,
    originator_port: u32,
    session: Session
) -> Self::FutureUnit

Called when a new X11 channel is created.

fn channel_open_direct_tcpip(
    self,
    channel: ChannelId,
    host_to_connect: &str,
    port_to_connect: u32,
    originator_address: &str,
    originator_port: u32,
    session: Session
) -> Self::FutureUnit

Called when a new channel is created.

fn data(
    self,
    channel: ChannelId,
    data: &[u8],
    session: Session
) -> Self::FutureUnit

Called when a data packet is received. A response can be written to the response argument.

fn extended_data(
    self,
    channel: ChannelId,
    code: u32,
    data: &[u8],
    session: Session
) -> Self::FutureUnit

Called when an extended data packet is received. Code 1 means that this packet comes from stderr, other codes are not defined (see RFC4254).

fn window_adjusted(
    self,
    channel: ChannelId,
    new_window_size: usize,
    session: Session
) -> Self::FutureUnit

Called when the network window is adjusted, meaning that we can send more bytes.

fn pty_request(
    self,
    channel: ChannelId,
    term: &str,
    col_width: u32,
    row_height: u32,
    pix_width: u32,
    pix_height: u32,
    modes: &[(Pty, u32)],
    session: Session
) -> Self::FutureUnit

The client requests a pseudo-terminal with the given specifications.

fn x11_request(
    self,
    channel: ChannelId,
    single_connection: bool,
    x11_auth_protocol: &str,
    x11_auth_cookie: &str,
    x11_screen_number: u32,
    session: Session
) -> Self::FutureUnit

The client requests an X11 connection.

fn env_request(
    self,
    channel: ChannelId,
    variable_name: &str,
    variable_value: &str,
    session: Session
) -> Self::FutureUnit

The client wants to set the given environment variable. Check these carefully, as it is dangerous to allow any variable environment to be set.

fn shell_request(self, channel: ChannelId, session: Session) -> Self::FutureUnit

The client requests a shell.

fn exec_request(
    self,
    channel: ChannelId,
    data: &[u8],
    session: Session
) -> Self::FutureUnit

The client sends a command to execute, to be passed to a shell. Make sure to check the command before doing so.

fn subsystem_request(
    self,
    channel: ChannelId,
    name: &str,
    session: Session
) -> Self::FutureUnit

The client asks to start the subsystem with the given name (such as sftp).

fn window_change_request(
    self,
    channel: ChannelId,
    col_width: u32,
    row_height: u32,
    pix_width: u32,
    pix_height: u32,
    session: Session
) -> Self::FutureUnit

The client's pseudo-terminal window size has changed.

fn signal(
    self,
    channel: ChannelId,
    signal_name: Sig,
    session: Session
) -> Self::FutureUnit

The client is sending a signal (usually to pass to the currently running process).

fn tcpip_forward(
    self,
    address: &str,
    port: u32,
    session: Session
) -> Self::FutureBool

Used for reverse-forwarding ports, see RFC4254.

fn cancel_tcpip_forward(
    self,
    address: &str,
    port: u32,
    session: Session
) -> Self::FutureBool

Used to stop the reverse-forwarding of a port, see RFC4254.

Loading content...

Implementors

Loading content...