Skip to content

Commit

Permalink
Merge pull request #280 from mjquigley/support-ipv6
Browse files Browse the repository at this point in the history
Support IPv6 URIs with rustls
  • Loading branch information
daniel-abramov committed May 7, 2023
2 parents d6f5d45 + e2e8b94 commit e5e8421
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ where
#[inline]
fn domain(request: &tungstenite::handshake::client::Request) -> Result<String, WsError> {
match request.uri().host() {
// rustls expects IPv6 addresses without the surrounding [] brackets
#[cfg(feature = "__rustls-tls")]
Some(d) if d.starts_with('[') && d.ends_with(']') => Ok(d[1..d.len() - 1].to_string()),
Some(d) => Ok(d.to_string()),
None => Err(WsError::Url(tungstenite::error::UrlError::NoHostName)),
}
Expand Down

0 comments on commit e5e8421

Please sign in to comment.