Merge branch 'master' into vecio

This commit is contained in:
quininer 2018-08-16 19:04:12 +08:00
commit 3faca3ee3d
3 changed files with 5 additions and 50 deletions

View File

@ -15,22 +15,15 @@ travis-ci = { repository = "quininer/tokio-rustls" }
appveyor = { repository = "quininer/tokio-rustls" } appveyor = { repository = "quininer/tokio-rustls" }
[dependencies] [dependencies]
futures-core = { version = "0.2.0", optional = true }
futures-io = { version = "0.2.0", optional = true }
tokio = { version = "0.1.6", optional = true } tokio = { version = "0.1.6", optional = true }
bytes = { version = "*" } bytes = { version = "0.4", optional = true }
iovec = { version = "*" } iovec = { version = "0.1", optional = true }
rustls = "0.13" rustls = "0.13"
webpki = "0.18.1" webpki = "0.18.1"
[dev-dependencies] [dev-dependencies]
# futures = "0.2.0"
tokio = "0.1.6" tokio = "0.1.6"
[features] [features]
default = [ "tokio" ] default = [ "tokio_impl" ]
# unstable-futures = [ tokio_impl = [ "tokio", "bytes", "iovec" ]
# "futures-core",
# "futures-io",
# "tokio/unstable-futures"
# ]

View File

@ -11,8 +11,7 @@ extern crate iovec;
mod common; mod common;
#[cfg(feature = "tokio")] mod tokio_impl; #[cfg(feature = "tokio_impl")] mod tokio_impl;
#[cfg(feature = "unstable-futures")] mod futures_impl;
use std::io; use std::io;
use std::sync::Arc; use std::sync::Arc;

View File

@ -83,32 +83,6 @@ fn start_client(addr: &SocketAddr, domain: &str, chain: Option<BufReader<Cursor<
done.wait() 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] #[test]
fn pass() { fn pass() {
@ -120,17 +94,6 @@ fn pass() {
start_client(&addr, "localhost", Some(chain)).unwrap(); 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] #[should_panic]
#[test] #[test]
fn fail() { fn fail() {