Skip to content

Commit 44df93f

Browse files
committed
On http3, bind ipv6 for ipv6
1 parent dfe01a1 commit 44df93f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/client_h3.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ impl Client {
8787
url: &Url,
8888
) -> Result<Stream, ClientError> {
8989
let endpoint_config = h3_quinn::quinn::EndpointConfig::default();
90-
let local_socket = UdpSocket::bind("0.0.0.0:0").expect("couldn't bind to address");
90+
let local_socket = if addr.0.is_ipv6() {
91+
UdpSocket::bind("[::]:0").expect("couldn't bind to address")
92+
} else {
93+
UdpSocket::bind("0.0.0.0:0").expect("couldn't bind to address")
94+
};
9195
// If we can set the right build flags, we can use `h3_quinn::quinn::Endpoint::client` instead
9296
let mut client_endpoint = h3_quinn::quinn::Endpoint::new(
9397
endpoint_config,
@@ -106,11 +110,14 @@ impl Client {
106110

107111
let remote_socket_address = SocketAddr::new(addr.0, addr.1);
108112
let server_name = url.host_str().ok_or(ClientError::HostNotFound)?;
113+
dbg!(&remote_socket_address);
114+
dbg!(&server_name);
109115
let conn = client_endpoint
110116
.connect(remote_socket_address, server_name)
111117
.map_err(Http3Error::from)?
112118
.await
113119
.map_err(Http3Error::from)?;
120+
dbg!("here");
114121
Ok(Stream::Quic(conn))
115122
}
116123

0 commit comments

Comments
 (0)