From ae133bb803b8bf852b90bcafb9f88e1ff2718df3 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Fri, 13 Jan 2023 15:14:25 +0700 Subject: [PATCH] join dns with another instance of WS transport Secure Websocket transport needs unresolved addresses, so we join DNS transport with yet another instance of Websocket transport. Closes #12024 --- client/network/src/transport.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/client/network/src/transport.rs b/client/network/src/transport.rs index 6c792a0c38042..f64d313016dc4 100644 --- a/client/network/src/transport.rs +++ b/client/network/src/transport.rs @@ -55,17 +55,20 @@ pub fn build_transport( // Build the base layer of the transport. let transport = if !memory_only { let tcp_config = tcp::Config::new().nodelay(true); - let desktop_trans = tcp::tokio::Transport::new(tcp_config.clone()); - let desktop_trans = websocket::WsConfig::new(desktop_trans) + let tcp_trans = tcp::tokio::Transport::new(tcp_config.clone()); + let desktop_trans = websocket::WsConfig::new(tcp_trans) .or_transport(tcp::tokio::Transport::new(tcp_config.clone())); let dns_init = dns::TokioDnsConfig::system(desktop_trans); EitherTransport::Left(if let Ok(dns) = dns_init { - EitherTransport::Left(dns) + // Secure Websocket transport needs unresolved addresses, so we join DNS transport with + // yet another instance of Websocket transport. + let tcp_trans = tcp::tokio::Transport::new(tcp_config.clone()); + EitherTransport::Left(dns.or_transport(websocket::WsConfig::new(tcp_trans))) } else { - let desktop_trans = tcp::tokio::Transport::new(tcp_config.clone()); - let desktop_trans = websocket::WsConfig::new(desktop_trans) + let tcp_trans = tcp::tokio::Transport::new(tcp_config.clone()); + let desktop_trans = websocket::WsConfig::new(tcp_trans) .or_transport(tcp::tokio::Transport::new(tcp_config)); - EitherTransport::Right(desktop_trans.map_err(dns::DnsErr::Transport)) + EitherTransport::Right(desktop_trans) }) } else { EitherTransport::Right(OptionalTransport::some(