Skip to content

Commit

Permalink
sip-core: fix breaking rustls update
Browse files Browse the repository at this point in the history
  • Loading branch information
kbalt committed Jun 24, 2024
1 parent de616e9 commit 54323c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions crates/sip-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ trust-dns-resolver = "0.23"
multimap = "0.10"
nom = "7"

tokio-rustls = { version = "0.26", optional = true }
tokio-rustls = { version = "0.26", optional = true, default-features = false }
rustls-pki-types = { version = "1", features = ["std"], optional = true }
tokio-native-tls = { version = "0.3", optional = true }


[features]
tls-rustls = ["dep:tokio-rustls"]
tls-rustls = ["dep:tokio-rustls", "dep:rustls-pki-types"]
tls-native-tls = ["dep:tokio-native-tls"]
9 changes: 5 additions & 4 deletions crates/sip-core/src/transport/rustls.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::streaming::{
StreamingFactory, StreamingListener, StreamingListenerBuilder, StreamingTransport,
};
use rustls_pki_types::{IpAddr, ServerName};
use sip_types::{host::Host, uri::UriInfo};
use std::convert::TryFrom;
use std::io;
use std::net::SocketAddr;
use tokio::net::{TcpListener, TcpStream, ToSocketAddrs};
use tokio_rustls::rustls::ServerName;
use tokio_rustls::{TlsAcceptor, TlsConnector, TlsStream};

// ==== Connector
Expand All @@ -22,9 +22,10 @@ impl StreamingFactory for TlsConnector {
) -> io::Result<Self::Transport> {
let server_name = match uri_info.host_port.host {
Host::Name(ref name) => ServerName::try_from(name.as_str())
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?,
Host::IP4(ip) => ServerName::IpAddress(ip.into()),
Host::IP6(ip) => ServerName::IpAddress(ip.into()),
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?
.to_owned(),
Host::IP4(ip) => ServerName::IpAddress(IpAddr::V4(ip.into())),
Host::IP6(ip) => ServerName::IpAddress(IpAddr::V6(ip.into())),
};

let stream = TcpStream::connect(addr).await?;
Expand Down

0 comments on commit 54323c8

Please sign in to comment.