From 375597ad904e1772a2c7b1179996db8c61fa921d Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 29 Nov 2021 21:40:38 +0000 Subject: [PATCH] internal rename --- actix-tls/src/connect/connect_addrs.rs | 6 +++--- actix-tls/src/connect/info.rs | 4 ++-- actix-tls/src/connect/resolver.rs | 17 ++++++++++------- actix-tls/src/connect/tcp.rs | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/actix-tls/src/connect/connect_addrs.rs b/actix-tls/src/connect/connect_addrs.rs index 6d27e3cc..13e4c4fa 100644 --- a/actix-tls/src/connect/connect_addrs.rs +++ b/actix-tls/src/connect/connect_addrs.rs @@ -13,12 +13,12 @@ pub(crate) enum ConnectAddrs { } impl ConnectAddrs { - pub(crate) fn is_none(&self) -> bool { + pub(crate) fn is_unresolved(&self) -> bool { matches!(self, Self::None) } - pub(crate) fn is_some(&self) -> bool { - !self.is_none() + pub(crate) fn is_resolved(&self) -> bool { + !self.is_unresolved() } } diff --git a/actix-tls/src/connect/info.rs b/actix-tls/src/connect/info.rs index ef283660..7bd1e5f3 100644 --- a/actix-tls/src/connect/info.rs +++ b/actix-tls/src/connect/info.rs @@ -80,8 +80,8 @@ impl ConnectInfo { /// Set local address to connection with. /// - /// Useful in situations where you know the IP address bound to a particular network interface - /// and want to make sure the socket is opened through that interface. + /// Useful in situations where the IP address bound to a particular network interface is known. + /// This would make sure the socket is opened through that interface. pub fn set_local_addr(mut self, addr: impl Into) -> Self { self.local_addr = Some(addr.into()); self diff --git a/actix-tls/src/connect/resolver.rs b/actix-tls/src/connect/resolver.rs index 7b6f14af..8e700deb 100644 --- a/actix-tls/src/connect/resolver.rs +++ b/actix-tls/src/connect/resolver.rs @@ -101,12 +101,14 @@ impl Service> for ResolverService { actix_service::always_ready!(); fn call(&self, req: ConnectInfo) -> Self::Future { - if req.addr.is_some() { - ResolverFut::Connected(Some(req)) + if req.addr.is_resolved() { + // socket address(es) already resolved; return existing connection request + ResolverFut::Resolved(Some(req)) } else if let Ok(ip) = req.hostname().parse() { + // request hostname is valid ip address; add address to request and return let addr = SocketAddr::new(ip, req.port()); let req = req.set_addr(Some(addr)); - ResolverFut::Connected(Some(req)) + ResolverFut::Resolved(Some(req)) } else { trace!("DNS resolver: resolving host {:?}", req.hostname()); @@ -127,7 +129,7 @@ impl Service> for ResolverService { let req = req.set_addrs(addrs); - if req.addr.is_none() { + if req.addr.is_unresolved() { Err(ConnectError::NoRecords) } else { Ok(req) @@ -140,8 +142,9 @@ impl Service> for ResolverService { } /// Future for resolver service. +#[doc(hidden)] pub enum ResolverFut { - Connected(Option>), + Resolved(Option>), LookUp( JoinHandle>>, Option>, @@ -154,7 +157,7 @@ impl Future for ResolverFut { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { match self.get_mut() { - Self::Connected(conn) => Poll::Ready(Ok(conn + Self::Resolved(conn) => Poll::Ready(Ok(conn .take() .expect("ResolverFuture polled after finished"))), @@ -185,7 +188,7 @@ impl Future for ResolverFut { req.addrs() ); - if req.addr.is_none() { + if req.addr.is_unresolved() { Poll::Ready(Err(ConnectError::NoRecords)) } else { Poll::Ready(Ok(req)) diff --git a/actix-tls/src/connect/tcp.rs b/actix-tls/src/connect/tcp.rs index a2a9fb94..8f566da7 100644 --- a/actix-tls/src/connect/tcp.rs +++ b/actix-tls/src/connect/tcp.rs @@ -90,7 +90,7 @@ impl TcpConnectorFut { local_addr: Option, addr: ConnectAddrs, ) -> TcpConnectorFut { - if addr.is_none() { + if addr.is_unresolved() { error!("TCP connector: unresolved connection address"); return TcpConnectorFut::Error(Some(ConnectError::Unresolved)); }