@ -9,6 +9,7 @@ use std::pin::Pin;
use std ::process ::{ Child , Command , Stdio } ;
use std ::sync ::Arc ;
use std ::task ::{ Context , Poll } ;
use std ::thread ;
use std ::time ::Duration ;
use tokio ::io ::{ split , AsyncRead , AsyncWriteExt , ReadBuf } ;
use tokio ::net ::TcpStream ;
@ -34,6 +35,7 @@ impl<T: AsyncRead + Unpin> Future for Read1<T> {
if buf . filled ( ) . is_empty ( ) {
Poll ::Ready ( Ok ( ( ) ) )
} else {
cx . waker ( ) . wake_by_ref ( ) ;
Poll ::Pending
}
}
@ -46,7 +48,7 @@ async fn send(
) -> io ::Result < TlsStream < TcpStream > > {
let connector = TlsConnector ::from ( config ) . early_data ( true ) ;
let stream = TcpStream ::connect ( & addr ) . await ? ;
let domain = rustls ::ServerName ::try_from ( "testserve r.com" ) . unwrap ( ) ;
let domain = rustls ::ServerName ::try_from ( "fooba r.com" ) . unwrap ( ) ;
let stream = connector . connect ( domain , stream ) . await ? ;
let ( mut rd , mut wd ) = split ( stream ) ;
@ -140,6 +142,17 @@ async fn test_0rtt() -> io::Result<()> {
let config = Arc ::new ( config ) ;
let addr = SocketAddr ::from ( ( [ 127 , 0 , 0 , 1 ] , 12354 ) ) ;
// workaround: write to openssl s_server standard input periodically, to
// get it unstuck on Windows
let stdin = handle . 0. stdin . take ( ) . unwrap ( ) ;
thread ::spawn ( move | | {
let mut stdin = stdin ;
loop {
thread ::sleep ( std ::time ::Duration ::from_secs ( 5 ) ) ;
std ::io ::Write ::write_all ( & mut stdin , b" \n " ) . unwrap ( ) ;
}
} ) ;
let io = send ( config . clone ( ) , addr , b" hello " ) . await ? ;
assert! ( ! io . get_ref ( ) . 1. is_early_data_accepted ( ) ) ;