diff --git a/actix-server-config/Cargo.toml b/actix-server-config/Cargo.toml index 58d0486d..caf201e7 100644 --- a/actix-server-config/Cargo.toml +++ b/actix-server-config/Cargo.toml @@ -14,10 +14,10 @@ name = "actix_server_config" path = "src/lib.rs" [package.metadata.docs.rs] -features = ["ssl", "rust-tls", "uds"] +features = ["ssl", "rust-tls"] [features] -default = ["ssl", "rustls" ] +default = [] # openssl ssl = ["tokio-openssl"] @@ -25,15 +25,13 @@ ssl = ["tokio-openssl"] # rustls rust-tls = ["rustls", "tokio-rustls"] -# unix domain sockets -# TODO: FIXME -uds = [] # ["tokio-uds"] - [dependencies] -futures = { package = "futures-preview", version = "0.3.0-alpha.18" } -tokio = "0.2.0-alpha.4" +futures = "0.3.1" +tokio = "0.2.0-alpha.6" -tokio-openssl = { version="0.4.0-alpha.4", optional = true } +# openssl +tokio-openssl = { version = "0.4.0-alpha.6", optional = true } + +# rustls rustls = { version = "0.16.0", optional = true } -tokio-rustls = { version = "0.12.0-alpha.2", optional = true } -#tokio-uds = { version="0.3.0-alpha.1", optional = true } +tokio-rustls = { version = "0.12.0-alpha.8", optional = true } diff --git a/actix-server-config/src/lib.rs b/actix-server-config/src/lib.rs index bc487b86..11dc4971 100644 --- a/actix-server-config/src/lib.rs +++ b/actix-server-config/src/lib.rs @@ -1,10 +1,12 @@ +//! Actix server config utils. + use std::cell::Cell; use std::net::SocketAddr; use std::rc::Rc; -use std::{fmt, io, net, time}; +use std::{fmt, io, net, ops, time}; use tokio::io::{AsyncRead, AsyncWrite}; -use tokio::net::tcp::TcpStream; +use tokio::net::TcpStream; #[derive(Debug, Clone)] pub struct ServerConfig { @@ -13,6 +15,7 @@ pub struct ServerConfig { } impl ServerConfig { + #[inline] pub fn new(addr: SocketAddr) -> Self { ServerConfig { addr, @@ -21,16 +24,19 @@ impl ServerConfig { } /// Returns the address of the local half of this TCP server socket + #[inline] pub fn local_addr(&self) -> SocketAddr { self.addr } /// Returns true if connection is secure (tls enabled) + #[inline] pub fn secure(&self) -> bool { self.secure.as_ref().get() } /// Set secure flag + #[inline] pub fn set_secure(&self) { self.secure.as_ref().set(true) } @@ -114,7 +120,7 @@ impl Io { } } -impl std::ops::Deref for Io { +impl ops::Deref for Io { type Target = T; fn deref(&self) -> &T { @@ -122,14 +128,14 @@ impl std::ops::Deref for Io { } } -impl std::ops::DerefMut for Io { +impl ops::DerefMut for Io { fn deref_mut(&mut self) -> &mut T { &mut self.io } } impl fmt::Debug for Io { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Io {{{:?}}}", self.io) } } @@ -171,7 +177,7 @@ impl IoStream for TcpStream { } } -#[cfg(any(feature = "ssl"))] +#[cfg(feature = "ssl")] impl IoStream for tokio_openssl::SslStream { #[inline] fn peer_addr(&self) -> Option { @@ -194,8 +200,8 @@ impl IoStream for tokio_openssl::SslStream { } } -#[cfg(any(feature = "rust-tls"))] -impl IoStream for tokio_rustls::server::TlsStream { +#[cfg(feature = "rust-tls")] +impl IoStream for tokio_rustls::server::TlsStream { #[inline] fn peer_addr(&self) -> Option { self.get_ref().0.peer_addr() @@ -217,8 +223,8 @@ impl IoStream for tokio_rustls::server::TlsStream { } } -#[cfg(all(unix, feature = "uds"))] -impl IoStream for t::UnixStream { +#[cfg(unix)] +impl IoStream for tokio::net::UnixStream { #[inline] fn peer_addr(&self) -> Option { None