diff --git a/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h b/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h index 56b4ac9486d4..26904b89dfe8 100644 --- a/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h +++ b/ios/MullvadRustRuntime/include/mullvad_rust_runtime.h @@ -5,6 +5,9 @@ #include #include +/** + * SAFETY: `TunnelObfuscatorProtocol` values must either be `0` or `1` + */ enum TunnelObfuscatorProtocol { UdpOverTcp = 0, Shadowsocks, diff --git a/ios/MullvadRustRuntimeTests/UnsafeListener.swift b/ios/MullvadRustRuntimeTests/UnsafeListener.swift index a09fa604d0db..2ccf0c1aaf57 100644 --- a/ios/MullvadRustRuntimeTests/UnsafeListener.swift +++ b/ios/MullvadRustRuntimeTests/UnsafeListener.swift @@ -8,6 +8,7 @@ import Network +/// > Warning: Do not use this implementation in production code. See the warning in `start()`. class UnsafeListener { private let dispatchQueue = DispatchQueue(label: "com.test.unsafeListener") private let listener: NWListener diff --git a/mullvad-ios/src/lib.rs b/mullvad-ios/src/lib.rs index 4a24745b09c5..61c47803a405 100644 --- a/mullvad-ios/src/lib.rs +++ b/mullvad-ios/src/lib.rs @@ -2,7 +2,7 @@ mod encrypted_dns_proxy; mod ephemeral_peer_proxy; mod shadowsocks_proxy; -mod tunnel_obfuscator_proxy; +pub mod tunnel_obfuscator_proxy; #[repr(C)] pub struct ProxyHandle { diff --git a/mullvad-ios/src/tunnel_obfuscator_proxy/ffi.rs b/mullvad-ios/src/tunnel_obfuscator_proxy/ffi.rs index c28682759b1c..e9ad7ba7941b 100644 --- a/mullvad-ios/src/tunnel_obfuscator_proxy/ffi.rs +++ b/mullvad-ios/src/tunnel_obfuscator_proxy/ffi.rs @@ -7,7 +7,7 @@ use std::{ static INIT_LOGGING: Once = Once::new(); -#[allow(dead_code)] +/// SAFETY: `TunnelObfuscatorProtocol` values must either be `0` or `1` #[repr(u8)] pub enum TunnelObfuscatorProtocol { UdpOverTcp = 0, @@ -35,8 +35,7 @@ pub unsafe extern "C" fn start_tunnel_obfuscator_proxy( return -1; }; - let result = TunnelObfuscatorRuntime::new(peer_sock_addr, obfuscation_protocol) - .and_then(|runtime| runtime.run()); + let result = TunnelObfuscatorRuntime::new(peer_sock_addr, obfuscation_protocol).run(); match result { Ok((local_endpoint, obfuscator_handle)) => { diff --git a/mullvad-ios/src/tunnel_obfuscator_proxy/mod.rs b/mullvad-ios/src/tunnel_obfuscator_proxy/mod.rs index 3526cc6f2ea1..f33d6fd6ee2d 100644 --- a/mullvad-ios/src/tunnel_obfuscator_proxy/mod.rs +++ b/mullvad-ios/src/tunnel_obfuscator_proxy/mod.rs @@ -17,10 +17,7 @@ pub struct TunnelObfuscatorRuntime { } impl TunnelObfuscatorRuntime { - pub fn new( - peer: SocketAddr, - obfuscation_protocol: TunnelObfuscatorProtocol, - ) -> io::Result { + pub fn new(peer: SocketAddr, obfuscation_protocol: TunnelObfuscatorProtocol) -> Self { let settings: ObfuscationSettings = match obfuscation_protocol { TunnelObfuscatorProtocol::UdpOverTcp => { ObfuscationSettings::Udp2Tcp(udp2tcp::Settings { peer }) @@ -33,7 +30,7 @@ impl TunnelObfuscatorRuntime { } }; - Ok(Self { settings }) + Self { settings } } pub fn run(self) -> io::Result<(SocketAddr, TunnelObfuscatorHandle)> {