diff options
| author | David Lönnhager <david.l@mullvad.net> | 2025-09-29 13:45:14 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2025-10-03 16:43:01 +0200 |
| commit | b597789d7cc9105189afebf937c03c400ade45d6 (patch) | |
| tree | 0339dcf056f71a1528daff850f2e1444f28a047f | |
| parent | 13f2bab900c5fce9594f5351dbf2207e04ba8070 (diff) | |
| download | mullvadvpn-b597789d7cc9105189afebf937c03c400ade45d6.tar.xz mullvadvpn-b597789d7cc9105189afebf937c03c400ade45d6.zip | |
Remove DAITA from wireguard-nt
| -rw-r--r-- | Cargo.lock | 2 | ||||
| -rw-r--r-- | talpid-wireguard/Cargo.toml | 4 | ||||
| -rw-r--r-- | talpid-wireguard/src/wireguard_nt/daita.rs | 478 | ||||
| -rw-r--r-- | talpid-wireguard/src/wireguard_nt/mod.rs | 169 |
4 files changed, 9 insertions, 644 deletions
diff --git a/Cargo.lock b/Cargo.lock index 03de3831a9..a634e91e39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5798,7 +5798,6 @@ dependencies = [ "ipnetwork", "libc", "log", - "maybenot", "netlink-packet-core", "netlink-packet-route", "netlink-proto", @@ -5806,7 +5805,6 @@ dependencies = [ "once_cell", "parking_lot", "proptest", - "rand 0.8.5", "rand 0.9.2", "rand_chacha 0.3.1", "rtnetlink", diff --git a/talpid-wireguard/Cargo.toml b/talpid-wireguard/Cargo.toml index 306c58e845..162bc7156e 100644 --- a/talpid-wireguard/Cargo.toml +++ b/talpid-wireguard/Cargo.toml @@ -66,10 +66,6 @@ talpid-dbus = { path = "../talpid-dbus" } bitflags = "1.2" talpid-windows = { path = "../talpid-windows" } widestring = "1.0" -maybenot = "2.0.0" -# TODO: rand 0.8 is a hard requirement of maybenot-ffi 2.0. May be upgraded to rand 0.9 -# when maybenot 2.2 is released. -rand08 = { package = "rand", version = "0.8.5" } rand_chacha = "0.3.1" # TODO: Figure out which features are needed and which are not diff --git a/talpid-wireguard/src/wireguard_nt/daita.rs b/talpid-wireguard/src/wireguard_nt/daita.rs deleted file mode 100644 index 98e60eff30..0000000000 --- a/talpid-wireguard/src/wireguard_nt/daita.rs +++ /dev/null @@ -1,478 +0,0 @@ -use super::WIREGUARD_KEY_LENGTH; -use maybenot::{MachineId, Timer}; -use once_cell::sync::OnceCell; -use rand08::{ - SeedableRng, - rngs::{OsRng, adapter::ReseedingRng}, -}; -use std::{ - collections::HashMap, fs, io, os::windows::io::AsRawHandle, os::windows::prelude::RawHandle, - path::Path, sync::Arc, time::Duration, -}; -use talpid_types::net::wireguard::PublicKey; -use tokio::task::JoinHandle; -use windows_sys::Win32::{ - Foundation::ERROR_NO_MORE_ITEMS, - System::Threading::{INFINITE, WaitForMultipleObjects, WaitForSingleObject}, -}; - -type Rng = ReseedingRng<rand_chacha::ChaCha12Core, OsRng>; -const RNG_RESEED_THRESHOLD: u64 = 1024 * 64; // 64 KiB - -#[derive(Debug, thiserror::Error)] -pub enum Error { - /// Failed to find maybenot machines - #[error("Failed to enumerate maybenot machines")] - EnumerateMachines(#[source] io::Error), - /// Failed to parse maybenot machine - #[error("Failed to parse maybenot machine \"{0}\"")] - InvalidMachine(String), - /// Failed to initialize quit event - #[error("Failed to initialize quit event")] - InitializeQuitEvent(#[source] io::Error), - /// Failed to initialize machinist handle - #[error("Failed to initialize machinist handle")] - InitializeHandle(#[source] io::Error), - /// Failed to initialize maybenot framework - #[error("Failed to initialize maybenot framework: {0}")] - InitializeMaybenot(String), -} - -// See DAITA_EVENT_TYPE: -// https://github.com/mullvad/wireguard-nt-priv/blob/mullvad-patches/driver/daita.h -#[repr(C)] -#[derive(Debug)] -#[allow(dead_code)] -pub enum EventType { - NonpaddingSent, - NonpaddingReceived, - PaddingSent, - PaddingReceived, -} - -// See DAITA_EVENT: -// https://github.com/mullvad/wireguard-nt-priv/blob/mullvad-patches/driver/daita.h -#[repr(C)] -#[derive(Debug)] -pub struct Event { - pub peer: [u8; WIREGUARD_KEY_LENGTH], - pub event_type: EventType, - pub xmit_bytes: u16, - pub user_context: usize, -} - -// See DAITA_ACTION_TYPE: -// https://github.com/mullvad/wireguard-nt-priv/blob/mullvad-patches/driver/daita.h -#[repr(C)] -pub enum ActionType { - InjectPadding, -} - -// See DAITA_PADDING_ACTION: -// https://github.com/mullvad/wireguard-nt-priv/blob/mullvad-patches/driver/daita.h -#[repr(C)] -#[derive(Debug, Clone, Copy)] -pub struct PaddingAction { - pub byte_count: u16, - pub replace: u8, -} - -// See DAITA_ACTION: -// https://github.com/mullvad/wireguard-nt-priv/blob/mullvad-patches/driver/daita.h -#[repr(C)] -pub struct Action { - pub peer: [u8; WIREGUARD_KEY_LENGTH], - pub action_type: ActionType, - pub payload: ActionPayload, - pub user_context: usize, -} - -#[repr(C)] -pub union ActionPayload { - pub padding: PaddingAction, -} - -/// Maximum number of events that can be stored in the underlying buffer -const EVENTS_CAPACITY: usize = 1000; -/// Maximum number of actions that can be stored in the underlying buffer -const ACTIONS_CAPACITY: usize = 1000; - -pub mod bindings { - use super::*; - pub type WireGuardDaitaActivateFn = unsafe extern "stdcall" fn( - adapter: RawHandle, - events_capacity: usize, - actions_capacity: usize, - ) -> bool; - pub type WireGuardDaitaEventDataAvailableEventFn = - unsafe extern "stdcall" fn(adapter: RawHandle) -> RawHandle; - pub type WireGuardDaitaReceiveEventsFn = - unsafe extern "stdcall" fn(adapter: RawHandle, events: *mut Event) -> usize; - pub type WireGuardDaitaSendActionFn = - unsafe extern "stdcall" fn(adapter: RawHandle, action: *const Action) -> bool; -} - -#[derive(Debug)] -pub struct Session { - adapter: Arc<super::WgNtAdapter>, -} - -impl Session { - /// Call `WireGuardDaitaActivate` for an existing WireGuard interface - pub(super) fn from_adapter(adapter: Arc<super::WgNtAdapter>) -> io::Result<Session> { - // SAFETY: `WgNtAdapter` has a valid adapter handle - unsafe { - adapter - .dll_handle - .daita_activate(adapter.handle, EVENTS_CAPACITY, ACTIONS_CAPACITY) - }?; - Ok(Self { adapter }) - } - - pub fn receive_events<'a>( - &self, - buffer: &'a mut [Event; EVENTS_CAPACITY], - ) -> io::Result<&'a [Event]> { - let num_events = unsafe { - // SAFETY: The adapter is valid, and the buffer is large enough to accommodate all - // events. - self.adapter - .dll_handle - .daita_receive_events(self.adapter.handle, buffer.as_mut_ptr())? - }; - Ok(unsafe { std::slice::from_raw_parts(buffer.as_ptr(), num_events) }) - } - - pub fn send_action(&self, action: &Action) -> io::Result<()> { - // SAFETY: The adapter is valid - unsafe { - self.adapter - .dll_handle - .daita_send_action(self.adapter.handle, action) - } - } - - pub fn event_data_available_event(&self) -> RawHandle { - // SAFETY: The adapter is valid - // This never fails when there's a DAITA session - unsafe { - self.adapter - .dll_handle - .daita_event_data_available_event(self.adapter.handle) - .unwrap() - } - } -} - -fn maybenot_event_from_event( - event: &Event, - machine_ids: &MachineMap, -) -> Option<maybenot::TriggerEvent> { - match event.event_type { - EventType::PaddingReceived => Some(maybenot::TriggerEvent::PaddingRecv), - EventType::NonpaddingSent => Some(maybenot::TriggerEvent::NormalSent), - EventType::NonpaddingReceived => Some(maybenot::TriggerEvent::NormalRecv), - EventType::PaddingSent => Some(maybenot::TriggerEvent::PaddingSent { - machine: machine_ids.get_machine_id(event.user_context)?.to_owned(), - }), - } -} - -/// Handle for a set of DAITA machines. -/// Note: `close` is NOT called implicitly when this is dropped. -pub struct MachinistHandle { - quit_event: talpid_windows::sync::Event, -} - -impl MachinistHandle { - fn new(quit_event: &talpid_windows::sync::Event) -> io::Result<MachinistHandle> { - Ok(MachinistHandle { - quit_event: quit_event.duplicate()?, - }) - } - - /// Signal quit event - pub fn close(&self) -> io::Result<()> { - self.quit_event.set() - } -} - -pub struct Machinist { - daita: Arc<Session>, - machine_ids: MachineMap, - machine_tasks: HashMap<usize, JoinHandle<()>>, - tokio_handle: tokio::runtime::Handle, - quit_event: talpid_windows::sync::Event, - peer: PublicKey, - mtu: u16, -} - -// TODO: This is silly. Let me use the raw ID of MachineId, please. -struct MachineMap { - id_to_num: HashMap<MachineId, usize>, - num_to_id: HashMap<usize, MachineId>, -} - -impl MachineMap { - fn new() -> Self { - Self { - id_to_num: HashMap::new(), - num_to_id: HashMap::new(), - } - } - - fn get_or_create_raw_id(&mut self, machine_id: MachineId) -> usize { - *self.id_to_num.entry(machine_id).or_insert_with(|| { - let raw_id = self.num_to_id.len(); - self.num_to_id.insert(raw_id, machine_id); - raw_id - }) - } - - fn get_machine_id(&self, raw_id: usize) -> Option<&MachineId> { - self.num_to_id.get(&raw_id) - } -} - -impl Machinist { - /// Spawn an actor that handles scheduling of Maybenot actions and forwards DAITA events to the - /// framework. - pub fn spawn( - resource_dir: &Path, - daita: Session, - peer: PublicKey, - mtu: u16, - ) -> std::result::Result<MachinistHandle, Error> { - const MAX_PADDING_BYTES: f64 = 0.0; - const MAX_BLOCKING_BYTES: f64 = 0.0; - - static MAYBENOT_MACHINES: OnceCell<Vec<maybenot::Machine>> = OnceCell::new(); - - let machines = - MAYBENOT_MACHINES.get_or_try_init(|| load_maybenot_machines(resource_dir))?; - - let quit_event = - talpid_windows::sync::Event::new(true, false).map_err(Error::InitializeQuitEvent)?; - let handle = MachinistHandle::new(&quit_event).map_err(Error::InitializeHandle)?; - - let framework = maybenot::Framework::new( - machines.clone(), - MAX_PADDING_BYTES, - MAX_BLOCKING_BYTES, - std::time::Instant::now(), - Rng::new( - rand_chacha::ChaCha12Core::from_entropy(), - RNG_RESEED_THRESHOLD, - OsRng, - ), - ) - .map_err(|error| Error::InitializeMaybenot(error.to_string()))?; - - let daita = Arc::new(daita); - let tokio_handle = tokio::runtime::Handle::current(); - - std::thread::spawn(move || { - Self { - daita, - machine_ids: MachineMap::new(), - machine_tasks: HashMap::new(), - tokio_handle, - quit_event, - peer, - mtu, - } - .event_loop(framework); - }); - - Ok(handle) - } - - fn event_loop(mut self, mut framework: maybenot::Framework<Vec<maybenot::Machine>, Rng>) { - use windows_sys::Win32::Foundation::WAIT_OBJECT_0; - - loop { - if unsafe { WaitForSingleObject(self.quit_event.as_raw_handle(), 0) } == WAIT_OBJECT_0 { - break; - } - - let events = match self.wait_for_events() { - Ok(events) => { - if events.is_empty() { - break; - } - events - } - Err(error) => { - log::error!("Error while waiting for DAITA events: {error}"); - break; - } - }; - - for action in framework.trigger_events(&events, std::time::Instant::now()) { - self.handle_action(action); - } - } - - log::debug!("Stopped DAITA event loop"); - } - - fn handle_action(&mut self, action: &maybenot::action::TriggerAction) { - match *action { - maybenot::action::TriggerAction::Cancel { machine, timer } => { - debug_assert_ne!(timer, Timer::Internal, "machine timers not implemented"); - - let raw_id = self.machine_ids.get_or_create_raw_id(machine); - - // Drop all scheduled actions for a given machine - if let Some(task) = self.machine_tasks.get_mut(&raw_id) { - task.abort(); - } - } - maybenot::action::TriggerAction::SendPadding { - timeout, - machine, - replace, - .. - } => { - let peer = self.peer.clone(); - - let raw_id = self.machine_ids.get_or_create_raw_id(machine); - self.machine_tasks.entry(raw_id).and_modify(|f| f.abort()); - - let action = Action { - peer: *peer.as_bytes(), - action_type: ActionType::InjectPadding, - user_context: raw_id, - payload: ActionPayload { - padding: PaddingAction { - byte_count: self.mtu, - replace: if replace { 1 } else { 0 }, - }, - }, - }; - - if timeout == Duration::ZERO { - if let Err(error) = self.daita.send_action(&action) { - log::error!("Failed to send DAITA action: {error}"); - } - } else { - // Schedule action on the tokio runtime - let daita = Arc::downgrade(&self.daita); - let task = self.tokio_handle.spawn(async move { - tokio::time::sleep(timeout).await; - - let Some(daita) = daita.upgrade() else { return }; - - if let Err(error) = daita.send_action(&action) { - log::error!("Failed to send DAITA action: {error}"); - } - }); - self.machine_tasks.insert(raw_id, task); - } - } - maybenot::action::TriggerAction::BlockOutgoing { .. } => { - if cfg!(debug_assertions) { - unimplemented!("received BlockOutgoing action"); - } - } - maybenot::action::TriggerAction::UpdateTimer { .. } => { - if cfg!(debug_assertions) { - unimplemented!("received UpdateTimer action"); - } - } - } - } - - /// Take all events from the ring buffer while there are any left. - /// If there are no events available, wait for events to arrive. - /// Otherwise, break and return a non-zero number of events to be processed. - /// If the quit event was signaled, this returns an empty vector. - fn wait_for_events(&mut self) -> io::Result<Vec<maybenot::TriggerEvent>> { - use windows_sys::Win32::Foundation::WAIT_OBJECT_0; - - let wait_events = [ - self.quit_event.as_raw_handle(), - self.daita.event_data_available_event(), - ]; - - let mut event_buffer: [Event; EVENTS_CAPACITY] = unsafe { std::mem::zeroed() }; - - loop { - match self.daita.receive_events(&mut event_buffer) { - Ok(events) => { - let converted_events: Vec<_> = events - .iter() - .filter(|event| &event.peer == self.peer.as_bytes()) - .filter_map(|event| maybenot_event_from_event(event, &self.machine_ids)) - .collect(); - if !converted_events.is_empty() { - return Ok(converted_events); - } - // Try again if we only received events for irrelevant peers - } - Err(error) => { - if error.raw_os_error() == Some(ERROR_NO_MORE_ITEMS as i32) { - let wait_result = unsafe { - WaitForMultipleObjects( - u32::try_from(wait_events.len()).unwrap(), - wait_events.as_ptr(), - 0, - INFINITE, - ) - }; - - if wait_result == WAIT_OBJECT_0 { - // Quit event signaled - break Ok(vec![]); - } - if wait_result == WAIT_OBJECT_0 + 1 { - // Event object signaled -- try to receive more events - continue; - } - } - break Err(std::io::Error::last_os_error()); - } - } - } - } -} - -fn load_maybenot_machines(resource_dir: &Path) -> Result<Vec<maybenot::Machine>, Error> { - let path = resource_dir.join("maybenot_machines"); - log::debug!("Reading maybenot machines from {}", path.display()); - - let mut machines = vec![]; - let machines_str = fs::read_to_string(path).map_err(Error::EnumerateMachines)?; - for machine_str in machines_str.lines() { - let machine_str = machine_str.trim(); - if matches!(machine_str.chars().next(), None | Some('#')) { - continue; - } - log::debug!("Adding maybenot machine: {machine_str}"); - machines.push( - machine_str - .parse::<maybenot::Machine>() - .map_err(|_error| Error::InvalidMachine(machine_str.to_owned()))?, - ); - } - Ok(machines) -} - -#[cfg(test)] -mod test { - use super::load_maybenot_machines; - use std::path::PathBuf; - - /// Test whether `maybenot_machines` in dist-assets contains valid machines. - /// TODO: Remove when switching to dynamic machines. - #[test] - fn test_load_maybenot_machines() { - let dist_assets = std::env::var("CARGO_MANIFEST_DIR") - .map(PathBuf::from) - .expect("CARGO_MANIFEST_DIR env var not set") - .join("..") - .join("dist-assets"); - - load_maybenot_machines(&dist_assets).unwrap(); - } -} diff --git a/talpid-wireguard/src/wireguard_nt/mod.rs b/talpid-wireguard/src/wireguard_nt/mod.rs index c51faf6d93..a1472bb2ff 100644 --- a/talpid-wireguard/src/wireguard_nt/mod.rs +++ b/talpid-wireguard/src/wireguard_nt/mod.rs @@ -1,5 +1,7 @@ #![allow(clippy::undocumented_unsafe_blocks)] // Remove me if you dare. +use crate::TunnelError; + use super::{ Tunnel, config::Config, @@ -11,7 +13,7 @@ use futures::SinkExt; use ipnetwork::IpNetwork; use once_cell::sync::OnceCell; use std::{ - ffi::CStr, + ffi::{CStr, c_uchar}, fmt, future::Future, io, @@ -24,8 +26,7 @@ use std::{ sync::{Arc, LazyLock, Mutex}, time::{Duration, SystemTime, UNIX_EPOCH}, }; -#[cfg(daita)] -use std::{ffi::c_uchar, path::PathBuf}; +use talpid_tunnel_config_client::DaitaSettings; use talpid_types::{BoxedError, ErrorExt}; use talpid_windows::net; use widestring::{U16CStr, U16CString}; @@ -41,9 +42,6 @@ use windows_sys::{ core::GUID, }; -#[cfg(daita)] -mod daita; - static WG_NT_DLL: OnceCell<WgNtDll> = OnceCell::new(); static ADAPTER_TYPE: LazyLock<U16CString> = LazyLock::new(|| U16CString::from_str("Mullvad").unwrap()); @@ -165,27 +163,13 @@ pub enum Error { /// Failed to parse data returned by the driver #[error("Failed to parse data returned by wireguard-nt")] InvalidConfigData, - - /// DAITA machinist failed - #[cfg(daita)] - #[error("Failed to enable DAITA on tunnel device")] - EnableTunnelDaita(#[source] io::Error), - - /// DAITA machinist failed - #[cfg(daita)] - #[error("Failed to initialize DAITA machinist")] - InitializeMachinist(#[source] daita::Error), } pub struct WgNtTunnel { - #[cfg(daita)] - resource_dir: PathBuf, config: Arc<Mutex<Config>>, device: Option<Arc<WgNtAdapter>>, interface_name: String, setup_handle: tokio::task::JoinHandle<()>, - #[cfg(daita)] - daita_handle: Option<daita::MachinistHandle>, _logger_handle: LoggerHandle, } @@ -326,8 +310,6 @@ bitflags! { const REPLACE_ALLOWED_IPS = 0b00100000; const REMOVE = 0b01000000; const UPDATE = 0b10000000; - #[cfg(daita)] - const HAS_CONSTANT_PACKET_SIZE = 0b100000000; } } @@ -345,7 +327,6 @@ struct WgPeer { rx_bytes: u64, last_handshake: u64, allowed_ips_count: u32, - #[cfg(daita)] constant_packet_size: c_uchar, } @@ -484,54 +465,18 @@ impl WgNtTunnel { }); Ok(WgNtTunnel { - #[cfg(daita)] - resource_dir: resource_dir.to_owned(), config: Arc::new(Mutex::new(config.clone())), device, interface_name, setup_handle, - #[cfg(daita)] - daita_handle: None, _logger_handle: logger_handle, }) } fn stop_tunnel(&mut self) { self.setup_handle.abort(); - #[cfg(daita)] - if let Some(daita_handle) = self.daita_handle.take() { - let _ = daita_handle.close(); - } let _ = self.device.take(); } - - #[cfg(daita)] - fn spawn_machinist(&mut self) -> Result<()> { - if let Some(handle) = self.daita_handle.take() { - log::info!("Stopping previous DAITA machines"); - let _ = handle.close(); - } - - let Some(device) = self.device.clone() else { - log::debug!("Tunnel is stopped; not starting machines"); - return Ok(()); - }; - - let config = self.config.lock().unwrap(); - - log::info!("Initializing DAITA for wireguard device"); - let session = daita::Session::from_adapter(device).map_err(Error::EnableTunnelDaita)?; - self.daita_handle = Some( - daita::Machinist::spawn( - &self.resource_dir, - session, - config.entry_peer.public_key.clone(), - config.mtu, - ) - .map_err(Error::InitializeMachinist)?, - ); - Ok(()) - } } async fn setup_ip_listener(device: Arc<WgNtAdapter>, mtu: u32, has_ipv6: bool) -> Result<()> { @@ -689,14 +634,6 @@ struct WgNtDll { func_set_adapter_state: WireGuardSetStateFn, func_set_logger: WireGuardSetLoggerFn, func_set_adapter_logging: WireGuardSetAdapterLoggingFn, - #[cfg(daita)] - func_daita_activate: daita::bindings::WireGuardDaitaActivateFn, - #[cfg(daita)] - func_daita_event_data_available_event: daita::bindings::WireGuardDaitaEventDataAvailableEventFn, - #[cfg(daita)] - func_daita_receive_events: daita::bindings::WireGuardDaitaReceiveEventsFn, - #[cfg(daita)] - func_daita_send_action: daita::bindings::WireGuardDaitaSendActionFn, } unsafe impl Send for WgNtDll {} @@ -750,23 +687,6 @@ impl WgNtDll { func_set_adapter_logging: unsafe { *((&get_proc_fn(handle, c"WireGuardSetAdapterLogging")?) as *const _ as *const _) }, - #[cfg(daita)] - func_daita_activate: unsafe { - *((&get_proc_fn(handle, c"WireGuardDaitaActivate")?) as *const _ as *const _) - }, - #[cfg(daita)] - func_daita_event_data_available_event: unsafe { - *((&get_proc_fn(handle, c"WireGuardDaitaEventDataAvailableEvent")?) as *const _ - as *const _) - }, - #[cfg(daita)] - func_daita_receive_events: unsafe { - *((&get_proc_fn(handle, c"WireGuardDaitaReceiveEvents")?) as *const _ as *const _) - }, - #[cfg(daita)] - func_daita_send_action: unsafe { - *((&get_proc_fn(handle, c"WireGuardDaitaSendAction")?) as *const _ as *const _) - }, }) } @@ -867,56 +787,6 @@ impl WgNtDll { } Ok(()) } - - #[cfg(daita)] - pub unsafe fn daita_activate( - &self, - adapter: RawHandle, - events_capacity: usize, - actions_capacity: usize, - ) -> io::Result<()> { - if !unsafe { (self.func_daita_activate)(adapter, events_capacity, actions_capacity) } { - return Err(io::Error::last_os_error()); - } - Ok(()) - } - - #[cfg(daita)] - pub unsafe fn daita_event_data_available_event( - &self, - adapter: RawHandle, - ) -> io::Result<RawHandle> { - let ready_event = unsafe { (self.func_daita_event_data_available_event)(adapter) }; - if ready_event.is_null() { - return Err(io::Error::last_os_error()); - } - Ok(ready_event) - } - - #[cfg(daita)] - pub unsafe fn daita_receive_events( - &self, - adapter: RawHandle, - events: *mut daita::Event, - ) -> io::Result<usize> { - let num_events = unsafe { (self.func_daita_receive_events)(adapter, events) }; - if num_events == 0 { - return Err(io::Error::last_os_error()); - } - Ok(num_events) - } - - #[cfg(daita)] - pub unsafe fn daita_send_action( - &self, - adapter: RawHandle, - action: *const daita::Action, - ) -> io::Result<()> { - if !unsafe { (self.func_daita_send_action)(adapter, action) } { - return Err(io::Error::last_os_error()); - } - Ok(()) - } } impl Drop for WgNtDll { @@ -943,17 +813,10 @@ fn serialize_config(config: &Config) -> Result<Vec<MaybeUninit<u8>>> { buffer.extend(as_uninit_byte_slice(&header)); for peer in config.peers() { - #[cfg(not(daita))] let mut flags = WgPeerFlag::HAS_PUBLIC_KEY | WgPeerFlag::HAS_ENDPOINT; - #[cfg(daita)] - let mut flags = WgPeerFlag::HAS_PUBLIC_KEY - | WgPeerFlag::HAS_ENDPOINT - | WgPeerFlag::HAS_CONSTANT_PACKET_SIZE; if peer.psk.is_some() { flags |= WgPeerFlag::HAS_PRESHARED_KEY; } - #[cfg(daita)] - let constant_packet_size = if peer.constant_packet_size { 1 } else { 0 }; let wg_peer = WgPeer { flags, reserved: 0, @@ -969,8 +832,7 @@ fn serialize_config(config: &Config) -> Result<Vec<MaybeUninit<u8>>> { rx_bytes: 0, last_handshake: 0, allowed_ips_count: u32::try_from(peer.allowed_ips.len()).unwrap(), - #[cfg(daita)] - constant_packet_size, + constant_packet_size: 0, }; buffer.extend(as_uninit_byte_slice(&wg_peer)); @@ -1127,18 +989,8 @@ impl Tunnel for WgNtTunnel { }) } - #[cfg(daita)] - fn start_daita( - &mut self, - _: talpid_tunnel_config_client::DaitaSettings, - ) -> std::result::Result<(), crate::TunnelError> { - self.spawn_machinist().map_err(|error| { - log::error!( - "{}", - error.display_chain_with_msg("Failed to start DAITA for wg-nt tunnel") - ); - super::TunnelError::SetConfigError - }) + fn start_daita(&mut self, _settings: DaitaSettings) -> std::result::Result<(), TunnelError> { + unimplemented!("DAITA is not supported on wireguard-nt") } } @@ -1193,9 +1045,8 @@ mod tests { ipv6_gateway: None, mtu: 0, obfuscator_config: None, - #[cfg(daita)] - daita: false, quantum_resistant: false, + daita: false, }); static WG_STRUCT_CONFIG: LazyLock<Interface> = LazyLock::new(|| Interface { @@ -1207,9 +1058,7 @@ mod tests { peers_count: 1, }, p0: WgPeer { - flags: WgPeerFlag::HAS_PUBLIC_KEY - | WgPeerFlag::HAS_ENDPOINT - | WgPeerFlag::HAS_CONSTANT_PACKET_SIZE, + flags: WgPeerFlag::HAS_PUBLIC_KEY | WgPeerFlag::HAS_ENDPOINT, reserved: 0, public_key: *WG_PUBLIC_KEY.as_bytes(), preshared_key: [0; WIREGUARD_KEY_LENGTH], |
