Skip to content

Commit c535724

Browse files
authored
Fix binding interface when no TLS is used (#2200)
1 parent d5adcba commit c535724

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/async_impl/client.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,6 @@ impl ClientBuilder {
468468
config.quic_receive_window,
469469
config.quic_send_window,
470470
config.local_address,
471-
#[cfg(any(
472-
target_os = "android",
473-
target_os = "fuchsia",
474-
target_os = "linux"
475-
))]
476-
config.interface.as_deref(),
477471
&config.http_version_pref,
478472
)?;
479473
}
@@ -639,7 +633,14 @@ impl ClientBuilder {
639633
}
640634

641635
#[cfg(not(feature = "__tls"))]
642-
Connector::new(http, proxies.clone(), config.local_address, config.nodelay)
636+
Connector::new(
637+
http,
638+
proxies.clone(),
639+
config.local_address,
640+
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
641+
config.interface.as_deref(),
642+
config.nodelay,
643+
)
643644
};
644645

645646
connector.set_timeout(config.connect_timeout);

src/connect.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,18 @@ impl Connector {
6363
mut http: HttpConnector,
6464
proxies: Arc<Vec<Proxy>>,
6565
local_addr: T,
66+
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
67+
interface: Option<&str>,
6668
nodelay: bool,
6769
) -> Connector
6870
where
6971
T: Into<Option<IpAddr>>,
7072
{
7173
http.set_local_address(local_addr.into());
74+
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
75+
if let Some(interface) = interface {
76+
http.set_interface(interface.to_owned());
77+
}
7278
http.set_nodelay(nodelay);
7379

7480
Connector {

0 commit comments

Comments
 (0)