@@ -3,6 +3,8 @@ XXXX-YY-ZZ RELEASER <admin@example.com>
* Breaking:
- Remove `tokio_xmpp::ParseError` and `tokio_xmpp::starttls::ParseError` which were never used
- Removed StreamFeatures from this crate, replaced with xmpp_parsers::stream_features::StreamFeatures (!400)
+ - `starttls::error::ConnectorError` variants have been merged with `starttls::error::Error`, except `ConnectorError::AllFailed`
+ which was not used and has been completely removed (!418)
Version 4.0.0:
2024-07-26 Maxime “pep” Buquet <pep@bouah.net>
@@ -13,8 +13,10 @@ use tokio_rustls::rustls::Error as TlsError;
/// StartTLS ServerConnector Error
#[derive(Debug)]
pub enum Error {
- /// Error resolving DNS and establishing a connection
- Connection(ConnectorError),
+ /// DNS protocol error
+ Dns(ProtoError),
+ /// DNS resolution error
+ Resolve(ResolveError),
/// DNS label conversion error, no details available from module
/// `idna`
Idna,
@@ -30,7 +32,8 @@ pub enum Error {
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match self {
- Error::Connection(e) => write!(fmt, "connection error: {}", e),
+ Error::Dns(e) => write!(fmt, "{:?}", e),
+ Error::Resolve(e) => write!(fmt, "{:?}", e),
Error::Idna => write!(fmt, "IDNA error"),
Error::Tls(e) => write!(fmt, "TLS error: {}", e),
#[cfg(all(feature = "tls-rust", not(feature = "tls-native")))]
@@ -48,12 +51,6 @@ impl From<crate::error::Error> for Error {
}
}
-impl From<ConnectorError> for Error {
- fn from(e: ConnectorError) -> Self {
- Error::Connection(e)
- }
-}
-
impl From<TlsError> for Error {
fn from(e: TlsError) -> Self {
Error::Tls(e)
@@ -66,22 +63,3 @@ impl From<InvalidDnsNameError> for Error {
Error::DnsNameError(e)
}
}
-
-/// Error establishing connection
-#[derive(Debug)]
-pub enum ConnectorError {
- /// All attempts failed, no error available
- AllFailed,
- /// DNS protocol error
- Dns(ProtoError),
- /// DNS resolution error
- Resolve(ResolveError),
-}
-
-impl StdError for ConnectorError {}
-
-impl std::fmt::Display for ConnectorError {
- fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
- write!(fmt, "{:?}", self)
- }
-}
@@ -1,4 +1,4 @@
-use super::error::{ConnectorError, Error};
+use super::error::Error;
use futures::{future::select_ok, FutureExt};
use hickory_resolver::{
config::LookupIpStrategy, name_server::TokioConnectionProvider, IntoName, TokioAsyncResolver,
@@ -17,14 +17,14 @@ pub async fn connect_to_host(domain: &str, port: u16) -> Result<TcpStream, Error
}
let (config, mut options) =
- hickory_resolver::system_conf::read_system_conf().map_err(ConnectorError::Resolve)?;
+ hickory_resolver::system_conf::read_system_conf().map_err(Error::Resolve)?;
options.ip_strategy = LookupIpStrategy::Ipv4AndIpv6;
let resolver = TokioAsyncResolver::new(config, options, TokioConnectionProvider::default());
let ips = resolver
.lookup_ip(ascii_domain)
.await
- .map_err(ConnectorError::Resolve)?;
+ .map_err(Error::Resolve)?;
// Happy Eyeballs: connect to all records in parallel, return the
// first to succeed
select_ok(
@@ -50,11 +50,11 @@ pub async fn connect_with_srv(
.map_err(|e| Error::from(crate::Error::Io(e)))?);
}
- let resolver = TokioAsyncResolver::tokio_from_system_conf().map_err(ConnectorError::Resolve)?;
+ let resolver = TokioAsyncResolver::tokio_from_system_conf().map_err(Error::Resolve)?;
let srv_domain = format!("{}.{}.", srv, ascii_domain)
.into_name()
- .map_err(ConnectorError::Dns)?;
+ .map_err(Error::Dns)?;
let srv_records = resolver.srv_lookup(srv_domain.clone()).await.ok();
match srv_records {