Skip to content

Commit

Permalink
fixup! Fix negotiation of ephemeral peer failing due to timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Sep 17, 2024
1 parent eb7c67d commit 390a550
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions talpid-wireguard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ async fn maybe_create_obfuscator(

impl WireguardMonitor {
/// Starts a WireGuard tunnel with the given config
/// TODO: Remove any android-specific parts.
#[cfg(not(target_os = "android"))]
pub fn start<
F: (Fn(TunnelEvent) -> Pin<Box<dyn std::future::Future<Output = ()> + Send>>)
Expand Down Expand Up @@ -296,24 +295,13 @@ impl WireguardMonitor {
log_path,
args.resource_dir,
args.tun_provider.clone(),
#[cfg(target_os = "android")]
config.quantum_resistant,
#[cfg(target_os = "windows")]
args.route_manager.clone(),
#[cfg(target_os = "windows")]
setup_done_tx,
)?;
let iface_name = tunnel.get_interface_name();

#[cfg(target_os = "android")]
if let Some(remote_socket_fd) = obfuscator.as_ref().map(|obfs| obfs.remote_socket_fd()) {
// Exclude remote obfuscation socket or bridge
log::debug!("Excluding remote socket fd from the tunnel");
if let Err(error) = args.tun_provider.lock().unwrap().bypass(remote_socket_fd) {
log::error!("Failed to exclude remote socket fd: {error}");
}
}

let obfuscator = Arc::new(AsyncMutex::new(obfuscator));

let event_callback = Box::new(on_event.clone());
Expand Down Expand Up @@ -378,8 +366,6 @@ impl WireguardMonitor {
args.retry_attempt,
obfuscator.clone(),
ephemeral_obfs_sender,
#[cfg(target_os = "android")]
args.tun_provider,
)
.await?;

Expand All @@ -391,7 +377,6 @@ impl WireguardMonitor {
.await;
}

#[cfg(not(target_os = "android"))]
if detect_mtu {
let config = config.clone();
let iface_name = iface_name.clone();
Expand Down Expand Up @@ -422,6 +407,7 @@ impl WireguardMonitor {
};
});
}

let mut connectivity_monitor = tokio::task::spawn_blocking(move || {
match connectivity_monitor.establish_connectivity(args.retry_attempt) {
Ok(true) => Ok(connectivity_monitor),
Expand Down

0 comments on commit 390a550

Please sign in to comment.