diff --git a/core/Cargo.toml b/core/Cargo.toml index 5151607b489..92b4115b08a 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -47,7 +47,7 @@ rust-version = "1.75" version = "0.50.1" [features] -default = ["reqwest/rustls-tls", "executors-tokio", "services-memory" ,"services-memcached"] +default = ["reqwest/rustls-tls", "executors-tokio", "services-memory"] # Build test utils or not. # diff --git a/core/src/services/memcached/backend.rs b/core/src/services/memcached/backend.rs index a21b198aa0e..250c2a282f1 100644 --- a/core/src/services/memcached/backend.rs +++ b/core/src/services/memcached/backend.rs @@ -190,7 +190,6 @@ impl Builder for MemcachedBuilder { cafile: self.config.cafile.clone(), tls_key: self.config.tls_key.clone(), tls_cert: self.config.tls_cert.clone(), - host, conn, default_ttl: self.config.default_ttl, }) @@ -211,7 +210,6 @@ pub struct Adapter { cafile: Option, tls_key: Option, tls_cert: Option, - host: String, conn: OnceCell>, } @@ -228,7 +226,6 @@ impl Adapter { self.cafile.clone(), self.tls_key.clone(), self.tls_cert.clone(), - &self.host, ); bb8::Pool::builder().build(mgr).await.map_err(|err| { @@ -301,7 +298,6 @@ struct MemcacheConnectionManager { cafile: Option, tls_key: Option, tls_cert: Option, - host: String, } impl MemcacheConnectionManager { @@ -313,7 +309,6 @@ impl MemcacheConnectionManager { cafile: Option, tls_key: Option, tls_cert: Option, - host: &str, ) -> Self { Self { address: address.to_string(), @@ -323,7 +318,6 @@ impl MemcacheConnectionManager { cafile, tls_key, tls_cert, - host: host.to_string(), } } } @@ -340,7 +334,7 @@ impl bb8::ManageConnection for MemcacheConnectionManager { let native_certs = rustls_native_certs::load_native_certs(); if native_certs.errors.is_empty() { - for cert in rustls_native_certs::load_native_certs().expect("unreachable") { + for cert in rustls_native_certs::load_native_certs().expect("unreachable!") { root_cert_store.add(cert).map_err(|err| { Error::new(ErrorKind::Unexpected, "tls connect failed").set_source(err) })?; @@ -385,11 +379,15 @@ impl bb8::ManageConnection for MemcacheConnectionManager { .with_root_certificates(root_cert_store) .with_no_client_auth() }; + let connector = TlsConnector::from(Arc::new(config)); let conn = TcpStream::connect(&self.address) .await .map_err(new_std_io_error)?; - let domain = ServerName::try_from(self.host.as_str()) + + let uri = http::Uri::try_from(&self.address).expect("unreachable!"); + let host = uri.host().expect("unreachable!"); + let domain = ServerName::try_from(host) .map_err(|err| { Error::new(ErrorKind::ConfigInvalid, "Invalid dns name error") .with_context("service", Scheme::Memcached)