Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ script:
|
travis-cargo build &&
travis-cargo test -- --features secure &&
travis-cargo --only stable doc
travis-cargo --only stable doc &&
rustup component add rustfmt &&
cargo fmt --all -- --check

after_success:
# upload the documentation from the build with stable (automatically only actually
Expand Down
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ path = "src/lib.rs"

[features]
# Enable support of FTPS which requires openssl
secure = ["openssl"]
secure = ["native-tls"]

# Add debug output (to STDOUT) of commands sent to the server
# and lines read from the server
debug_print = []

[dependencies]
lazy_static = "0.1"
regex = "0.1"
chrono = "0.2"
lazy_static = "1.4.0"
regex = "1.4.2"
chrono = "0.4.19"

[dependencies.openssl]
version = "0.9"
[dependencies.native-tls]
version = "^0.2"
optional = true
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
rust-ftp
================
# rust-ftp

FTP client for Rust

Expand All @@ -11,15 +10,26 @@ FTP client for Rust

[Documentation](https://docs.rs/ftp/)

---

- [rust-ftp](#rust-ftp)
- [Installation](#installation)
- [Usage](#usage)
- [License](#license)
- [Contribution](#contribution)
- [Development environment](#development-environment)

## Installation

FTPS support is disabled by default. To enable it `secure` should be activated in `Cargo.toml`.
FTPS support is achieved through [rust-native-tls](https://github.com/sfackler/rust-native-tls) and is disabled by default. To enable it `secure` should be activated in `Cargo.toml`.

```toml
[dependencies]
ftp = { version = "<version>", features = ["secure"] }
```

## Usage

```rust
extern crate ftp;

Expand All @@ -34,7 +44,7 @@ fn main() {

// Get the current directory that the client will be reading from and writing to.
println!("Current directory: {}", ftp_stream.pwd().unwrap());

// Change into a new directory, relative to the one we are currently in.
let _ = ftp_stream.cwd("test_data").unwrap();

Expand All @@ -57,8 +67,8 @@ fn main() {

Licensed under either of

* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)

at your option.

Expand Down Expand Up @@ -96,6 +106,7 @@ cargo test
```

The following commands can be useful:

```bash
# List running containers of ftp-server image
# (to include stopped containers use -a option)
Expand Down
4 changes: 2 additions & 2 deletions examples/connecting.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
extern crate ftp;

use std::str;
use ftp::{FtpError, FtpStream};
use std::io::Cursor;
use ftp::{FtpStream, FtpError};
use std::str;

fn test_ftp(addr: &str, user: &str, pass: &str) -> Result<(), FtpError> {
let mut ftp_stream = FtpStream::connect((addr, 21)).unwrap();
Expand Down
12 changes: 5 additions & 7 deletions src/data_stream.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use std::io::{Read, Write, Result};
use std::net::TcpStream;
#[cfg(feature = "secure")]
use openssl::ssl::SslStream;

use native_tls::TlsStream;
use std::io::{Read, Result, Write};
use std::net::TcpStream;

/// Data Stream used for communications
#[derive(Debug)]
pub enum DataStream {
Tcp(TcpStream),
#[cfg(feature = "secure")]
Ssl(SslStream<TcpStream>),
Ssl(TlsStream<TcpStream>),
}

#[cfg(feature = "secure")]
Expand All @@ -26,7 +25,7 @@ impl DataStream {
pub fn is_ssl(&self) -> bool {
match self {
&DataStream::Ssl(_) => true,
_ => false
_ => false,
}
}
}
Expand All @@ -52,7 +51,6 @@ impl Read for DataStream {
}
}


impl Write for DataStream {
fn write(&mut self, buf: &[u8]) -> Result<usize> {
match self {
Expand Down
Loading