diff --git a/Cargo.toml b/Cargo.toml index 63db804..1adcbb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ yaml = ["yaml_config"] proxy = ["tokio-socks"] -tls-native = ["native-tls", "tokio-tls"] +tls-native = ["native-tls", "tokio-native-tls"] tls-rust = ["tokio-rustls", "webpki-roots"] @@ -52,8 +52,8 @@ log = "0.4.0" parking_lot = "0.11.0" pin-utils = "0.1.0-alpha.4" thiserror = "1.0.0" -tokio = { version = "0.2.0", features = ["macros", "net", "stream", "time"] } -tokio-util = { version = "0.3.0", features = ["codec"] } +tokio = { version = "0.3.0", features = ["net", "stream", "time"] } +tokio-util = { version = "0.4.0", features = ["codec"] } # Feature - Config serde = { version = "1.0.0", optional = true } @@ -67,8 +67,8 @@ tokio-socks = { version = "0.3.0", optional = true } # Feature - TLS native-tls = { version = "0.2.0", optional = true } -tokio-rustls = { version = "0.14.0", optional = true } -tokio-tls = { version = "0.3.0", optional = true } +tokio-rustls = { version = "0.20.0", optional = true } +tokio-native-tls = { version = "0.2.0", optional = true } webpki-roots = { version = "0.20.0", optional = true } @@ -78,6 +78,7 @@ args = "2.0.0" env_logger = "0.7.0" futures = "0.3.0" getopts = "0.2.0" +tokio = { version = "0.3.0", features = ["rt", "rt-multi-thread", "macros", "net", "stream", "time"] } [[example]] diff --git a/irc-proto/Cargo.toml b/irc-proto/Cargo.toml index 069b3bf..3f31e3c 100644 --- a/irc-proto/Cargo.toml +++ b/irc-proto/Cargo.toml @@ -21,5 +21,5 @@ encoding = "0.2.0" thiserror = "1.0.0" bytes = { version = "0.5.0", optional = true } -tokio = { version = "0.2.0", optional = true } -tokio-util = { version = "0.3.0", features = ["codec"], optional = true } +tokio = { version = "0.3.0", optional = true } +tokio-util = { version = "0.4.0", features = ["codec"], optional = true } diff --git a/src/client/conn.rs b/src/client/conn.rs index 716b8f8..c01b872 100644 --- a/src/client/conn.rs +++ b/src/client/conn.rs @@ -7,7 +7,7 @@ use std::{ task::{Context, Poll}, }; use tokio::net::TcpStream; -use tokio_util::codec::Decoder; +use tokio_util::codec::Framed; #[cfg(feature = "proxy")] use tokio_socks::tcp::Socks5Stream; @@ -22,7 +22,7 @@ use std::{fs::File, io::Read}; use native_tls::{Certificate, Identity, TlsConnector}; #[cfg(feature = "tls-native")] -use tokio_tls::{self, TlsStream}; +use tokio_native_tls::{self, TlsStream}; #[cfg(feature = "tls-rust")] use std::{ @@ -150,7 +150,7 @@ impl Connection { tx: UnboundedSender, ) -> error::Result> { let stream = Self::new_stream(config).await?; - let framed = IrcCodec::new(config.encoding())?.framed(stream); + let framed = Framed::new(stream, IrcCodec::new(config.encoding())?); Ok(Transport::new(&config, framed, tx)) } @@ -184,12 +184,12 @@ impl Connection { ); } - let connector: tokio_tls::TlsConnector = builder.build()?.into(); + let connector: tokio_native_tls::TlsConnector = builder.build()?.into(); let domain = config.server()?; let stream = Self::new_stream(config).await?; let stream = connector.connect(domain, stream).await?; - let framed = IrcCodec::new(config.encoding())?.framed(stream); + let framed = Framed::new(stream, IrcCodec::new(config.encoding())?); Ok(Transport::new(&config, framed, tx)) } @@ -236,7 +236,7 @@ impl Connection { let stream = Self::new_stream(config).await?; let stream = connector.connect(domain, stream).await?; - let framed = IrcCodec::new(config.encoding())?.framed(stream); + let framed = Framed::new(stream, IrcCodec::new(config.encoding())?); Ok(Transport::new(&config, framed, tx)) } @@ -262,7 +262,7 @@ impl Connection { })?; let stream = MockStream::new(&initial); - let framed = IrcCodec::new(config.encoding())?.framed(stream); + let framed = Framed::new(stream, IrcCodec::new(config.encoding())?); Ok(Transport::new(&config, framed, tx)) } diff --git a/src/client/mock.rs b/src/client/mock.rs index e1c3334..eb7e885 100644 --- a/src/client/mock.rs +++ b/src/client/mock.rs @@ -3,7 +3,7 @@ use std::{ pin::Pin, task::{Context, Poll}, }; -use tokio::io::{AsyncRead, AsyncWrite}; +use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; /// A fake stream for testing network applications backed by buffers. #[derive(Clone, Debug)] @@ -41,9 +41,11 @@ impl AsyncRead for MockStream { fn poll_read( mut self: Pin<&mut Self>, _: &mut Context<'_>, - buf: &mut [u8], - ) -> Poll> { - Poll::Ready(self.as_mut().received.read(buf)) + buf: &mut ReadBuf<'_>, + ) -> Poll> { + let n = self.as_mut().received.read(buf.initialize_unfilled())?; + buf.advance(n); + Poll::Ready(Ok(())) } } diff --git a/src/client/transport.rs b/src/client/transport.rs index 1d10ffa..573d566 100644 --- a/src/client/transport.rs +++ b/src/client/transport.rs @@ -13,7 +13,7 @@ use futures_channel::mpsc::UnboundedSender; use futures_util::{future::Future, ready, sink::Sink, stream::Stream}; use tokio::{ io::{AsyncRead, AsyncWrite}, - time::{self, Delay, Interval}, + time::{self, Interval, Sleep}, }; use tokio_util::codec::Framed; @@ -31,7 +31,7 @@ struct Pinger { /// The amount of time to wait before timing out from no ping response. ping_timeout: Duration, /// The instant that the last ping was sent to the server. - ping_deadline: Option, + ping_deadline: Option, /// The interval at which to send pings. ping_interval: Interval, } @@ -98,7 +98,7 @@ impl Pinger { /// Set the ping deadline. fn set_deadline(&mut self) { if self.ping_deadline.is_none() { - let ping_deadline = time::delay_for(self.ping_timeout); + let ping_deadline = time::sleep(self.ping_timeout); self.ping_deadline = Some(ping_deadline); } }