pub trait Behavior {
type Stream: Read + Write;
type Random: CryptoRng + Rng;
type User: Clone;
type Command: Clone;
// Required methods
fn stream(&mut self) -> &mut Self::Stream;
fn random(&mut self) -> &mut Self::Random;
fn host_secret_key(&self) -> &SecretKey;
fn allow_user(
&mut self,
username: &str,
auth_method: &AuthMethod,
) -> Option<Self::User>;
fn parse_command(&mut self, command: &str) -> Self::Command;
// Provided methods
fn server_id(&self) -> &'static str { ... }
fn allow_shell(&self) -> bool { ... }
}Expand description
Description of aspects of the server’s behavior.
Required Associated Types§
Required Methods§
Sourcefn host_secret_key(&self) -> &SecretKey
fn host_secret_key(&self) -> &SecretKey
The secret key advertised by the server.
Sourcefn allow_user(
&mut self,
username: &str,
auth_method: &AuthMethod,
) -> Option<Self::User>
fn allow_user( &mut self, username: &str, auth_method: &AuthMethod, ) -> Option<Self::User>
Allow a given user to authenticate with a given auth method.
Returns None if the user’s auth method is not acceptable (e.g. public key does not match a whitelist), otherwise returns a type representing a user identity.
This may be called more than once if the client uses probe requests.
Sourcefn parse_command(&mut self, command: &str) -> Self::Command
fn parse_command(&mut self, command: &str) -> Self::Command
Parse a user-supplied command string into a command.
It is not permitted to “fail” to parse a command, instead just represent invalid commands as a “print usage” command variant so as to handle all possible inputs.
Provided Methods§
Sourcefn server_id(&self) -> &'static str
fn server_id(&self) -> &'static str
The server’s identification string.
This will be sent to the client during the initial version handshake. It must comply with RFC4253 section 4.2 except it should not contain the final CR LF.
Sourcefn allow_shell(&self) -> bool
fn allow_shell(&self) -> bool
Whether to allow shell channel requests.
Note that if this returns true, the server code must be prepared to handle shell requests by accepting interactive input in ways similar to a real shell process.