Skip to content

Commit

Permalink
FIX - Re-add openssl
Browse files Browse the repository at this point in the history
  • Loading branch information
Elrendio committed Dec 19, 2020
1 parent 29ba403 commit 2446618
Show file tree
Hide file tree
Showing 6 changed files with 316 additions and 155 deletions.
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ 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
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

0 comments on commit 2446618

Please sign in to comment.