pub struct SmbServerBuilder { /* private fields */ }Expand description
Builder for SmbServer. See SmbServer::builder.
Implementations§
Source§impl SmbServerBuilder
impl SmbServerBuilder
pub fn listen(self, addr: SocketAddr) -> Self
pub fn user(self, name: impl Into<String>, password: impl Into<String>) -> Self
pub fn netbios_name(self, name: impl Into<String>) -> Self
Sourcepub fn require_signing(self, required: bool) -> Self
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.
Sourcepub fn encrypt_data(self, encrypt: bool) -> Self
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.
Sourcepub fn reject_unencrypted_access(self, reject: bool) -> Self
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.
Sourcepub fn max_sessions_per_connection(self, sessions: usize) -> Self
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.
Sourcepub fn max_trees_per_session(self, trees: usize) -> Self
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.
Sourcepub fn logon_throttle(self, max_failures: u32, lockout: Duration) -> Self
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.
pub fn max_read_size(self, bytes: u32) -> Self
pub fn max_write_size(self, bytes: u32) -> Self
Sourcepub fn server_guid(self, guid: Uuid) -> Self
pub fn server_guid(self, guid: Uuid) -> Self
Override the random per-process server GUID. Mostly useful in tests.
Sourcepub fn max_connections(self, connections: usize) -> Self
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.
Sourcepub fn handshake_timeout(self, timeout: Duration) -> Self
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.
Sourcepub fn idle_timeout(self, timeout: Duration) -> Self
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.
Sourcepub fn io_timeout(self, timeout: Duration) -> Self
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.
Sourcepub fn tcp_keepalive(self, idle: Option<Duration>) -> Self
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.
Sourcepub fn max_opens_per_connection(self, opens: usize) -> Self
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.
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.
Sourcepub fn max_locks_per_open(self, locks: usize) -> Self
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.
Sourcepub fn durable_handle_timeout(self, timeout: Duration) -> Self
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.
Sourcepub fn max_disconnected_opens(self, opens: usize) -> Self
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.
Sourcepub fn discovery(self, discovery: Discovery) -> Self
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.
Sourcepub fn apple_extensions(self, enabled: bool) -> Self
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.
Sourcepub fn apple_model(self, model: impl Into<String>) -> Self
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.
Sourcepub fn apple_copyfile(self, enabled: bool) -> Self
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.
pub fn build(self) -> Result<SmbServer, BuildError>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SmbServerBuilder
impl !UnwindSafe for SmbServerBuilder
impl Forget for SmbServerBuilder
impl Freeze for SmbServerBuilder
impl Move for SmbServerBuilder
impl Send for SmbServerBuilder
impl Sync for SmbServerBuilder
impl Unpin for SmbServerBuilder
impl UnsafeUnpin for SmbServerBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
Source§type NoneType = T
type NoneType = T
NoneValue::null_value produces.