Skip to content

Commit 951d12b

Browse files
Revert force_wireguard_handshake because it was broken
1 parent fed889e commit 951d12b

File tree

5 files changed

+4
-77
lines changed

5 files changed

+4
-77
lines changed

CHANGELOG.md

-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ Line wrap the file at 100 chars. Th
3030
- (Linux and macOS only) Update to DAITA v2. The main difference is that many different machines are
3131
provided by relays instead of a bundled list. The bundled `maybenot_machines` file was removed.
3232

33-
#### Windows
34-
- Test tunnel before ephemeral peer exchange. This is an attempt to fix timeout issues.
35-
3633
### Fixed
3734
#### macOS
3835
- Fix GUI getting stuck when opening the split tunneling view.

talpid-wireguard/build.rs

-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ fn main() {
1414
// Enable DAITA by default on desktop and android
1515
println!("cargo::rustc-check-cfg=cfg(daita)");
1616
println!("cargo::rustc-cfg=daita");
17-
18-
// Ensure that the WireGuard tunnel works before exchanging ephemeral peers.
19-
// This is useful after updating the WireGuard config, to force a WireGuard handshake. This
20-
// should reduce the number of PQ timeouts.
21-
println!("cargo::rustc-check-cfg=cfg(force_wireguard_handshake)");
22-
if target_os.as_str() == "windows" {
23-
println!("cargo::rustc-cfg=force_wireguard_handshake");
24-
}
2517
}
2618

