Skip to main content

ServerBuilder

Struct ServerBuilder 

Source
pub struct ServerBuilder { /* private fields */ }
Expand description

Builder for creating an SSH server.

Implementations§

Source§

impl ServerBuilder

Source

pub fn new() -> Self

Creates a new server builder.

Source

pub fn address(self, addr: impl Into<String>) -> Self

Sets the listen address.

Source

pub fn version(self, version: impl Into<String>) -> Self

Sets the server version.

Source

pub fn banner(self, banner: impl Into<String>) -> Self

Sets a static banner.

Source

pub fn banner_handler<F>(self, handler: F) -> Self
where F: Fn(&Context) -> String + Send + Sync + 'static,

Sets a dynamic banner handler.

Source

pub fn host_key_path(self, path: impl Into<String>) -> Self

Sets the host key path.

Source

pub fn host_key_pem(self, pem: Vec<u8>) -> Self

Sets the host key from PEM data.

Source

pub fn with_middleware(self, mw: Middleware) -> Self

Adds middleware to the server.

Source

pub fn handler<F, Fut>(self, handler: F) -> Self
where F: Fn(Session) -> Fut + Send + Sync + 'static, Fut: Future<Output = ()> + Send + 'static,

Sets the main handler.

Source

pub fn handler_arc(self, handler: Handler) -> Self

Sets the main handler from a pre-wrapped Handler.

Use this when you already have a Handler (e.g., from the handler function).

Source

pub fn auth_handler<H: AuthHandler + 'static>(self, handler: H) -> Self

Sets the trait-based authentication handler.

If set, this takes precedence over the callback-based handlers.

Source

pub fn max_auth_attempts(self, max: u32) -> Self

Sets the maximum authentication attempts.

Source

pub fn auth_rejection_delay(self, delay_ms: u64) -> Self

Sets the authentication rejection delay in milliseconds.

Source

pub fn allow_no_auth(self) -> Self

Allow unauthenticated access when no auth handlers are configured.

By default, auth_none is rejected unless at least one auth handler is registered. Call this to explicitly opt in to anonymous access (e.g., for demo/development servers).

Source

pub fn public_key_auth<F>(self, handler: F) -> Self
where F: Fn(&Context, &PublicKey) -> bool + Send + Sync + 'static,

Sets the public key authentication handler.

Source

pub fn password_auth<F>(self, handler: F) -> Self
where F: Fn(&Context, &str) -> bool + Send + Sync + 'static,

Sets the password authentication handler.

Source

pub fn keyboard_interactive_auth<F>(self, handler: F) -> Self
where F: Fn(&Context, &str, &[String], &[bool]) -> Vec<String> + Send + Sync + 'static,

Sets the keyboard-interactive authentication handler.

Source

pub fn idle_timeout(self, duration: Duration) -> Self

Sets the idle timeout.

Source

pub fn max_timeout(self, duration: Duration) -> Self

Sets the maximum connection timeout.

Source

pub fn subsystem<F, Fut>(self, name: impl Into<String>, handler: F) -> Self
where F: Fn(Session) -> Fut + Send + Sync + 'static, Fut: Future<Output = ()> + Send + 'static,

Adds a subsystem handler.

Source

pub fn build(self) -> Result<Server>

Builds the server.

Trait Implementations§

Source§

impl Default for ServerBuilder

Source§

fn default() -> ServerBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more