summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBug Magnet <marco.nikic@mullvad.net>2024-06-14 10:19:31 +0200
committerBug Magnet <marco.nikic@mullvad.net>2024-06-17 13:22:25 +0200
commit0af08f5096693881a03c5914906e783b7dd99288 (patch)
treee34950bd106122c0566f0220a672703b2fa0c5d7
parent9030a3b015eb488f6babf7b5be2af1e7ce4b9e23 (diff)
downloadmullvadvpn-0af08f5096693881a03c5914906e783b7dd99288.tar.xz
mullvadvpn-0af08f5096693881a03c5914906e783b7dd99288.zip
Clean up the code
-rw-r--r--talpid-tunnel-config-client/src/ios_ffi/ios_runtime.rs16
-rw-r--r--talpid-tunnel-config-client/src/ios_ffi/ios_tcp_connection.rs20
2 files changed, 18 insertions, 18 deletions
diff --git a/talpid-tunnel-config-client/src/ios_ffi/ios_runtime.rs b/talpid-tunnel-config-client/src/ios_ffi/ios_runtime.rs
index 509b38c461..1ab08a19bc 100644
--- a/talpid-tunnel-config-client/src/ios_ffi/ios_runtime.rs
+++ b/talpid-tunnel-config-client/src/ios_ffi/ios_runtime.rs
@@ -96,8 +96,8 @@ impl IOSRuntime {
self.run_service_inner();
});
}
- /// Creates a `RelayConfigService` using the in-tunnel TCP Connection provided by the Packet
- /// Tunnel Provider # Safety
+ /// Creates a `RelayConfigService` using the in-tunnel TCP Connection provided by the Packet Tunnel Provider
+ /// # Safety
/// It is unsafe to call this with an already used `SwiftContext`
async unsafe fn ios_tcp_client(
ctx: SwiftContext,
@@ -153,16 +153,20 @@ impl IOSRuntime {
let preshared_key_bytes = preshared_key.as_bytes();
swift_post_quantum_key_ready(packet_tunnel_ptr, preshared_key_bytes.as_ptr(), self.ephemeral_key.as_ptr());
},
- None => unsafe {
+ None => {
log::error!("No suitable peer was found");
- swift_post_quantum_key_ready(packet_tunnel_ptr, ptr::null(), ptr::null());
+ unsafe {
+ swift_post_quantum_key_ready(packet_tunnel_ptr, ptr::null(), ptr::null());
+ }
}
}
},
- Err(error) => unsafe {
+ Err(error) => {
log::error!("Key exchange failed {}", error);
- swift_post_quantum_key_ready(packet_tunnel_ptr, ptr::null(), ptr::null());
+ unsafe {
+ swift_post_quantum_key_ready(packet_tunnel_ptr, ptr::null(), ptr::null());
+ }
}
}
}
diff --git a/talpid-tunnel-config-client/src/ios_ffi/ios_tcp_connection.rs b/talpid-tunnel-config-client/src/ios_ffi/ios_tcp_connection.rs
index 656bb142c8..b550cc69b3 100644
--- a/talpid-tunnel-config-client/src/ios_ffi/ios_tcp_connection.rs
+++ b/talpid-tunnel-config-client/src/ios_ffi/ios_tcp_connection.rs
@@ -64,7 +64,7 @@ unsafe impl Send for ConnectionContext {}
impl IosTcpProvider {
/// # Safety
- /// `tcp_connection` must be pointing to a valid instance of a `NWTCPConnection`, created by the
+ /// `connection` must be pointing to a valid instance of a `NWTCPConnection`, created by the
/// `PacketTunnelProvider`
pub unsafe fn new(connection: Arc<Mutex<ConnectionContext>>) -> (Self, IosTcpShutdownHandle) {
let (tx, rx) = mpsc::unbounded_channel();
@@ -93,17 +93,15 @@ impl IosTcpProvider {
impl IosTcpShutdownHandle {
pub fn shutdown(self) {
- {
- let Ok(mut context) = self.context.lock() else {
- return;
- };
+ let Ok(mut context) = self.context.lock() else {
+ return;
+ };
- context.tcp_connection = None;
- if let Some(waker) = context.waker.take() {
- waker.wake();
- }
- std::mem::drop(context);
+ context.tcp_connection = None;
+ if let Some(waker) = context.waker.take() {
+ waker.wake();
}
+ std::mem::drop(context);
}
}
@@ -136,7 +134,6 @@ impl AsyncWrite for IosTcpProvider {
let raw_sender = Weak::into_raw(Arc::downgrade(&self.write_tx));
unsafe {
swift_nw_tcp_connection_send(
- // self.tcp_connection,
tcp_ptr,
buf.as_ptr() as _,
buf.len(),
@@ -193,7 +190,6 @@ impl AsyncRead for IosTcpProvider {
if !self.read_in_progress {
let raw_sender = Weak::into_raw(Arc::downgrade(&self.read_tx));
unsafe {
- // TODO
swift_nw_tcp_connection_read(tcp_ptr, raw_sender as _);
}
self.read_in_progress = true;