diff --git a/Cargo.toml b/Cargo.toml index 96e1c79..cd8a8de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,8 +17,8 @@ appveyor = { repository = "quininer/tokio-rustls" } [dependencies] smallvec = "0.6" -tokio-io = "0.2.0-alpha.1" -futures-core-preview = "0.3.0-alpha.17" +tokio-io = "=0.2.0-alpha.4" +futures-core-preview = "=0.3.0-alpha.18" rustls = "0.16" webpki = "0.21" @@ -26,7 +26,7 @@ webpki = "0.21" early-data = [] [dev-dependencies] -tokio = "0.2.0-alpha.1" -futures-util-preview = "0.3.0-alpha.17" +tokio = "=0.2.0-alpha.4" +futures-util-preview = "0.3.0-alpha.18" lazy_static = "1" webpki-roots = "0.17" diff --git a/src/lib.rs b/src/lib.rs index f09e02d..f631a09 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,22 +1,19 @@ //! Asynchronous TLS/SSL streams for Tokio using [Rustls](https://github.com/ctz/rustls). -#![cfg_attr(test, feature(async_await))] - - -mod common; pub mod client; +mod common; pub mod server; -use std::{ io, mem }; -use std::sync::Arc; -use std::pin::Pin; -use std::future::Future; -use std::task::{ Poll, Context }; -use tokio_io::{ AsyncRead, AsyncWrite }; -use futures_core as futures; -use rustls::{ ClientConfig, ClientSession, ServerConfig, ServerSession }; -use webpki::DNSNameRef; use common::Stream; +use futures_core as futures; +use rustls::{ClientConfig, ClientSession, ServerConfig, ServerSession}; +use std::future::Future; +use std::pin::Pin; +use std::sync::Arc; +use std::task::{Context, Poll}; +use std::{io, mem}; +use tokio_io::{AsyncRead, AsyncWrite}; +use webpki::DNSNameRef; pub use rustls; pub use webpki; diff --git a/tests/test.rs b/tests/test.rs index 1db59ca..42dd9ed 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -1,5 +1,3 @@ -#![feature(async_await)] - use std::{ io, thread }; use std::io::{ BufReader, Cursor }; use std::sync::Arc; @@ -36,7 +34,7 @@ lazy_static!{ let done = async move { let addr = SocketAddr::from(([127, 0, 0, 1], 0)); - let listener = TcpListener::bind(&addr)?; + let listener = TcpListener::bind(&addr).await?; send.send(listener.local_addr()?).unwrap(); @@ -97,6 +95,13 @@ async fn start_client(addr: SocketAddr, domain: &str, config: Arc) async fn pass() -> io::Result<()> { let (addr, domain, chain) = start_server(); + // TODO: not sure how to resolve this right now but since + // TcpStream::bind now returns a future it creates a race + // condition until its ready sometimes. + use std::time::*; + let deadline = Instant::now() + Duration::from_secs(1); + tokio::timer::delay(deadline); + let mut config = ClientConfig::new(); let mut chain = BufReader::new(Cursor::new(chain)); config.root_store.add_pem_file(&mut chain).unwrap();