SuppaFTP
Introduction 👋
SuppaFTP is the main FTP/FTPS client library for Rust, with both support for sync/async programming and for all the FTP protocol features. It is a fork of the original ftp library "rust-ftp", but since the original library is currently unmaintained, I decided to keep working on this library by myself. Currently, I consider myself as the only maintainer of this project, indeed I've already added some features to the library and improved it with better error handling and test units.
Main differences between SuppaFTP and rust-ftp 🤔
- Replaced OpenSSL with native-tls or rustls as you prefer 🔒
- Added methods to work with streams (e.g.
put_with_stream) ⬇️ - suppaftp supports Active mode
- Added
get_welcome_msgmethod 👋 - Supports for both sync/async rust 🕙
- Supports for more commands 🌟
- ABOR
- APPE
- REST
- EPSV
- EPRT
- Some extra features, such as the LIST command output parser
- Implementation of RFC 2428
- Implementationb of RFC 2389
- Removed deprecated statements ⚰️
- Better error handling 🐛
- Added test units keeping an eye on code coverage 👀
Get started 🏁
To get started, first add suppaftp to your dependencies:
= "^7"
Features
These are all the possible features, by family
- sync FTP:
native-tls: enable FTPS support using native-tls as backend for TLSnative-tls-vendored: enable vendored FTPS support using native-tlsrustls: enable FTPS support using rustls as backend for TLS
- Async FTP:
- Async-std:
async-std: enable async client using async-std as async backendasync-std-async-native-tls: enable FTPS support using async-native-tlsasync-std-async-native-tls-vendored: enable vendored FTPS support using async-native-tlsasync-std-async-rustls: enable FTPS support using async-rustls
- Tokio:
tokio: enable async client using tokio as async backendtokio-async-native-tls: enable FTPS support using async-native-tlstokio-async-native-tls-vendored: enable vendored FTPS support using async-native-tlstokio-async-rustls: enable FTPS support using async-rustls
- Async-std:
- Misc:
deprecated: enable deprecated FTP/FTPS methodsno-log: disable logging
In more details:
SSL/TLS Support
If you want to enable support for FTPS, you must enable the native-tls or rustls feature in your cargo dependencies, based on the TLS provider you prefer.
= { = "^7", = ["native-tls"] }
# or
= { = "^7", = ["rustls"] }
[!NOTE] 💡 If you don't know what to choose,
native-tlsshould be preferred for compatibility reasons.
❗ If you want to link libssl statically, enable featurenative-tls-vendored
Async support
If you want to enable async support, you must enable either async-std feature, to use async-std or tokio feature, to use tokio as backend, in your cargo dependencies.
= { = "^7", = ["tokio"] }
[!CAUTION] ⚠️ If you want to enable both native-tls and async-std you must use the async-std-async-native-tls feature ⚠️
⚠️ If you want to enable both native-tls and tokio you must use the tokio-async-native-tls feature ⚠️ ⚠️ If you want to enable both rustls and async you must use the async-rustls feature ⚠️
❗ If you want to link libssl statically withasync-std, enable featureasync-std-async-native-tls-vendored❗ If you want to link libssl statically withtokio, enable featuretokio-async-native-tls-vendored
Deprecated methods
If you want to enable deprecated methods of FTPS, please enable the deprecated feature in your cargo dependencies.
This feature enables these methods:
connect_secure_implicit(): used to connect via implicit FTPS
Logging
By default, the library will log if there is any log crate consumer on the user implementation.
Logging can be if preferred, disabled via the no-log feature.
Examples 📚
use str;
use Cursor;
use FtpStream;
Ftp with TLS (native-tls)
use ;
use ;
Ftp with TLS (rustls)
You can also find and run this example in the suppaftp/examples/ directory (cargo run --example rustls --features rustls).
use Arc;
use ;
use rustls;
use ClientConfig;
Going Async
use ;
use ;
let ftp_stream = connect.await.unwrap;
// Switch to the secure mode
let mut ftp_stream = ftp_stream.into_secure.await.unwrap;
ftp_stream.login.await.unwrap;
// Do other secret stuff
assert!;
Built-in CLI client 🖥️
SuppaFTP comes also with a built-in command-line FTP client. This CLI application provides all the commands to interact with a remote FTP server and supports FTPS too. You can also use it as a reference to implement your project. You can find it in the cli/ directory.
You can simply install as any other rust application via Cargo:
Support the developer ☕
If you like SuppaFTP, please consider a little donation 🥳
Changelog ⌛
License 📜
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution 🤝
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
If you want to contribute to this project, please read the Contributing guide first 🙂.