Skip to content

Commit 3254984

Browse files
committed
Merge branch 'block-on-duct-tape' into prepare-2024.9
2 parents d00e3b2 + 222d4b9 commit 3254984

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ Line wrap the file at 100 chars. Th
4343
- Make Smart Routing override multihop if both are enabled. To manually set the entry relay,
4444
explicitly enable the "Direct only" option in the DAITA settings.
4545
- Update maybenot from 1.1.3 to 2.0.1.
46-
- Test tunnel before ephemeral peer exchange. This is an attempt to fix timeout issues.
4746

4847
#### Windows
4948
- Enable quantum-resistant tunnels by default (when set to `auto`).
49+
- Test tunnel before ephemeral peer exchange. This is an attempt to fix timeout issues.
5050

5151
### Fixed
5252
- Handle network switching better when using WG over Shadowsocks.

talpid-wireguard/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919
// This is useful after updating the WireGuard config, to force a WireGuard handshake. This
2020
// should reduce the number of PQ timeouts.
2121
println!("cargo::rustc-check-cfg=cfg(force_wireguard_handshake)");
22-
if matches!(target_os.as_str(), "linux" | "macos" | "windows") {
22+
if target_os.as_str() == "windows" {
2323
println!("cargo::rustc-cfg=force_wireguard_handshake");
2424
}
2525
}

talpid-wireguard/src/connectivity/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ mod mock;
66
mod monitor;
77
mod pinger;
88

9-
pub use check::{Cancellable, Check};
9+
#[cfg(any(target_os = "android", force_wireguard_handshake))]
10+
pub use check::Cancellable;
11+
pub use check::Check;
1012
pub use error::Error;
1113
pub use monitor::Monitor;

talpid-wireguard/src/ephemeral.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ async fn config_ephemeral_peers_inner(
120120
// NOTE: This one often fails with multihop on Windows, even though the handshake afterwards
121121
// succeeds. So we try anyway if it fails.
122122
#[cfg(force_wireguard_handshake)]
123-
let _ = establish_tunnel_connection(tunnel, connectivity).await;
123+
let _ = establish_tunnel_connection(tunnel, connectivity);
124124

125125
let ephemeral_private_key = PrivateKey::new_from_random();
126126
let close_obfs_sender = close_obfs_sender.clone();
@@ -158,7 +158,7 @@ async fn config_ephemeral_peers_inner(
158158
.await?;
159159

160160
#[cfg(force_wireguard_handshake)]
161-
establish_tunnel_connection(tunnel, connectivity).await?;
161+
establish_tunnel_connection(tunnel, connectivity)?;
162162

163163
let entry_psk = request_ephemeral_peer(
164164
retry_attempt,
@@ -279,16 +279,17 @@ async fn reconfigure_tunnel(
279279
/// Ensure that the WireGuard tunnel works. This is useful after updating the WireGuard config, to
280280
/// force a WireGuard handshake. This should reduce the number of PQ timeouts.
281281
#[cfg(force_wireguard_handshake)]
282-
async fn establish_tunnel_connection(
282+
fn establish_tunnel_connection(
283283
tunnel: &Arc<AsyncMutex<Option<TunnelType>>>,
284284
connectivity: &mut connectivity::Check<connectivity::Cancellable>,
285285
) -> Result<(), CloseMsg> {
286286
use talpid_types::ErrorExt;
287287

288-
let shared_tunnel = tunnel.lock().await;
289-
let tunnel = shared_tunnel.as_ref().expect("tunnel was None");
290-
let ping_result = connectivity.establish_connectivity(tunnel);
291-
drop(shared_tunnel);
288+
let ping_result = tokio::task::block_in_place(|| {
289+
let shared_tunnel = tunnel.blocking_lock();
290+
let tunnel = shared_tunnel.as_ref().expect("tunnel was None");
291+
connectivity.establish_connectivity(tunnel)
292+
});
292293

293294
match ping_result {
294295
Ok(true) => Ok(()),

0 commit comments

Comments
 (0)