Skip to content

FIX - Re-add openssl #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 13, 2021
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
14 changes: 9 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ path = "src/lib.rs"

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

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

[dependencies]
lazy_static = "1.4.0"
regex = "1.4.2"
chrono = "0.4.19"
lazy_static = "1"
regex = "1"
chrono = "0.4"
openssl = { version = "0.10", optional = true }

[dependencies.native-tls]
version = "^0.2"
version = "0.2"
optional = true

[package.metadata.docs.rs]
rustc-args = ["--cfg", "secure"]
5 changes: 2 additions & 3 deletions examples/connecting.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
extern crate ftp;

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

fn test_ftp(addr: &str, user: &str, pass: &str) -> Result<(), FtpError> {
let mut ftp_stream = FtpStream::connect((addr, 21)).unwrap();
let (mut ftp_stream, _welcome_msg) = FtpStream::connect((addr, 21)).unwrap();
ftp_stream.login(user, pass).unwrap();
println!("current dir: {}", ftp_stream.pwd().unwrap());

Expand Down
15 changes: 11 additions & 4 deletions src/data_stream.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
#[cfg(feature = "secure")]
#[cfg(all(feature = "secure", feature = "native-tls"))]
use native_tls::TlsStream;
use std::io::{Read, Result, Write};
use std::net::TcpStream;
#[cfg(all(feature = "secure", not(feature = "native-tls")))]
use openssl::ssl::SslStream;

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

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

Expand Down
Loading