Skip to content

Commit

Permalink
Fix missing socket_bypass_tx value for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Sep 22, 2023
1 parent 3684550 commit 200ad79
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions mullvad-api/src/https_client_with_sni.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,38 @@ impl InnerConnectionMode {
&self,
hostname: &str,
addr: &SocketAddr,
#[cfg(target_os = "android")] socket_bypass_tx: Option<mpsc::Sender<SocketBypassRequest>>,
) -> Result<ApiConnection, std::io::Error> {
use InnerConnectionMode::*;
match self {
Direct => Self::handle_direct_connection(addr, hostname).await,
Direct => {
Self::handle_direct_connection(
addr,
hostname,
#[cfg(target_os = "android")]
socket_bypass_tx,
)
.await
}
Shadowsocks(config) => {
Self::handle_shadowsocks_connection(config.clone(), addr, hostname).await
Self::handle_shadowsocks_connection(
config.clone(),
addr,
hostname,
#[cfg(target_os = "android")]
socket_bypass_tx,
)
.await
}
Socks5(proxy_config) => {
Self::handle_socks_connection(proxy_config.clone(), addr, hostname).await
Self::handle_socks_connection(
proxy_config.clone(),
addr,
hostname,
#[cfg(target_os = "android")]
socket_bypass_tx,
)
.await
}
}
}
Expand All @@ -101,11 +124,12 @@ impl InnerConnectionMode {
async fn handle_direct_connection(
addr: &SocketAddr,
hostname: &str,
#[cfg(target_os = "android")] socket_bypass_tx: Option<mpsc::Sender<SocketBypassRequest>>,
) -> Result<ApiConnection, io::Error> {
let socket = HttpsConnectorWithSni::open_socket(
*addr,
#[cfg(target_os = "android")]
socket_bypass_tx.clone(),
socket_bypass_tx,
)
.await?;
#[cfg(feature = "api-override")]
Expand All @@ -122,11 +146,12 @@ impl InnerConnectionMode {
shadowsocks: ShadowsocksConfig,
addr: &SocketAddr,
hostname: &str,
#[cfg(target_os = "android")] socket_bypass_tx: Option<mpsc::Sender<SocketBypassRequest>>,
) -> Result<ApiConnection, io::Error> {
let socket = HttpsConnectorWithSni::open_socket(
shadowsocks.params.peer,
#[cfg(target_os = "android")]
socket_bypass_tx.clone(),
socket_bypass_tx,
)
.await?;
let proxy = ProxyClientStream::from_stream(
Expand All @@ -150,6 +175,7 @@ impl InnerConnectionMode {
proxy_config: SocksConfig,
addr: &SocketAddr,
hostname: &str,
#[cfg(target_os = "android")] socket_bypass_tx: Option<mpsc::Sender<SocketBypassRequest>>,
) -> Result<ApiConnection, io::Error> {
let socket = HttpsConnectorWithSni::open_socket(
proxy_config.peer,
Expand Down Expand Up @@ -424,7 +450,12 @@ impl Service<Uri> for HttpsConnectorWithSni {
let stream = loop {
let notify = abort_notify.notified();
let proxy_config = { inner.lock().unwrap().proxy_config.clone() };
let stream_fut = proxy_config.connect(&hostname, &addr);
let stream_fut = proxy_config.connect(
&hostname,
&addr,
#[cfg(target_os = "android")]
socket_bypass_tx.clone(),
);

pin_mut!(stream_fut);
pin_mut!(notify);
Expand Down

0 comments on commit 200ad79

Please sign in to comment.