Skip to content

Commit b6c96e5

Browse files
yujincheng08Nutomic
authored andcommitted
Fix binding interface when no TLS is used (seanmonstar#2200)
1 parent 73a6513 commit b6c96e5

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
@@ -470,12 +470,6 @@ impl ClientBuilder {
470470
config.quic_receive_window,
471471
config.quic_send_window,
472472
config.local_address,
473-
#[cfg(any(
474-
target_os = "android",
475-
target_os = "fuchsia",
476-
target_os = "linux"
477-
))]
478-
config.interface.as_deref(),
479473
&config.http_version_pref,
480474
)?;
481475
}
@@ -641,7 +635,14 @@ impl ClientBuilder {
641635
}
642636

643637
#[cfg(not(feature = "__tls"))]
644-
Connector::new(http, proxies.clone(), config.local_address, config.nodelay)
638+
Connector::new(
639+
http,
640+
proxies.clone(),
641+
config.local_address,
642+
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
643+
config.interface.as_deref(),
644+
config.nodelay,
645+
)
645646
};
646647

647648
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)