Skip to content

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
buggmagnet committed Nov 11, 2024
1 parent 9923b67 commit 0ed4bfc
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
3 changes: 3 additions & 0 deletions ios/MullvadRustRuntime/include/mullvad_rust_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include <stdint.h>
#include <stdlib.h>

/**
* SAFETY: `TunnelObfuscatorProtocol` values must either be `0` or `1`
*/
enum TunnelObfuscatorProtocol {
UdpOverTcp = 0,
Shadowsocks,
Expand Down
1 change: 1 addition & 0 deletions ios/MullvadRustRuntimeTests/UnsafeListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Network

/// > Warning: Do not use this implementation in production code. See the warning in `start()`.
class UnsafeListener<T: Connection> {
private let dispatchQueue = DispatchQueue(label: "com.test.unsafeListener")
private let listener: NWListener
Expand Down
2 changes: 1 addition & 1 deletion mullvad-ios/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions mullvad-ios/src/tunnel_obfuscator_proxy/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)) => {
Expand Down
7 changes: 2 additions & 5 deletions mullvad-ios/src/tunnel_obfuscator_proxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ pub struct TunnelObfuscatorRuntime {
}

impl TunnelObfuscatorRuntime {
pub fn new(
peer: SocketAddr,
obfuscation_protocol: TunnelObfuscatorProtocol,
) -> io::Result<Self> {
pub fn new(peer: SocketAddr, obfuscation_protocol: TunnelObfuscatorProtocol) -> Self {
let settings: ObfuscationSettings = match obfuscation_protocol {
TunnelObfuscatorProtocol::UdpOverTcp => {
ObfuscationSettings::Udp2Tcp(udp2tcp::Settings { peer })
Expand All @@ -33,7 +30,7 @@ impl TunnelObfuscatorRuntime {
}
};

Ok(Self { settings })
Self { settings }
}

pub fn run(self) -> io::Result<(SocketAddr, TunnelObfuscatorHandle)> {
Expand Down

0 comments on commit 0ed4bfc

Please sign in to comment.