Skip to content

Commit

Permalink
join dns with another instance of WS transport
Browse files Browse the repository at this point in the history
Secure Websocket transport needs unresolved addresses, so we join DNS transport with
yet another instance of Websocket transport.

Closes paritytech#12024
  • Loading branch information
melekes committed Jan 13, 2023
1 parent 2bfc1dd commit ae133bb
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions client/network/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit ae133bb

Please sign in to comment.