1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-08-15 21:33:54 +02:00

Compare commits

..

2 Commits

Author SHA1 Message Date
Rob Ede
54d1d9e520 prepare actix-tls release 3.0.0-beta.8 2021-11-15 17:55:23 +00:00
Alexander Polakov
0b0cbd5388 actix-tls: allow getting uri from Connect (#415)
Co-authored-by: Rob Ede <robjtede@icloud.com>
2021-11-15 10:39:42 +00:00
3 changed files with 26 additions and 9 deletions

View File

@@ -3,6 +3,12 @@
## Unreleased - 2021-xx-xx
## 3.0.0-beta.8 - 2021-11-15
* Add `Connect::request` for getting a reference to the connection request. [#415]
[#415]: https://github.com/actix/actix-net/pull/415
## 3.0.0-beta.7 - 2021-10-20
* Add `webpki_roots_cert_store()` to get rustls compatible webpki roots cert store. [#401]
* Alias `connect::ssl` to `connect::tls`. [#401]

View File

@@ -1,6 +1,6 @@
[package]
name = "actix-tls"
version = "3.0.0-beta.7"
version = "3.0.0-beta.8"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "TLS acceptor and connector services for Actix ecosystem"
keywords = ["network", "tls", "ssl", "async", "transport"]

View File

@@ -63,16 +63,16 @@ impl From<Option<SocketAddr>> for ConnectAddrs {
/// Connection info.
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct Connect<T> {
pub(crate) req: T,
pub struct Connect<R> {
pub(crate) req: R,
pub(crate) port: u16,
pub(crate) addr: ConnectAddrs,
pub(crate) local_addr: Option<IpAddr>,
}
impl<T: Address> Connect<T> {
impl<R: Address> Connect<R> {
/// Create `Connect` instance by splitting the string by ':' and convert the second part to u16
pub fn new(req: T) -> Connect<T> {
pub fn new(req: R) -> Connect<R> {
let (_, port) = parse_host(req.hostname());
Connect {
@@ -85,7 +85,7 @@ impl<T: Address> Connect<T> {
/// Create new `Connect` instance from host and address. Connector skips name resolution stage
/// for such connect messages.
pub fn with_addr(req: T, addr: SocketAddr) -> Connect<T> {
pub fn with_addr(req: R, addr: SocketAddr) -> Connect<R> {
Connect {
req,
port: 0,
@@ -155,15 +155,20 @@ impl<T: Address> Connect<T> {
ConnectAddrs::Multi(addrs) => ConnectAddrsIter::MultiOwned(addrs.into_iter()),
}
}
/// Returns a reference to the connection request.
pub fn request(&self) -> &R {
&self.req
}
}
impl<T: Address> From<T> for Connect<T> {
fn from(addr: T) -> Self {
impl<R: Address> From<R> for Connect<R> {
fn from(addr: R) -> Self {
Connect::new(addr)
}
}
impl<T: Address> fmt::Display for Connect<T> {
impl<R: Address> fmt::Display for Connect<R> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}:{}", self.hostname(), self.port())
}
@@ -347,4 +352,10 @@ mod tests {
IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1))
)
}
#[test]
fn request_ref() {
let conn = Connect::new("hello");
assert_eq!(conn.request(), &"hello")
}
}