Skip to content

Commit

Permalink
Updates due to nightly changes (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbcfd authored May 13, 2019
1 parent ced1300 commit 6bc11cf
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 50 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ edition = "2018"
# - Update CHANGELOG.md.
# - Update doc URL.
# - Create "v0.1.x" git tag.
version = "0.3.0-alpha.5"
version = "0.3.0-alpha.6"
license = "MIT"
readme = "README.md"
description = """
TLS support for AsyncRead/AsyncWrite using native-tls
"""
authors = ["Danny Browning <bdbrowning2@gmail.com>", "Carl Lerche <me@carllerche.com>"]
categories = ["asynchronous", "network-programming"]
documentation = "https://docs.rs/tls-async/0.3.0-alpha.5/tls_async/"
documentation = "https://docs.rs/tls-async/"
repository = "https://github.com/dbcfd/tls-async"

[dependencies]
Expand All @@ -25,13 +25,13 @@ log = "0.4.1"
native-tls = "0.2"

[dependencies.futures]
version = "0.3.0-alpha.14"
version = "0.3.0-alpha.16"
package = "futures-preview"
features = ["compat", "io-compat", "std"]

[dev-dependencies]
cfg-if = "0.1"
romio = "0.3.0-alpha.5"
romio = "0.3.0-alpha.8"
tokio = "0.1"

[dev-dependencies.env_logger]
Expand Down
8 changes: 4 additions & 4 deletions examples/echo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(async_await, await_macro, futures_api)]
#![feature(async_await)]
// A tiny async TLS echo server with Tokio
use futures::{FutureExt, TryFutureExt, StreamExt};
use futures::io::AsyncReadExt;
Expand All @@ -18,16 +18,16 @@ async fn accept_connections() -> () {

// Iterate incoming connections
let mut tcp_incoming = tcp.incoming();
while let Some(tcp) = await!(tcp_incoming.next()) {
while let Some(tcp) = tcp_incoming.next().await {
let tcp = tcp.expect("Error encountered while fetching next");
let tcp = tls_acceptor.accept(tcp);
let tls = async {
let tls = await!(tcp).expect("Failed to form tls connection");
let tls = tcp.await.expect("Failed to form tls connection");
// Split up the read and write halves
let (mut reader, mut writer) = tls.split();

// Copy the data back to the client
match await!(reader.copy_into(&mut writer)) {
match reader.copy_into(&mut writer).await {
Ok(n) => println!("wrote {} bytes", n),
Err(err) => println!("IO error {:?}", err)
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//! functionality provided by the `native-tls` crate, on which this crate is
//! built. Configuration of TLS parameters is still primarily done through the
//! `native-tls` crate.
#![feature(async_await, await_macro)]
#![feature(async_await)]
mod acceptor;
mod connector;
mod errors;
Expand Down
14 changes: 7 additions & 7 deletions tests/bad.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(async_await, await_macro)]
#![feature(async_await)]
use std::net::ToSocketAddrs;

use cfg_if::cfg_if;
Expand Down Expand Up @@ -87,17 +87,17 @@ async fn get_host(host: String) -> Result<(), Error> {
let addr = format!("{}:443", host);
let addr = t!(addr.to_socket_addrs()).next().unwrap();

let socket = t!(await!(TcpStream::connect(&addr)));
let socket = t!(TcpStream::connect(&addr).await);
let builder = TlsConnector::builder();
let cx = t!(builder.build());
await!(cx.connect(&host, socket))?;
cx.connect(&host, socket).await?;
Ok(())
}

#[test]
fn expired() {
let fut_res = async {
await!(get_host("expired.badssl.com".to_owned()))
get_host("expired.badssl.com".to_owned()).await
};
let mut rt = t!(tokio::runtime::Runtime::new());
let res = rt.block_on(fut_res.boxed().compat());
Expand All @@ -112,7 +112,7 @@ fn expired() {
#[cfg_attr(all(target_os = "macos", feature = "force-openssl"), ignore)]
fn wrong_host() {
let fut_res = async {
await!(get_host("wrong.host.badssl.com".to_owned()))
get_host("wrong.host.badssl.com".to_owned()).await
};
let mut rt = t!(tokio::runtime::Runtime::new());
let res = rt.block_on(fut_res.boxed().compat());
Expand All @@ -124,7 +124,7 @@ fn wrong_host() {
#[test]
fn self_signed() {
let fut_res = async {
await!(get_host("self-signed.badssl.com".to_owned()))
get_host("self-signed.badssl.com".to_owned()).await
};
let mut rt = t!(tokio::runtime::Runtime::new());
let res = rt.block_on(fut_res.boxed().compat());
Expand All @@ -136,7 +136,7 @@ fn self_signed() {
#[test]
fn untrusted_root() {
let fut_res = async {
await!(get_host("untrusted-root.badssl.com".to_owned()))
get_host("untrusted-root.badssl.com".to_owned()).await
};
let mut rt = t!(tokio::runtime::Runtime::new());
let res = rt.block_on(fut_res.boxed().compat());
Expand Down
18 changes: 9 additions & 9 deletions tests/google.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(async_await, await_macro)]
#![feature(async_await)]
use std::net::ToSocketAddrs;

use cfg_if::cfg_if;
Expand Down Expand Up @@ -58,7 +58,7 @@ fn fetch_google() {
// First up, resolve google.com
let addr = t!("google.com:443".to_socket_addrs()).next().unwrap();

let socket = t!(await!(TcpStream::connect(&addr)));
let socket = t!(TcpStream::connect(&addr).await);

println!("Connected to google");

Expand All @@ -69,12 +69,12 @@ fn fetch_google() {

println!("Attempting tls connection");

let mut stream = t!(await!(connector.connect("google.com", socket)));
t!(await!(stream.write_all(b"GET / HTTP/1.0\r\n\r\n")));
t!(await!(stream.flush()));
let mut stream = t!(connector.connect("google.com", socket).await);
t!(stream.write_all(b"GET / HTTP/1.0\r\n\r\n").await);
t!(stream.flush().await);
let mut buf = vec![];
t!(await!(stream.read_to_end(&mut buf)));
t!(await!(stream.close()));
t!(stream.read_to_end(&mut buf).await);
t!(stream.close().await);
buf
};

Expand All @@ -99,10 +99,10 @@ fn wrong_hostname_error() {

let fut_result = async {
let addr = t!("google.com:443".to_socket_addrs()).next().unwrap();
let socket = t!(await!(TcpStream::connect(&addr)));
let socket = t!(TcpStream::connect(&addr).await);
let builder = TlsConnector::builder();
let connector = t!(builder.build());
await!(connector.connect("rust-lang.org", socket))
connector.connect("rust-lang.org", socket).await
};

let mut rt = t!(tokio::runtime::Runtime::new());
Expand Down
50 changes: 25 additions & 25 deletions tests/smoke.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(async_await, await_macro)]
#![feature(async_await)]
use std::io::Write;
use std::process::Command;

Expand Down Expand Up @@ -495,22 +495,22 @@ fn client_to_server() {
// read all the data from it.
let fut_server = async move {
let mut incoming = srv.incoming();
let socket = t!(await!(incoming.next()).unwrap());
let socket = t!(incoming.next().await.unwrap());
let f = server_cx.accept(socket);
let mut stream = t!(await!(f));
let mut stream = t!(f.await);
let mut buf = vec![];
t!(await!(stream.read_to_end(&mut buf)));
t!(stream.read_to_end(&mut buf).await);
buf
};

let fut_client = async move {
// Create a future to connect to our server, connect the ssl stream, and
// then write a bunch of data to it.
let socket = t!(await!(TcpStream::connect(&addr)));
let mut socket = t!(await!(client_cx.connect("localhost", socket)));
t!(await!(socket.write_all(&EXPECTED)));
t!(await!(socket.flush()));
t!(await!(socket.close()));
let socket = t!(TcpStream::connect(&addr).await);
let mut socket = t!(client_cx.connect("localhost", socket).await);
t!(socket.write_all(&EXPECTED).await);
t!(socket.flush().await);
t!(socket.close().await);
};

// Finally, run everything!
Expand All @@ -532,18 +532,18 @@ fn server_to_client() {

let fut_server = async move {
let mut incoming = srv.incoming();
let socket = t!(await!(incoming.next()).unwrap());
let mut socket = t!(await!(server_cx.accept(socket)));
t!(await!(socket.write_all(&EXPECTED)));
t!(await!(socket.flush()));
t!(await!(socket.close()));
let socket = t!(incoming.next().await.unwrap());
let mut socket = t!(server_cx.accept(socket).await);
t!(socket.write_all(&EXPECTED).await);
t!(socket.flush().await);
t!(socket.close().await);
};

let fut_client = async move {
let socket = t!(await!(TcpStream::connect(&addr)));
let mut stream = t!(await!(client_cx.connect("localhost", socket)));
let socket = t!(TcpStream::connect(&addr).await);
let mut stream = t!(client_cx.connect("localhost", socket).await);
let mut buf = vec![];
t!(await!(stream.read_to_end(&mut buf)));
t!(stream.read_to_end(&mut buf).await);
buf
};

Expand All @@ -565,21 +565,21 @@ fn one_byte_at_a_time() {

let fut_server = async move {
let mut incoming = srv.incoming();
let socket = t!(await!(incoming.next()).unwrap());
let mut stream = t!(await!(server_cx.accept(socket)));
let socket = t!(incoming.next().await.unwrap());
let mut stream = t!(server_cx.accept(socket).await);
for byte in SMALL_EXPECTED.iter().cloned() {
let to_send = [byte];
t!(await!(stream.write_all(&to_send)));
t!(await!(stream.flush()));
t!(stream.write_all(&to_send).await);
t!(stream.flush().await);
}
t!(await!(stream.close()));
t!(stream.close().await);
};

let fut_client = async move {
let socket = t!(await!(TcpStream::connect(&addr)));
let mut stream = t!(await!(client_cx.connect("localhost", socket)));
let socket = t!(TcpStream::connect(&addr).await);
let mut stream = t!(client_cx.connect("localhost", socket).await);
let mut buf = vec![];
t!(await!(stream.read_to_end(&mut buf)));
t!(stream.read_to_end(&mut buf).await);
buf
};

Expand Down

0 comments on commit 6bc11cf

Please sign in to comment.