[−][src]Struct libunftp::Server
An instance of a FTP server. It contains a reference to an Authenticator
that will be used
for authentication, and a StorageBackend
that will be used as the storage backend.
The server can be started with the listen
method.
Example
use libunftp::Server; use tokio::runtime::Runtime; let mut rt = Runtime::new().unwrap(); let server = Server::new_with_fs_root("/srv/ftp"); rt.spawn(server.listen("127.0.0.1:2121")); // ... drop(rt);
Methods
impl Server<Filesystem, DefaultUser>
[src]
pub fn new_with_fs_root<P: Into<PathBuf> + Send + 'static>(path: P) -> Self
[src]
Create a new Server
with the given filesystem root.
Example
use libunftp::Server; let server = Server::new_with_fs_root("/srv/ftp");
impl<S, U> Server<S, U> where
S: 'static + StorageBackend<U> + Sync + Send,
S::File: AsyncRead + Send,
S::Metadata: Metadata,
U: UserDetail + 'static,
[src]
S: 'static + StorageBackend<U> + Sync + Send,
S::File: AsyncRead + Send,
S::Metadata: Metadata,
U: UserDetail + 'static,
pub fn new(s: Box<dyn Fn() -> S + Send + Sync>) -> Self where
AnonymousAuthenticator: Authenticator<U>,
[src]
AnonymousAuthenticator: Authenticator<U>,
Construct a new Server
with the given StorageBackend
. The other parameters will be
set to defaults.
pub fn new_with_authenticator(
s: Box<dyn Fn() -> S + Send + Sync>,
authenticator: Arc<dyn Authenticator<U> + Send + Sync>
) -> Self
[src]
s: Box<dyn Fn() -> S + Send + Sync>,
authenticator: Arc<dyn Authenticator<U> + Send + Sync>
) -> Self
Construct a new Server
with the given StorageBackend
and Authenticator
. The other parameters will be set to defaults.
pub fn greeting(self, greeting: &'static str) -> Self
[src]
Set the greeting that will be sent to the client after connecting.
Example
use libunftp::Server; // Use it in a builder-like pattern: let mut server = Server::new_with_fs_root("/tmp").greeting("Welcome to my FTP Server"); // Or instead if you prefer: let mut server = Server::new_with_fs_root("/tmp"); server.greeting("Welcome to my FTP Server");
pub fn authenticator(
self,
authenticator: Arc<dyn Authenticator<U> + Send + Sync>
) -> Self
[src]
self,
authenticator: Arc<dyn Authenticator<U> + Send + Sync>
) -> Self
Set the Authenticator
that will be used for authentication.
Example
use libunftp::{auth, auth::AnonymousAuthenticator, Server}; use std::sync::Arc; // Use it in a builder-like pattern: let mut server = Server::new_with_fs_root("/tmp") .authenticator(Arc::new(auth::AnonymousAuthenticator{}));
pub fn passive_ports(self, range: Range<u16>) -> Self
[src]
Set the range of passive ports that we'll use for passive connections.
Example
use libunftp::Server; // Use it in a builder-like pattern: let mut server = Server::new_with_fs_root("/tmp").passive_ports(49152..65535); // Or instead if you prefer: let mut server = Server::new_with_fs_root("/tmp"); server.passive_ports(49152..65535);
pub fn ftps<P: Into<PathBuf>, T: Into<String>>(
self,
certs_file: P,
password: T
) -> Self
[src]
self,
certs_file: P,
password: T
) -> Self
Configures the path to the certificates file (DER-formatted PKCS #12 archive) and the associated password for the archive in order to configure FTPS.
Example
use libunftp::Server; let mut server = Server::new_with_fs_root("/tmp").ftps("/srv/unftp/server-certs.pfx", "thepassword");
pub fn metrics(self) -> Self
[src]
Enable the collection of prometheus metrics.
Example
use libunftp::Server; // Use it in a builder-like pattern: let mut server = Server::new_with_fs_root("/tmp").metrics(); // Or instead if you prefer: let mut server = Server::new_with_fs_root("/tmp"); server.metrics();
pub fn idle_session_timeout(self, secs: u64) -> Self
[src]
Set the idle session timeout in seconds. The default is 600 seconds.
Example
use libunftp::Server; // Use it in a builder-like pattern: let mut server = Server::new_with_fs_root("/tmp").idle_session_timeout(600); // Or instead if you prefer: let mut server = Server::new_with_fs_root("/tmp"); server.idle_session_timeout(600);
pub fn proxy_protocol_mode(
self,
external_ip: &str,
external_control_port: u16
) -> Result<Self, Box<dyn Error>>
[src]
self,
external_ip: &str,
external_control_port: u16
) -> Result<Self, Box<dyn Error>>
Enable PROXY protocol mode.
If you use a proxy such as haproxy or nginx, you can enable the PROXY protocol (https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt).
Configure your proxy to enable PROXY protocol encoding for control and data external listening ports, forwarding these connections to the libunFTP listening port in proxy protocol mode.
In PROXY protocol mode, libunftp receives both control and
data connections on the listening port. It then distinguishes
control and data connections by comparing the original
destination port (extracted from the PROXY header) with the
port specified as the external_control_port
proxy_protocol_mode
parameter.
For the passive listening port, libunftp reports the IP
address specified as the external_ip
proxy_protocol_mode
parameter.
Example
use libunftp::Server; // Use it in a builder-like pattern: let mut server = Server::new_with_fs_root("/tmp").proxy_protocol_mode("10.0.0.1", 2121).unwrap();
pub async fn listen<T: Into<String>>(self, bind_address: T)
[src]
Runs the main ftp process asynchronously. Should be started in a async runtime context.
Example
use libunftp::Server; use tokio::runtime::Runtime; let mut rt = Runtime::new().unwrap(); let server = Server::new_with_fs_root("/srv/ftp"); rt.spawn(server.listen("127.0.0.1:2121")); // ... drop(rt);
Panics
This function panics when called with invalid addresses or when the process is unable to
bind()
to the address.
Auto Trait Implementations
impl<S, U> !RefUnwindSafe for Server<S, U>
impl<S, U> Send for Server<S, U>
impl<S, U> Sync for Server<S, U>
impl<S, U> Unpin for Server<S, U>
impl<S, U> !UnwindSafe for Server<S, U>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,