diff --git a/rust/bin-shared/src/tun_device_manager/windows.rs b/rust/bin-shared/src/tun_device_manager/windows.rs index 2fbcb51ed..03daaaa41 100644 --- a/rust/bin-shared/src/tun_device_manager/windows.rs +++ b/rust/bin-shared/src/tun_device_manager/windows.rs @@ -217,34 +217,35 @@ impl Drop for Tun { } impl Tun { - #[tracing::instrument(level = "debug")] - pub fn new(mtu: u32) -> Result { - let path = ensure_dll()?; + fn new(mtu: u32) -> Result { + let path = ensure_dll().context("Failed to ensure `wintun.dll` is in place")?; // SAFETY: we're loading a DLL from disk and it has arbitrary C code in it. There's no perfect way to prove it's safe. - let wintun = unsafe { wintun::load_from_path(path) }?; + let wintun = unsafe { wintun::load_from_path(path.clone()) } + .with_context(|| format!("Failed to load `wintun.dll` from {}", path.display()))?; // Create wintun adapter - let adapter = match Adapter::create( + let adapter = Adapter::create( &wintun, TUNNEL_NAME, TUNNEL_NAME, Some(TUNNEL_UUID.as_u128()), - ) { - Ok(x) => x, - Err(error) => { - tracing::error!(error = std_dyn_err(&error), "Failed in `Adapter::create`"); - return Err(error)?; - } - }; - let iface_idx = adapter.get_adapter_index()?; + )?; + let iface_idx = adapter + .get_adapter_index() + .context("Failed to get adapter index")?; - set_iface_config(adapter.get_luid(), mtu)?; + set_iface_config(adapter.get_luid(), mtu).context("Failed to set interface config")?; - let session = Arc::new(adapter.start_session(RING_BUFFER_SIZE)?); + let session = Arc::new( + adapter + .start_session(RING_BUFFER_SIZE) + .context("Failed to start session")?, + ); // 4 is a nice power of two. Wintun already queues packets for us, so we don't // need much capacity here. let (packet_tx, packet_rx) = mpsc::channel(4); - let recv_thread = start_recv_thread(packet_tx, Arc::clone(&session))?; + let recv_thread = start_recv_thread(packet_tx, Arc::clone(&session)) + .context("Failed to start recv thread")?; Ok(Self { iface_idx, diff --git a/rust/headless-client/src/ipc_service.rs b/rust/headless-client/src/ipc_service.rs index ee6ca7af9..80478d27b 100644 --- a/rust/headless-client/src/ipc_service.rs +++ b/rust/headless-client/src/ipc_service.rs @@ -9,7 +9,7 @@ use firezone_bin_shared::{ platform::{tcp_socket_factory, udp_socket_factory, DnsControlMethod}, TunDeviceManager, TOKEN_ENV_KEY, }; -use firezone_logging::{anyhow_dyn_err, std_dyn_err, telemetry_span}; +use firezone_logging::{anyhow_dyn_err, telemetry_span}; use firezone_telemetry::Telemetry; use futures::{ future::poll_fn, @@ -480,12 +480,7 @@ impl<'a> Handler<'a> { // Warning: Connection errors don't bubble to callers of `handle_ipc_msg`. let token = secrecy::SecretString::from(token); let result = self.connect_to_firezone(&api_url, token); - if let Err(error) = &result { - tracing::error!( - error = std_dyn_err(error), - "Failed to connect connlib session" - ); - } + self.ipc_tx .send(&ServerMsg::ConnectResult(result)) .await