2719
fn declare_libs_dir(base: &str) {

talpid-wireguard/src/connectivity/mod.rs

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

9-
#[cfg(any(target_os = "android", force_wireguard_handshake))]
9+
#[cfg(target_os = "android")]
1010
pub use check::Cancellable;
1111
pub use check::Check;
1212
pub use error::Error;

talpid-wireguard/src/ephemeral.rs

+3-63
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//! This module takes care of obtaining ephemeral peers, updating the WireGuard configuration and
22
//! restarting obfuscation and WG tunnels when necessary.
33
4-
#[cfg(force_wireguard_handshake)]
5-
use super::connectivity;
64
#[cfg(target_os = "android")] // On Android, the Tunnel trait is not imported by default.
75
use super::Tunnel;
86
use super::{config::Config, obfuscation::ObfuscatorHandle, CloseMsg, Error, TunnelType};
@@ -33,9 +31,6 @@ pub async fn config_ephemeral_peers(
3331
retry_attempt: u32,
3432
obfuscator: Arc<AsyncMutex<Option<ObfuscatorHandle>>>,
3533
close_obfs_sender: sync_mpsc::Sender<CloseMsg>,
36-
#[cfg(force_wireguard_handshake)] connectivity: &mut connectivity::Check<
37-
connectivity::Cancellable,
38-
>,
3934
) -> std::result::Result<(), CloseMsg> {
4035
let iface_name = {
4136
let tunnel = tunnel.lock().await;
@@ -49,16 +44,8 @@ pub async fn config_ephemeral_peers(
4944
log::trace!("Temporarily lowering tunnel MTU before ephemeral peer config");
5045
try_set_ipv4_mtu(&iface_name, talpid_tunnel::MIN_IPV4_MTU);
5146

52-
config_ephemeral_peers_inner(
53-
tunnel,
54-
config,
55-
retry_attempt,
56-
obfuscator,
57-
close_obfs_sender,
58-
#[cfg(force_wireguard_handshake)]
59-
connectivity,
60-
)
61-
.await?;
47+
config_ephemeral_peers_inner(tunnel, config, retry_attempt, obfuscator, close_obfs_sender)
48+
.await?;
6249

6350
log::trace!("Resetting tunnel MTU");
6451
try_set_ipv4_mtu(&iface_name, config.mtu);
@@ -88,9 +75,6 @@ pub async fn config_ephemeral_peers(
8875
retry_attempt: u32,
8976
obfuscator: Arc<AsyncMutex<Option<ObfuscatorHandle>>>,
9077
close_obfs_sender: sync_mpsc::Sender<CloseMsg>,
91-
#[cfg(force_wireguard_handshake)] connectivity: &mut connectivity::Check<
92-
connectivity::Cancellable,
93-
>,
9478
#[cfg(target_os = "android")] tun_provider: Arc<Mutex<TunProvider>>,
9579
) -> Result<(), CloseMsg> {
9680
config_ephemeral_peers_inner(
@@ -99,8 +83,6 @@ pub async fn config_ephemeral_peers(
9983
retry_attempt,
10084
obfuscator,
10185
close_obfs_sender,
102-
#[cfg(force_wireguard_handshake)]
103-
connectivity,
10486
#[cfg(target_os = "android")]
10587
tun_provider,
10688
)
@@ -113,16 +95,8 @@ async fn config_ephemeral_peers_inner(
11395
retry_attempt: u32,
11496
obfuscator: Arc<AsyncMutex<Option<ObfuscatorHandle>>>,
11597
close_obfs_sender: sync_mpsc::Sender<CloseMsg>,
116-
#[cfg(force_wireguard_handshake)] connectivity: &mut connectivity::Check<
117-
connectivity::Cancellable,
118-
>,
11998
#[cfg(target_os = "android")] tun_provider: Arc<Mutex<TunProvider>>,
12099
) -> Result<(), CloseMsg> {
121-
// NOTE: This one often fails with multihop on Windows, even though the handshake afterwards
122-
// succeeds. So we try anyway if it fails.
123-
#[cfg(force_wireguard_handshake)]
124-
let _ = establish_tunnel_connection(tunnel, connectivity);
125-
126100
let ephemeral_private_key = PrivateKey::new_from_random();
127101
let close_obfs_sender = close_obfs_sender.clone();
128102

@@ -160,10 +134,6 @@ async fn config_ephemeral_peers_inner(
160134
&tun_provider,
161135
)
162136
.await?;
163-
164-
#[cfg(force_wireguard_handshake)]
165-
establish_tunnel_connection(tunnel, connectivity)?;
166-
167137
let entry_ephemeral_peer = request_ephemeral_peer(
168138
retry_attempt,
169139
&entry_config,
@@ -244,6 +214,7 @@ async fn reconfigure_tunnel(
244214
*obfs_guard = super::obfuscation::apply_obfuscation_config(
245215
&mut config,
246216
close_obfs_sender,
217+
#[cfg(target_os = "android")]
247218
tun_provider.clone(),
248219
)
249220
.await
@@ -297,37 +268,6 @@ async fn reconfigure_tunnel(
297268
Ok(config)
298269
}
299270

300-
/// Ensure that the WireGuard tunnel works. This is useful after updating the WireGuard config, to
301-
/// force a WireGuard handshake. This should reduce the number of PQ timeouts.
302-
#[cfg(force_wireguard_handshake)]
303-
fn establish_tunnel_connection(
304-
tunnel: &Arc<AsyncMutex<Option<TunnelType>>>,
305-
connectivity: &mut connectivity::Check<connectivity::Cancellable>,
306-
) -> Result<(), CloseMsg> {
307-
use talpid_types::ErrorExt;
308-
309-
let ping_result = tokio::task::block_in_place(|| {
310-
let shared_tunnel = tunnel.blocking_lock();
311-
let tunnel = shared_tunnel.as_ref().expect("tunnel was None");
312-
connectivity.establish_connectivity(tunnel)
313-
});
314-
315-
match ping_result {
316-
Ok(true) => Ok(()),
317-
Ok(false) => {
318-
log::warn!("Timeout while checking tunnel connection");
319-
Err(CloseMsg::PingErr)
320-
}
321-
Err(error) => {
322-
log::error!(
323-
"{}",
324-
error.display_chain_with_msg("Failed to check tunnel connection")
325-
);
326-
Err(CloseMsg::PingErr)
327-
}
328-
}
329-
}
330-
331271
async fn request_ephemeral_peer(
332272
retry_attempt: u32,
333273
config: &Config,

talpid-wireguard/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,6 @@ impl WireguardMonitor {
274274
args.retry_attempt,
275275
obfuscator.clone(),
276276
ephemeral_obfs_sender,
277-
#[cfg(force_wireguard_handshake)]
278-
&mut connectivity_monitor,
279277
)
280278
.await?;
281279

0 commit comments

Comments
 (0)