Skip to content

Commit

Permalink
Fix binding interface when no TLS is used (#2200)
Browse files Browse the repository at this point in the history
  • Loading branch information
yujincheng08 authored Mar 22, 2024
1 parent d5adcba commit c535724
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/async_impl/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,6 @@ impl ClientBuilder {
config.quic_receive_window,
config.quic_send_window,
config.local_address,
#[cfg(any(
target_os = "android",
target_os = "fuchsia",
target_os = "linux"
))]
config.interface.as_deref(),
&config.http_version_pref,
)?;
}
Expand Down Expand Up @@ -639,7 +633,14 @@ impl ClientBuilder {
}

#[cfg(not(feature = "__tls"))]
Connector::new(http, proxies.clone(), config.local_address, config.nodelay)
Connector::new(
http,
proxies.clone(),
config.local_address,
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
config.interface.as_deref(),
config.nodelay,
)
};

connector.set_timeout(config.connect_timeout);
Expand Down
6 changes: 6 additions & 0 deletions src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,18 @@ impl Connector {
mut http: HttpConnector,
proxies: Arc<Vec<Proxy>>,
local_addr: T,
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
interface: Option<&str>,
nodelay: bool,
) -> Connector
where
T: Into<Option<IpAddr>>,
{
http.set_local_address(local_addr.into());
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
if let Some(interface) = interface {
http.set_interface(interface.to_owned());
}
http.set_nodelay(nodelay);

Connector {
Expand Down

0 comments on commit c535724

Please sign in to comment.