Skip to main content

SmbServerBuilder

Struct SmbServerBuilder 

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

Builder for SmbServer. See SmbServer::builder.

Implementations§

Source§

impl SmbServerBuilder

Source

pub fn listen(self, addr: SocketAddr) -> Self

Source

pub fn user(self, name: impl Into<String>, password: impl Into<String>) -> Self

Source

pub fn share(self, share: Share) -> Self

Source

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

Source

pub fn require_signing(self, required: bool) -> Self

Require every authenticated session to sign its requests, and set SMB2_NEGOTIATE_SIGNING_REQUIRED in the NEGOTIATE response. It does not apply to anonymous and guest sessions, which have no key and stay unsigned. Off by default; a client can still require signing for its own sessions.

Source

pub fn encrypt_data(self, encrypt: bool) -> Self

Encrypt every authenticated session on a connection that negotiated a cipher. While reject_unencrypted_access is on, clients that cannot encrypt get no session, and anonymous and guest sessions get no tree. Off by default; with it off, a client that sends encrypted requests gets encrypted replies, and Share::encrypt_data turns encryption on for one share.

Source

pub fn reject_unencrypted_access(self, reject: bool) -> Self

Whether a session or share that must be encrypted refuses clients that cannot encrypt: SMB 2.x, SMB 3.0 and 3.0.2 without the encryption capability, SMB 3.1.1 without a common cipher, and anonymous and guest sessions. On SMB 3.0 and 3.0.2 it also refuses unencrypted requests from clients that can encrypt; SMB 3.1.1 always refuses them. On by default. Turned off, clients that cannot encrypt are served unencrypted.

Source

pub fn max_sessions_per_connection(self, sessions: usize) -> Self

Most sessions one connection may hold. SESSION_SETUP past the limit fails with STATUS_INSUFFICIENT_RESOURCES. Default 64.

Source

pub fn max_trees_per_session(self, trees: usize) -> Self

Most tree connects one session may hold. TREE_CONNECT past the limit fails with STATUS_INSUFFICIENT_RESOURCES. Default 128.

Source

pub fn logon_throttle(self, max_failures: u32, lockout: Duration) -> Self

Failed-logon throttle. After max_failures failed logons for one user name, each within lockout of the one before, logons with that name fail with STATUS_ACCOUNT_LOCKED_OUT until lockout has passed since the last failure. One client address is locked out the same way after ten times max_failures failed logons, whatever names they used. A connection is closed after max_failures failed logons. Unknown names are tracked the same way as configured ones. max_failures 0 turns the throttle off. Default 10 failures and 60 seconds.

Source

pub fn max_read_size(self, bytes: u32) -> Self

Source

pub fn max_write_size(self, bytes: u32) -> Self

Source

pub fn server_guid(self, guid: Uuid) -> Self

Override the random per-process server GUID. Mostly useful in tests.

Source

pub fn max_connections(self, connections: usize) -> Self

Most connections served at once, counting every client together; per-host limits belong in the firewall. A connection accepted beyond the limit is closed straight away. Defaults to 1024.

Source

pub fn handshake_timeout(self, timeout: Duration) -> Self

Time a new connection has to establish a session, and each SESSION_SETUP exchange has to finish. A connection still without a session at the deadline is closed, and an unfinished exchange is dropped. Defaults to 30 seconds.

Source

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

Closes a connection that has sent no request for this long and has no open files. Defaults to 15 minutes.

Source

pub fn io_timeout(self, timeout: Duration) -> Self

Time allowed to receive the rest of a request once its first bytes have arrived, and to send one response. The connection closes when either takes longer. Defaults to 60 seconds.

Source

pub fn tcp_keepalive(self, idle: Option<Duration>) -> Self

Idle time before TCP keepalive probes start on accepted connections, or None to leave keepalive off. Defaults to 60 seconds.

Source

pub fn max_opens_per_connection(self, opens: usize) -> Self

Most files and named pipes one connection may hold open at once. A CREATE past the limit fails with STATUS_INSUFFICIENT_RESOURCES. Named pipes are also limited to 16 per connection. Defaults to DEFAULT_MAX_OPENS_PER_CONNECTION. ConfigHandle::set_max_opens_per_connection changes it at run time.

Source

pub fn share_listing(self, enabled: bool) -> Self

Answer clients that list the server’s shares: Explorer and net view on Windows, the Finder and smbutil view on macOS, smbclient -L and file managers on Linux. A client sees the shares its session may connect to, the public ones for an anonymous session, and IPC$, in the order the shares were added; a share whose traffic is encrypted is left out for a session that cannot encrypt. Shares left out with Share::listed are not in the list. Clients list shares through the srvsvc named pipe on IPC$; one connection may hold 16 named pipes at once. On by default; turned off, IPC$ opens no pipe and clients get no list.

Source

pub fn max_locks_per_open(self, locks: usize) -> Self

Most byte-range locks one open may hold at once. A LOCK past the limit fails with STATUS_INSUFFICIENT_RESOURCES. Defaults to DEFAULT_MAX_LOCKS_PER_OPEN.

Source

pub fn durable_handle_timeout(self, timeout: Duration) -> Self

How long the server keeps an open file for a client whose connection dropped or that logged off; see Share::durable_handles. A client that asks for a time in a version 2 durable handle request gets it, up to this timeout or 5 minutes, whichever is longer. Must be between 1 millisecond and 49 days. Defaults to DEFAULT_DURABLE_HANDLE_TIMEOUT, 2 minutes.

Source

pub fn max_disconnected_opens(self, opens: usize) -> Self

Most open files the server keeps for clients whose connection dropped or that logged off, counting every client together; one user gets at most a quarter of them, rounded up. Past the limit, such a client’s files are closed. Defaults to DEFAULT_MAX_DISCONNECTED_OPENS, 4096.

Source

pub fn discovery(self, discovery: Discovery) -> Self

Announce the server on the local network while SmbServer::serve runs; see Discovery. Off unless called. build fails when the listen address is a loopback address, and when Discovery::ws_discovery is true and the listen port is set to one other than 445 or the NetBIOS name is not one Windows accepts. Needs the discovery feature.

Source

pub fn apple_extensions(self, enabled: bool) -> Self

Answer the AAPL create context that macOS clients send when they mount a share. The reply carries the model string of apple_model, whether the server runs on a Unix host and whether the share’s names are case-sensitive, and the client then treats the server as one with Apple’s SMB2 extensions. macOS keeps one case-sensitivity value per session: shares mounted over one session all take that of the last one mounted. On by default; turned off, the context is ignored.

Source

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

The model string sent to macOS clients in the AAPL reply. Default smb-server. While apple_extensions is on, build fails unless it is 1 to 79 bytes of UTF-8 without control characters.

Source

pub fn apple_copyfile(self, enabled: bool) -> Self

Offers macOS clients the whole-file copy: a COPYCHUNK or COPYCHUNK_WRITE without chunks copies a file with its named streams and its creation and write times in one request. Offered on shares that serve named streams and allow server-side copies, while apple_extensions is on. A connection keeps the offer for every share, and a copy onto a share without named streams carries the data only. On by default.

Source

pub fn build(self) -> Result<SmbServer, BuildError>

Trait Implementations§

Source§

impl Default for SmbServerBuilder

Source§

fn default() -> Self

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> NoneValue for T
where T: Default,

Source§

type NoneType = T

The type of the none-equivalent value that NoneValue::null_value produces.
Source§

fn null_value() -> T

The none-equivalent value.
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 = !

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

fn try_from(value: U) -> Result<T, !>

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<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