Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit f910c04

Browse files
mahkohjbg
authored andcommitted
Add support for UDS connections
1 parent a841a3e commit f910c04

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/lib.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,17 @@ where
3737

3838
fn make_tls_connect(&mut self, hostname: &str) -> io::Result<RustlsConnect> {
3939
DNSNameRef::try_from_ascii_str(hostname)
40-
.map(|dns_name| RustlsConnect {
40+
.map(|dns_name| RustlsConnect(Some(RustlsConnectData {
4141
hostname: dns_name.to_owned(),
4242
connector: Arc::clone(&self.config).into(),
43-
})
44-
.map_err(|_| io::ErrorKind::InvalidInput.into())
43+
})))
44+
.or(Ok(RustlsConnect(None)))
4545
}
4646
}
4747

48-
pub struct RustlsConnect {
48+
pub struct RustlsConnect(Option<RustlsConnectData>);
49+
50+
struct RustlsConnectData {
4951
hostname: DNSName,
5052
connector: TlsConnector,
5153
}
@@ -59,10 +61,13 @@ where
5961
type Future = Pin<Box<dyn Future<Output = io::Result<RustlsStream<S>>> + Send>>;
6062

6163
fn connect(self, stream: S) -> Self::Future {
62-
self.connector
63-
.connect(self.hostname.as_ref(), stream)
64-
.map_ok(|s| RustlsStream(Box::pin(s)))
65-
.boxed()
64+
match self.0 {
65+
None => Box::pin(core::future::ready(Err(io::ErrorKind::InvalidInput.into()))),
66+
Some(c) => c.connector
67+
.connect(c.hostname.as_ref(), stream)
68+
.map_ok(|s| RustlsStream(Box::pin(s)))
69+
.boxed()
70+
}
6671
}
6772
}
6873

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy