Re-enable IPv6 dual stack tests on unix
use std::convert::TryInto;
use std::io;
-use std::net::Ipv4Addr;
use std::time::Duration;
use super::*;
@@ -41,23 +40,28 @@ const TIMEOUT: Duration = Duration::from_secs(60);
#[tokio::test]
async fn test_udp_mux() -> Result<()> {
- // use std::io::Write;
- // env_logger::Builder::from_default_env()
- // .format(|buf, record| {
- // writeln!(
- // buf,
- // "{}:{} [{}] {} - {}",
- // record.file().unwrap_or("unknown"),
- // record.line().unwrap_or(0),
- // record.level(),
- // chrono::Local::now().format("%H:%M:%S.%6f"),
- // record.args()
- // )
- // })
- // .init();
+ use std::io::Write;
+ env_logger::Builder::from_default_env()
+ .format(|buf, record| {
+ writeln!(
+ buf,
+ "{}:{} [{}] {} - {}",
+ record.file().unwrap_or("unknown"),
+ record.line().unwrap_or(0),
+ record.level(),
+ chrono::Local::now().format("%H:%M:%S.%6f"),
+ record.args()
+ )
+ })
+ .init();
// TODO: Support IPv6 dual stack. This works Linux and macOS, but not Windows.
- let udp_socket = UdpSocket::bind((Ipv4Addr::UNSPECIFIED, 0)).await?;
+ #[cfg(all(unix, target_pointer_width = "64"))]
+ let udp_socket = UdpSocket::bind((std::net::Ipv6Addr::UNSPECIFIED, 0)).await?;
+
+ #[cfg(any(not(unix), not(target_pointer_width = "64")))]
+ let udp_socket = UdpSocket::bind((std::net::Ipv4Addr::UNSPECIFIED, 0)).await?;
+
let addr = udp_socket.local_addr()?;
log::info!("Listening on {}", addr);
@@ -87,17 +91,17 @@ async fn test_udp_mux() -> Result<()> {
#[cfg(all(unix, target_pointer_width = "64"))]
{
// TODO: Support IPv6 dual stack. This works Linux and macOS, but not Windows.
- // let udp_mux_dyn_3 = Arc::clone(&udp_mux_dyn);
- // let h3 = tokio::spawn(async move {
- // timeout(
- // TIMEOUT,
- // test_mux_connection(Arc::clone(&udp_mux_dyn_3), "ufrag3", addr, Network::Ipv6),
- // )
- // .await
- // });
+ let udp_mux_dyn_3 = Arc::clone(&udp_mux_dyn);
+ let h3 = tokio::spawn(async move {
+ timeout(
+ TIMEOUT,
+ test_mux_connection(Arc::clone(&udp_mux_dyn_3), "ufrag3", addr, Network::Ipv6),
+ )
+ .await
+ });
- let (r1, r2) = tokio::join!(h1, h2);
- all_results = [r1, r2];
+ let (r1, r2, r3) = tokio::join!(h1, h2, h3);
+ all_results = [r1, r2, r3];
}
#[cfg(any(not(unix), not(target_pointer_width = "64")))]
