Merge branch 'master' into vecio
This commit is contained in:
commit
3faca3ee3d
15
Cargo.toml
15
Cargo.toml
@ -15,22 +15,15 @@ travis-ci = { repository = "quininer/tokio-rustls" }
|
||||
appveyor = { repository = "quininer/tokio-rustls" }
|
||||
|
||||
[dependencies]
|
||||
futures-core = { version = "0.2.0", optional = true }
|
||||
futures-io = { version = "0.2.0", optional = true }
|
||||
tokio = { version = "0.1.6", optional = true }
|
||||
bytes = { version = "*" }
|
||||
iovec = { version = "*" }
|
||||
bytes = { version = "0.4", optional = true }
|
||||
iovec = { version = "0.1", optional = true }
|
||||
rustls = "0.13"
|
||||
webpki = "0.18.1"
|
||||
|
||||
[dev-dependencies]
|
||||
# futures = "0.2.0"
|
||||
tokio = "0.1.6"
|
||||
|
||||
[features]
|
||||
default = [ "tokio" ]
|
||||
# unstable-futures = [
|
||||
# "futures-core",
|
||||
# "futures-io",
|
||||
# "tokio/unstable-futures"
|
||||
# ]
|
||||
default = [ "tokio_impl" ]
|
||||
tokio_impl = [ "tokio", "bytes", "iovec" ]
|
||||
|
@ -11,8 +11,7 @@ extern crate iovec;
|
||||
|
||||
|
||||
mod common;
|
||||
#[cfg(feature = "tokio")] mod tokio_impl;
|
||||
#[cfg(feature = "unstable-futures")] mod futures_impl;
|
||||
#[cfg(feature = "tokio_impl")] mod tokio_impl;
|
||||
|
||||
use std::io;
|
||||
use std::sync::Arc;
|
||||
|
@ -83,32 +83,6 @@ fn start_client(addr: &SocketAddr, domain: &str, chain: Option<BufReader<Cursor<
|
||||
done.wait()
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable-futures")]
|
||||
fn start_client2(addr: &SocketAddr, domain: &str, chain: Option<BufReader<Cursor<&str>>>) -> io::Result<()> {
|
||||
use futures::FutureExt;
|
||||
use futures::io::{ AsyncReadExt, AsyncWriteExt };
|
||||
use futures::executor::block_on;
|
||||
|
||||
let domain = webpki::DNSNameRef::try_from_ascii_str(domain).unwrap();
|
||||
let mut config = ClientConfig::new();
|
||||
if let Some(mut chain) = chain {
|
||||
config.root_store.add_pem_file(&mut chain).unwrap();
|
||||
}
|
||||
let config = Arc::new(config);
|
||||
|
||||
let done = TcpStream::connect(addr)
|
||||
.and_then(|stream| config.connect_async(domain, stream))
|
||||
.and_then(|stream| stream.write_all(HELLO_WORLD))
|
||||
.and_then(|(stream, _)| stream.read_exact(vec![0; HELLO_WORLD.len()]))
|
||||
.and_then(|(stream, buf)| {
|
||||
assert_eq!(buf, HELLO_WORLD);
|
||||
stream.close()
|
||||
})
|
||||
.map(drop);
|
||||
|
||||
block_on(done)
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn pass() {
|
||||
@ -120,17 +94,6 @@ fn pass() {
|
||||
start_client(&addr, "localhost", Some(chain)).unwrap();
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable-futures")]
|
||||
#[test]
|
||||
fn pass2() {
|
||||
let cert = certs(&mut BufReader::new(Cursor::new(CERT))).unwrap();
|
||||
let mut keys = rsa_private_keys(&mut BufReader::new(Cursor::new(RSA))).unwrap();
|
||||
let chain = BufReader::new(Cursor::new(CHAIN));
|
||||
|
||||
let addr = start_server(cert, keys.pop().unwrap());
|
||||
start_client2(&addr, "localhost", Some(chain)).unwrap();
|
||||
}
|
||||
|
||||
#[should_panic]
|
||||
#[test]
|
||||
fn fail() {
|
||||
|
Loading…
Reference in New Issue
Block a user