diff --git a/boltconn/src/app.rs b/boltconn/src/app.rs index d95ae77..d523585 100644 --- a/boltconn/src/app.rs +++ b/boltconn/src/app.rs @@ -495,13 +495,13 @@ async fn start_tun_services( #[cfg(unix)] let tcp_listener = tokio::net::TcpListener::bind(tun_inbound_tcp.nat_addr()) .await - .or_else(|e| { + .map_err(|e| { tracing::error!( "Failed to start NAT at {}: {}", tun_inbound_tcp.nat_addr(), e ); - Err(e) + e })?; #[cfg(windows)] let tcp_listener = { diff --git a/boltconn/src/external/uds_controller.rs b/boltconn/src/external/uds_controller.rs index 6ecf518..d06991d 100644 --- a/boltconn/src/external/uds_controller.rs +++ b/boltconn/src/external/uds_controller.rs @@ -43,10 +43,10 @@ impl UnixListenerGuard { .chown(&path) .map_err(|e| SystemError::Controller(as_io_err(e)))?; } - return Ok(Self { + Ok(Self { path: path.to_string_lossy().to_string(), listener: Some(listener), - }); + }) } #[cfg(windows)] { @@ -54,10 +54,10 @@ impl UnixListenerGuard { .first_pipe_instance(true) .create(path) .map_err(SystemError::Controller)?; - return Ok(Self { + Ok(Self { path: path.to_string(), listener: tokio::sync::Mutex::new(listener), - }); + }) } } diff --git a/boltconn/src/platform/process/windows.rs b/boltconn/src/platform/process/windows.rs index eff9b91..bf16bef 100644 --- a/boltconn/src/platform/process/windows.rs +++ b/boltconn/src/platform/process/windows.rs @@ -224,7 +224,7 @@ impl RecordSearcher { for i in 0..(record_cnt as usize) { let record = data .get((4 + i * self.item_size)..(4 + (i + 1) * self.item_size)) - .ok_or_else(|| std::io::ErrorKind::NotFound)?; + .ok_or(std::io::ErrorKind::NotFound)?; // only check established TCP record if let Some(tcp_state_offset) = self.tcp_state { let tcp_state = slice_to_u32(&record[tcp_state_offset..tcp_state_offset + 4]); diff --git a/boltconn/src/platform/sys/windows_sys.rs b/boltconn/src/platform/sys/windows_sys.rs index 0671dbd..e4ce274 100644 --- a/boltconn/src/platform/sys/windows_sys.rs +++ b/boltconn/src/platform/sys/windows_sys.rs @@ -186,7 +186,7 @@ impl SystemDnsHandle { impl Drop for SystemDnsHandle { fn drop(&mut self) { for record in self.old_dns.iter() { - if let Some(dns) = record.dns_server.get(0) { + if let Some(dns) = record.dns_server.first() { let _ = run_command(Command::new("netsh").args([ "interface", "ipv4", @@ -194,7 +194,7 @@ impl Drop for SystemDnsHandle { "dnsservers", &format!("name={}", record.iface_name), "source=static", - &format!("address={}", dns.to_string()), + &format!("address={}", dns), "register=none", "validate=no", ]));