From c030b79540a3a6561341580730bafd2b09547f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Em=C4=ABls?= Date: Tue, 10 Dec 2024 16:40:03 +0100 Subject: [PATCH] Update docs --- .../include/mullvad_rust_runtime.h | 7 ++++--- mullvad-ios/src/ephemeral_peer_proxy/mod.rs | 12 ++++-------- .../src/ephemeral_peer_proxy/peer_exchange.rs | 1 - 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h b/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h index b2bb5b6dfd95..6a176c3551e4 100644 --- a/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h +++ b/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h @@ -114,9 +114,10 @@ void drop_ephemeral_peer_exchange_token(struct ExchangeCancelToken *sender); * # Safety * `public_key` and `ephemeral_key` must be valid respective `PublicKey` and `PrivateKey` types. * They will not be valid after this function is called, and thus must be copied here. - * `packet_tunnel` and `tcp_connection` must be valid pointers to a packet tunnel and a TCP - * connection instances. - * `cancel_token` should be owned by the caller of this function. + * `packet_tunnel` must be valid pointers to a packet tunnel, the packet tunnel pointer must + * outlive the ephemeral peer exchange. `cancel_token` should be owned by the caller of this + * function. + * */ struct ExchangeCancelToken *request_ephemeral_peer(const uint8_t *public_key, const uint8_t *ephemeral_key, diff --git a/mullvad-ios/src/ephemeral_peer_proxy/mod.rs b/mullvad-ios/src/ephemeral_peer_proxy/mod.rs index 6eab5134710d..5d932fe727f2 100644 --- a/mullvad-ios/src/ephemeral_peer_proxy/mod.rs +++ b/mullvad-ios/src/ephemeral_peer_proxy/mod.rs @@ -31,11 +31,6 @@ impl PacketTunnelBridge { } } -// # Safety -// This is safe as long as the PacketTunnel class outlives the instance of the PacketTunnelBridge, -// and thus the ephemeral peer exchange. Since the peer exchange takes place in the packet tunnel -// process on iOS, it is certain _enough_ this will be the case. -// It is safe to implement Send for PacketTunnelBridge because the packet_tunnel unsafe impl Send for PacketTunnelBridge {} #[repr(C)] @@ -80,9 +75,10 @@ pub unsafe extern "C" fn drop_ephemeral_peer_exchange_token( /// # Safety /// `public_key` and `ephemeral_key` must be valid respective `PublicKey` and `PrivateKey` types. /// They will not be valid after this function is called, and thus must be copied here. -/// `packet_tunnel` and `tcp_connection` must be valid pointers to a packet tunnel and a TCP -/// connection instances. -/// `cancel_token` should be owned by the caller of this function. +/// `packet_tunnel` must be valid pointers to a packet tunnel, the packet tunnel pointer must +/// outlive the ephemeral peer exchange. `cancel_token` should be owned by the caller of this +/// function. +/// #[no_mangle] pub unsafe extern "C" fn request_ephemeral_peer( public_key: *const u8, diff --git a/mullvad-ios/src/ephemeral_peer_proxy/peer_exchange.rs b/mullvad-ios/src/ephemeral_peer_proxy/peer_exchange.rs index bcc42a007a16..e3540c2d432d 100644 --- a/mullvad-ios/src/ephemeral_peer_proxy/peer_exchange.rs +++ b/mullvad-ios/src/ephemeral_peer_proxy/peer_exchange.rs @@ -30,7 +30,6 @@ impl ExchangeCancelToken { task.abort(); // CODE STENCH: // Swift can call this function from a tokio context. That *will* crash. - // context. let _ = inner.tokio_handle.block_on(task); } }