Update to tokio 0.2.0-alpha.4 (#45)

This commit is contained in:
Lucio Franco 2019-09-01 01:29:07 -04:00 committed by quininer
parent 0fceadf799
commit c190031761
3 changed files with 22 additions and 20 deletions

View File

@ -17,8 +17,8 @@ appveyor = { repository = "quininer/tokio-rustls" }
[dependencies] [dependencies]
smallvec = "0.6" smallvec = "0.6"
tokio-io = "0.2.0-alpha.1" tokio-io = "=0.2.0-alpha.4"
futures-core-preview = "0.3.0-alpha.17" futures-core-preview = "=0.3.0-alpha.18"
rustls = "0.16" rustls = "0.16"
webpki = "0.21" webpki = "0.21"
@ -26,7 +26,7 @@ webpki = "0.21"
early-data = [] early-data = []
[dev-dependencies] [dev-dependencies]
tokio = "0.2.0-alpha.1" tokio = "=0.2.0-alpha.4"
futures-util-preview = "0.3.0-alpha.17" futures-util-preview = "0.3.0-alpha.18"
lazy_static = "1" lazy_static = "1"
webpki-roots = "0.17" webpki-roots = "0.17"

View File

@ -1,22 +1,19 @@
//! Asynchronous TLS/SSL streams for Tokio using [Rustls](https://github.com/ctz/rustls). //! Asynchronous TLS/SSL streams for Tokio using [Rustls](https://github.com/ctz/rustls).
#![cfg_attr(test, feature(async_await))]
mod common;
pub mod client; pub mod client;
mod common;
pub mod server; 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 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 rustls;
pub use webpki; pub use webpki;

View File

@ -1,5 +1,3 @@
#![feature(async_await)]
use std::{ io, thread }; use std::{ io, thread };
use std::io::{ BufReader, Cursor }; use std::io::{ BufReader, Cursor };
use std::sync::Arc; use std::sync::Arc;
@ -36,7 +34,7 @@ lazy_static!{
let done = async move { let done = async move {
let addr = SocketAddr::from(([127, 0, 0, 1], 0)); 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(); send.send(listener.local_addr()?).unwrap();
@ -97,6 +95,13 @@ async fn start_client(addr: SocketAddr, domain: &str, config: Arc<ClientConfig>)
async fn pass() -> io::Result<()> { async fn pass() -> io::Result<()> {
let (addr, domain, chain) = start_server(); 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 config = ClientConfig::new();
let mut chain = BufReader::new(Cursor::new(chain)); let mut chain = BufReader::new(Cursor::new(chain));
config.root_store.add_pem_file(&mut chain).unwrap(); config.root_store.add_pem_file(&mut chain).unwrap();