Skip to content

Commit 322250f

Browse files
fix test_0rtt
1 parent b9b4b0c commit 322250f

File tree

9 files changed

+25
-26
lines changed

9 files changed

+25
-26
lines changed

src/acceptor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use crate::server;
44
use futures::io::{AsyncRead, AsyncWrite};
55
use rustls::{ServerConfig, ServerSession};
66
use std::future::Future;
7+
use std::io;
78
use std::pin::Pin;
89
use std::sync::Arc;
910
use std::task::{Context, Poll};
10-
use std::io;
1111

1212
/// The TLS accepting part. The acceptor drives
1313
/// the server side of the TLS handshake process. It works
@@ -73,4 +73,4 @@ impl From<Arc<ServerConfig>> for TlsAcceptor {
7373
fn from(inner: Arc<ServerConfig>) -> TlsAcceptor {
7474
TlsAcceptor { inner }
7575
}
76-
}
76+
}

src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::rusttls::stream::Stream;
21
use crate::common::tls_state::TlsState;
2+
use crate::rusttls::stream::Stream;
33
use futures::io::{AsyncRead, AsyncWrite};
44
use rustls::ClientSession;
55
use std::future::Future;

src/common/tls_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ impl TlsState {
3636
_ => true,
3737
}
3838
}
39-
}
39+
}

src/connector.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@ use crate::common::tls_state::TlsState;
33
use crate::client;
44

55
use futures::io::{AsyncRead, AsyncWrite};
6-
use rustls::{ClientConfig,ClientSession};
6+
use rustls::{ClientConfig, ClientSession};
77
use std::future::Future;
8+
use std::io;
89
use std::pin::Pin;
910
use std::sync::Arc;
1011
use std::task::{Context, Poll};
11-
use std::io;
1212
use webpki::DNSNameRef;
1313

1414
/// The TLS connecting part. The acceptor drives
1515
/// the client side of the TLS handshake process. It works
1616
/// on any asynchronous stream.
17-
///
17+
///
1818
/// It provides a simple interface (`connect`), returning a future
1919
/// that will resolve when the handshake process completed. On
2020
/// success, it will hand you an async `TlsStream`.
21-
///
21+
///
2222
/// To create a `TlsConnector` with a non-default configuation, create
2323
/// a `rusttls::ClientConfig` and call `.into()` on it.
2424
///
2525
/// ## Example
26-
///
26+
///
2727
/// ```rust
2828
/// #![feature(async_await)]
2929
///
@@ -67,7 +67,7 @@ impl Default for TlsConnector {
6767

6868
impl TlsConnector {
6969
/// Create a new TlsConnector with default configuration.
70-
///
70+
///
7171
/// This is the same as calling `TlsConnector::default()`.
7272
pub fn new() -> Self {
7373
Default::default()
@@ -157,7 +157,3 @@ impl<IO: AsyncRead + AsyncWrite + Unpin> Future for Connect<IO> {
157157
Pin::new(&mut self.0).poll(cx)
158158
}
159159
}
160-
161-
#[cfg(feature = "early-data")]
162-
#[cfg(test)]
163-
mod test_0rtt;

src/lib.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
33
#![deny(unsafe_code)]
44

5+
mod acceptor;
56
pub mod client;
6-
pub mod server;
77
mod common;
8-
mod rusttls;
98
mod connector;
10-
mod acceptor;
9+
mod rusttls;
10+
pub mod server;
11+
12+
pub use acceptor::TlsAcceptor;
13+
pub use connector::TlsConnector;
1114

12-
pub use acceptor::TlsAcceptor as TlsAcceptor;
13-
pub use connector::TlsConnector as TlsConnector;
15+
#[cfg(feature = "early-data")]
16+
#[cfg(test)]
17+
mod test_0rtt;

src/rusttls/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pub(crate) mod stream;
1+
pub(crate) mod stream;

src/rusttls/stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,5 +258,5 @@ impl<'a, IO: AsyncRead + AsyncWrite + Unpin, S: Session> AsyncWrite for Stream<'
258258
}
259259

260260
#[cfg(test)]
261-
#[path="test_stream.rs"]
261+
#[path = "test_stream.rs"]
262262
mod test_stream;

src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::rusttls::stream::Stream;
21
use crate::common::tls_state::TlsState;
2+
use crate::rusttls::stream::Stream;
33

44
use futures::io::{AsyncRead, AsyncWrite};
55
use rustls::ServerSession;

src/test_0rtt.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::{client::TlsStream, TlsConnector};
2+
use async_std::net::TcpStream;
3+
use async_std::sync::Arc;
24
use futures::executor;
35
use futures::prelude::*;
4-
use romio::tcp::TcpStream;
56
use rustls::ClientConfig;
67
use std::io;
78
use std::net::ToSocketAddrs;
8-
use std::sync::Arc;
99

1010
async fn get(
1111
config: Arc<ClientConfig>,
@@ -16,11 +16,10 @@ async fn get(
1616
let input = format!("GET / HTTP/1.0\r\nHost: {}\r\n\r\n", domain);
1717

1818
let addr = (domain, 443).to_socket_addrs()?.next().unwrap();
19-
let domain = webpki::DNSNameRef::try_from_ascii_str(&domain).unwrap();
2019
let mut buf = Vec::new();
2120

2221
let stream = TcpStream::connect(&addr).await?;
23-
let mut stream = connector.connect(domain, stream).await?;
22+
let mut stream = connector.connect(domain, stream)?.await?;
2423
stream.write_all(input.as_bytes()).await?;
2524
stream.read_to_end(&mut buf).await?;
2625

0 commit comments

Comments
 (0)