From af9255057330917e453e9f4ebebf35c516aaefcd Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 29 Nov 2021 23:56:46 +0000 Subject: [PATCH 1/7] prepare actix-tls release 3.0.0-rc.1 --- actix-tls/CHANGES.md | 36 +++++++++++++++++++++++++++++++++++- actix-tls/Cargo.toml | 4 ++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/actix-tls/CHANGES.md b/actix-tls/CHANGES.md index 78ba36659a..8ab9a71114 100644 --- a/actix-tls/CHANGES.md +++ b/actix-tls/CHANGES.md @@ -1,6 +1,39 @@ # Changes ## Unreleased - 2021-xx-xx + + +## 3.0.0-rc.1 - 2021-11-29 +### Added +* Derive `Debug` for `connect::Connection`. [#422] +* Implement `Display` for `accept::TlsError`. [#422] +* Implement `Error` for `accept::TlsError` where both types also implement `Error`. [#422] +* Implement `Default` for `connect::Resolver`. [#422] +* Implement `Error` for `connect::ConnectError`. [#422] + +### Changed +* The crate's default features flags no longer include `uri`. [#422] +* Useful re-exports from underlying TLS crates are exposed in a `reexports` modules in all acceptors and connectors. +* Convert `connect::ResolverService` from enum to struct. [#422] +* Make `ConnectAddrsIter` private. [#422] +* Rename `accept::native_tls::{NativeTlsAcceptorService => AcceptorService}`. [#422] +* Rename `connect::{Address => Host}` trait. [#422] +* Rename method `connect::Connection::{host => hostname}`. [#422] +* Rename struct `connect::{Connect => ConnectInfo}`. [#422] +* Rename struct `connect::{ConnectService => ConnectorService}`. [#422] +* Rename struct `connect::{ConnectServiceFactory => Connector}`. [#422] +* Rename TLS acceptor service future types and hide from docs. [#422] +* Unbox some service futures types. [#422] +* Inline modules in `connect::tls` to `connect` module. [#422] + +### Removed +* Remove `connect::{new_connector, new_connector_factory, default_connector, default_connector_factory}` methods. [#422] +* Remove `connect::native_tls::Connector::service` method. [#422] +* Remove redundant `connect::Connection::from_parts` method. [#422] + +[#422]: https://github.com/actix/actix-net/pull/422 + + ### Added * Derive `Debug` for `connect::Connection`. [#422] * Implement `Display` for `accept::TlsError`. [#422] @@ -9,7 +42,7 @@ * Implement `Error` for `connect::ConnectError`. [#422] ### Changed -* There are now no default features. [#422] +* The crate's default features flags no longer include `uri`. [#422] * Useful re-exports from underlying TLS crates are exposed in a `reexports` modules in all acceptors and connectors. * Convert `connect::ResolverService` from enum to struct. [#422] * Make `ConnectAddrsIter` private. [#422] @@ -21,6 +54,7 @@ * Rename struct `connect::{ConnectServiceFactory => Connector}`. [#422] * Rename TLS acceptor service future types and hide from docs. [#422] * Unbox some service futures types. [#422] +* Inline modules in `connect::tls` to `connect` module. [#422] ### Removed * Remove `connect::{new_connector, new_connector_factory, default_connector, default_connector_factory}` methods. [#422] diff --git a/actix-tls/Cargo.toml b/actix-tls/Cargo.toml index 29feff73c4..a340488462 100755 --- a/actix-tls/Cargo.toml +++ b/actix-tls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-tls" -version = "3.0.0-beta.9" +version = "3.0.0-rc.1" authors = [ "Nikolay Kim ", "Rob Ede ", @@ -21,7 +21,7 @@ name = "actix_tls" path = "src/lib.rs" [features] -default = [] +default = ["accept", "connect"] # enable acceptor services accept = [] From 4b35c052ef07b8fef857dac5f7d150b8ec7eac43 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 30 Nov 2021 00:26:42 +0000 Subject: [PATCH 2/7] tweak re-exports --- actix-tls/src/accept/native_tls.rs | 2 +- actix-tls/src/accept/openssl.rs | 2 +- actix-tls/src/accept/rustls.rs | 2 +- actix-tls/src/connect/native_tls.rs | 10 ++++++---- actix-tls/src/connect/openssl.rs | 6 ++++-- actix-tls/src/connect/rustls.rs | 4 +++- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/actix-tls/src/accept/native_tls.rs b/actix-tls/src/accept/native_tls.rs index 534dc58d3b..9a864a7258 100644 --- a/actix-tls/src/accept/native_tls.rs +++ b/actix-tls/src/accept/native_tls.rs @@ -93,7 +93,7 @@ pub struct Acceptor { } impl Acceptor { - /// Constructs `native-tls` based `Acceptor` service factory. + /// Constructs `native-tls` based acceptor service factory. pub fn new(acceptor: TlsAcceptor) -> Self { Acceptor { acceptor, diff --git a/actix-tls/src/accept/openssl.rs b/actix-tls/src/accept/openssl.rs index a91000ccc3..51a45942d6 100644 --- a/actix-tls/src/accept/openssl.rs +++ b/actix-tls/src/accept/openssl.rs @@ -96,7 +96,7 @@ pub struct Acceptor { } impl Acceptor { - /// Create OpenSSL based `Acceptor` service factory. + /// Create `openssl` based acceptor service factory. #[inline] pub fn new(acceptor: SslAcceptor) -> Self { Acceptor { diff --git a/actix-tls/src/accept/rustls.rs b/actix-tls/src/accept/rustls.rs index b6f3a8fe42..4eca996e11 100644 --- a/actix-tls/src/accept/rustls.rs +++ b/actix-tls/src/accept/rustls.rs @@ -96,7 +96,7 @@ pub struct Acceptor { } impl Acceptor { - /// Constructs Rustls based acceptor service factory. + /// Constructs `rustls` based acceptor service factory. pub fn new(config: ServerConfig) -> Self { Acceptor { config: Arc::new(config), diff --git a/actix-tls/src/connect/native_tls.rs b/actix-tls/src/connect/native_tls.rs index eba89cb263..97d027f526 100644 --- a/actix-tls/src/connect/native_tls.rs +++ b/actix-tls/src/connect/native_tls.rs @@ -10,22 +10,24 @@ use actix_utils::future::{ok, Ready}; use futures_core::future::LocalBoxFuture; use log::trace; use tokio_native_tls::{ - native_tls::TlsConnector as NativeTlsConnector, TlsConnector as TokioNativeTlsConnector, + native_tls::TlsConnector as NativeTlsConnector, TlsConnector as AsyncNativeTlsConnector, TlsStream, }; use crate::connect::{Connection, Host}; pub mod reexports { - //! Re-exports from `native-tls` that are useful for connectors. + //! Re-exports from `native-tls` and `tokio-native-tls` that are useful for connectors. pub use tokio_native_tls::native_tls::TlsConnector; + + pub use tokio_native_tls::TlsStream as AsyncTlsStream; } /// Connector service and factory using `native-tls`. #[derive(Clone)] pub struct TlsConnector { - connector: TokioNativeTlsConnector, + connector: AsyncNativeTlsConnector, } impl TlsConnector { @@ -34,7 +36,7 @@ impl TlsConnector { /// This type is it's own service factory, so it can be used in that setting, too. pub fn new(connector: NativeTlsConnector) -> Self { Self { - connector: TokioNativeTlsConnector::from(connector), + connector: AsyncNativeTlsConnector::from(connector), } } } diff --git a/actix-tls/src/connect/openssl.rs b/actix-tls/src/connect/openssl.rs index 3db37284ec..f4d2cf8cfc 100644 --- a/actix-tls/src/connect/openssl.rs +++ b/actix-tls/src/connect/openssl.rs @@ -20,9 +20,11 @@ use tokio_openssl::SslStream; use crate::connect::{Connection, Host}; pub mod reexports { - //! Re-exports from `openssl` that are useful for connectors. + //! Re-exports from `openssl` and `tokio-openssl` that are useful for connectors. - pub use openssl::ssl::{Error as SslError, HandshakeError, SslConnector, SslMethod}; + pub use openssl::ssl::{Error, HandshakeError, SslConnector, SslMethod, SslStream}; + + pub use tokio_openssl::SslStream as AsyncSslStream; } /// Connector service factory using `openssl`. diff --git a/actix-tls/src/connect/rustls.rs b/actix-tls/src/connect/rustls.rs index a98ae04ee6..86d1b5b4d5 100644 --- a/actix-tls/src/connect/rustls.rs +++ b/actix-tls/src/connect/rustls.rs @@ -26,7 +26,9 @@ use crate::connect::{Connection, Host}; pub mod reexports { //! Re-exports from `rustls` and `webpki_roots` that are useful for connectors. - pub use tokio_rustls::{client::TlsStream, rustls::ClientConfig}; + pub use tokio_rustls::rustls::ClientConfig; + + pub use tokio_rustls::client::TlsStream as AsyncTlsStream; pub use webpki_roots::TLS_SERVER_ROOTS; } From bd5d971dde1bbdd8454e6d8975612b3da474a3a7 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 30 Nov 2021 00:57:06 +0000 Subject: [PATCH 3/7] re-export async tls streams with async prefix --- actix-tls/src/connect/native_tls.rs | 6 +++--- actix-tls/src/connect/openssl.rs | 12 ++++++------ actix-tls/src/connect/rustls.rs | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/actix-tls/src/connect/native_tls.rs b/actix-tls/src/connect/native_tls.rs index 97d027f526..49222228e5 100644 --- a/actix-tls/src/connect/native_tls.rs +++ b/actix-tls/src/connect/native_tls.rs @@ -11,7 +11,7 @@ use futures_core::future::LocalBoxFuture; use log::trace; use tokio_native_tls::{ native_tls::TlsConnector as NativeTlsConnector, TlsConnector as AsyncNativeTlsConnector, - TlsStream, + TlsStream as AsyncTlsStream, }; use crate::connect::{Connection, Host}; @@ -45,7 +45,7 @@ impl ServiceFactory> for TlsConnector where IO: ActixStream + 'static, { - type Response = Connection>; + type Response = Connection>; type Error = io::Error; type Config = (); type Service = Self; @@ -64,7 +64,7 @@ where R: Host, IO: ActixStream + 'static, { - type Response = Connection>; + type Response = Connection>; type Error = io::Error; type Future = LocalBoxFuture<'static, Result>; diff --git a/actix-tls/src/connect/openssl.rs b/actix-tls/src/connect/openssl.rs index f4d2cf8cfc..a672d34edd 100644 --- a/actix-tls/src/connect/openssl.rs +++ b/actix-tls/src/connect/openssl.rs @@ -15,7 +15,7 @@ use actix_utils::future::{ok, Ready}; use futures_core::ready; use log::trace; use openssl::ssl::SslConnector; -use tokio_openssl::SslStream; +use tokio_openssl::SslStream as AsyncSslStream; use crate::connect::{Connection, Host}; @@ -57,7 +57,7 @@ where R: Host, IO: ActixStream + 'static, { - type Response = Connection>; + type Response = Connection>; type Error = io::Error; type Config = (); type Service = TlsConnectorService; @@ -89,7 +89,7 @@ where R: Host, IO: ActixStream, { - type Response = Connection>; + type Response = Connection>; type Error = io::Error; type Future = ConnectFut; @@ -110,7 +110,7 @@ where .expect("SSL connect configuration was invalid."); ConnectFut { - io: Some(SslStream::new(ssl, io).unwrap()), + io: Some(AsyncSslStream::new(ssl, io).unwrap()), stream: Some(stream), } } @@ -119,7 +119,7 @@ where /// Connect future for OpenSSL service. #[doc(hidden)] pub struct ConnectFut { - io: Option>, + io: Option>, stream: Option>, } @@ -128,7 +128,7 @@ where R: Host, IO: ActixStream, { - type Output = Result>, io::Error>; + type Output = Result>, io::Error>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.get_mut(); diff --git a/actix-tls/src/connect/rustls.rs b/actix-tls/src/connect/rustls.rs index 86d1b5b4d5..641ddd2314 100644 --- a/actix-tls/src/connect/rustls.rs +++ b/actix-tls/src/connect/rustls.rs @@ -17,7 +17,7 @@ use actix_utils::future::{ok, Ready}; use futures_core::ready; use log::trace; use tokio_rustls::rustls::{client::ServerName, OwnedTrustAnchor, RootCertStore}; -use tokio_rustls::{client::TlsStream, rustls::ClientConfig}; +use tokio_rustls::{client::TlsStream as AsyncTlsStream, rustls::ClientConfig}; use tokio_rustls::{Connect as RustlsConnect, TlsConnector as RustlsTlsConnector}; use webpki_roots::TLS_SERVER_ROOTS; @@ -71,7 +71,7 @@ where R: Host, IO: ActixStream + 'static, { - type Response = Connection>; + type Response = Connection>; type Error = io::Error; type Config = (); type Service = TlsConnectorService; @@ -96,7 +96,7 @@ where R: Host, IO: ActixStream, { - type Response = Connection>; + type Response = Connection>; type Error = io::Error; type Future = ConnectFut; @@ -132,7 +132,7 @@ where R: Host, IO: ActixStream, { - type Output = Result>, io::Error>; + type Output = Result>, io::Error>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { match self.get_mut() { From e530225520e1232b68bc841b11902ad589cfb831 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 30 Nov 2021 01:07:40 +0000 Subject: [PATCH 4/7] internal docs --- actix-tls/src/connect/connector.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/actix-tls/src/connect/connector.rs b/actix-tls/src/connect/connector.rs index f571766147..bde9a23ac6 100644 --- a/actix-tls/src/connect/connector.rs +++ b/actix-tls/src/connect/connector.rs @@ -78,14 +78,14 @@ impl Service> for ConnectorService { } } -/// Helper enum to generic over futures of resolve and connect steps. +/// Chains futures of resolve and connect steps. pub(crate) enum ConnectFut { Resolve(>>::Future), Connect(>>::Future), } -/// Helper enum to contain the future output of `ConnectFuture`. -pub(crate) enum ConnectOutput { +/// Container for the intermediate states of [`ConnectFut`]. +pub(crate) enum ConnectFutState { Resolved(ConnectInfo), Connected(Connection), } @@ -94,13 +94,14 @@ impl ConnectFut { fn poll_connect( &mut self, cx: &mut Context<'_>, - ) -> Poll, ConnectError>> { + ) -> Poll, ConnectError>> { match self { ConnectFut::Resolve(ref mut fut) => { - Pin::new(fut).poll(cx).map_ok(ConnectOutput::Resolved) + Pin::new(fut).poll(cx).map_ok(ConnectFutState::Resolved) } + ConnectFut::Connect(ref mut fut) => { - Pin::new(fut).poll(cx).map_ok(ConnectOutput::Connected) + Pin::new(fut).poll(cx).map_ok(ConnectFutState::Connected) } } } @@ -117,10 +118,10 @@ impl Future for ConnectServiceResponse { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { loop { match ready!(self.fut.poll_connect(cx))? { - ConnectOutput::Resolved(res) => { + ConnectFutState::Resolved(res) => { self.fut = ConnectFut::Connect(self.tcp.call(res)); } - ConnectOutput::Connected(res) => return Poll::Ready(Ok(res)), + ConnectFutState::Connected(res) => return Poll::Ready(Ok(res)), } } } From c8c7358a08791c51d6370c4bb20194e789210297 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 30 Nov 2021 01:16:15 +0000 Subject: [PATCH 5/7] impl default for tcp connector service --- actix-tls/CHANGES.md | 3 +++ actix-tls/src/connect/connector.rs | 2 +- actix-tls/src/connect/tcp.rs | 8 +++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/actix-tls/CHANGES.md b/actix-tls/CHANGES.md index 8ab9a71114..e0035f375a 100644 --- a/actix-tls/CHANGES.md +++ b/actix-tls/CHANGES.md @@ -10,12 +10,14 @@ * Implement `Error` for `accept::TlsError` where both types also implement `Error`. [#422] * Implement `Default` for `connect::Resolver`. [#422] * Implement `Error` for `connect::ConnectError`. [#422] +* Implement `Default` for `tcp::{TcpConnector, TcpConnectorService}`. [#423] ### Changed * The crate's default features flags no longer include `uri`. [#422] * Useful re-exports from underlying TLS crates are exposed in a `reexports` modules in all acceptors and connectors. * Convert `connect::ResolverService` from enum to struct. [#422] * Make `ConnectAddrsIter` private. [#422] +* Mark `tcp::{TcpConnector, TcpConnectorService}` structs `#[non_exhaustive]`. [#423] * Rename `accept::native_tls::{NativeTlsAcceptorService => AcceptorService}`. [#422] * Rename `connect::{Address => Host}` trait. [#422] * Rename method `connect::Connection::{host => hostname}`. [#422] @@ -32,6 +34,7 @@ * Remove redundant `connect::Connection::from_parts` method. [#422] [#422]: https://github.com/actix/actix-net/pull/422 +[#423]: https://github.com/actix/actix-net/pull/423 ### Added diff --git a/actix-tls/src/connect/connector.rs b/actix-tls/src/connect/connector.rs index bde9a23ac6..94d72fe845 100644 --- a/actix-tls/src/connect/connector.rs +++ b/actix-tls/src/connect/connector.rs @@ -34,7 +34,7 @@ impl Connector { /// Build connector service. pub fn service(&self) -> ConnectorService { ConnectorService { - tcp: TcpConnector.service(), + tcp: TcpConnector::default().service(), resolver: self.resolver.service(), } } diff --git a/actix-tls/src/connect/tcp.rs b/actix-tls/src/connect/tcp.rs index 8f566da741..f8f0d3becb 100644 --- a/actix-tls/src/connect/tcp.rs +++ b/actix-tls/src/connect/tcp.rs @@ -21,13 +21,14 @@ use tokio_util::sync::ReusableBoxFuture; use super::{connect_addrs::ConnectAddrs, error::ConnectError, ConnectInfo, Connection, Host}; /// TCP connector service factory. -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Clone, Copy, Default)] +#[non_exhaustive] pub struct TcpConnector; impl TcpConnector { /// Returns a new TCP connector service. pub fn service(&self) -> TcpConnectorService { - TcpConnectorService + TcpConnectorService::default() } } @@ -45,7 +46,8 @@ impl ServiceFactory> for TcpConnector { } /// TCP connector service. -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, Default)] +#[non_exhaustive] pub struct TcpConnectorService; impl Service> for TcpConnectorService { From 2e48bedd0d030bbecdf2ccc5570ddfa6d075bbae Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 30 Nov 2021 01:20:06 +0000 Subject: [PATCH 6/7] impl default for connector service --- actix-tls/CHANGES.md | 3 ++- actix-tls/src/connect/connector.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/actix-tls/CHANGES.md b/actix-tls/CHANGES.md index e0035f375a..709dfcc6a0 100644 --- a/actix-tls/CHANGES.md +++ b/actix-tls/CHANGES.md @@ -10,7 +10,8 @@ * Implement `Error` for `accept::TlsError` where both types also implement `Error`. [#422] * Implement `Default` for `connect::Resolver`. [#422] * Implement `Error` for `connect::ConnectError`. [#422] -* Implement `Default` for `tcp::{TcpConnector, TcpConnectorService}`. [#423] +* Implement `Default` for `connect::tcp::{TcpConnector, TcpConnectorService}`. [#423] +* Implement `Default` for `connect::ConnectorService`. [#423] ### Changed * The crate's default features flags no longer include `uri`. [#422] diff --git a/actix-tls/src/connect/connector.rs b/actix-tls/src/connect/connector.rs index 94d72fe845..a4276548d1 100644 --- a/actix-tls/src/connect/connector.rs +++ b/actix-tls/src/connect/connector.rs @@ -57,7 +57,7 @@ impl ServiceFactory> for Connector { /// /// Service implementation receives connection information, resolves DNS if required, and returns /// a TCP stream. -#[derive(Clone)] +#[derive(Clone, Default)] pub struct ConnectorService { tcp: TcpConnectorService, resolver: ResolverService, From 99511b74d1f1bb3ef7b479fa07499f70f51b7962 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 30 Nov 2021 01:39:08 +0000 Subject: [PATCH 7/7] do not re-export non-async ssl stream --- actix-tls/src/connect/openssl.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actix-tls/src/connect/openssl.rs b/actix-tls/src/connect/openssl.rs index a672d34edd..3c0b10a008 100644 --- a/actix-tls/src/connect/openssl.rs +++ b/actix-tls/src/connect/openssl.rs @@ -22,7 +22,7 @@ use crate::connect::{Connection, Host}; pub mod reexports { //! Re-exports from `openssl` and `tokio-openssl` that are useful for connectors. - pub use openssl::ssl::{Error, HandshakeError, SslConnector, SslMethod, SslStream}; + pub use openssl::ssl::{Error, HandshakeError, SslConnector, SslMethod}; pub use tokio_openssl::SslStream as AsyncSslStream; }