diff options
| author | Emīls <emils@mullvad.net> | 2025-12-02 09:36:32 +0100 |
|---|---|---|
| committer | Emīls <emils@mullvad.net> | 2025-12-19 12:59:49 +0100 |
| commit | 4d42bb21eb083d4863b3a25ebd58ea68f8faeb5b (patch) | |
| tree | d6a38edb614ad2c4a2b9eb7363390f67674128e0 | |
| parent | 629e877d124d0c9782bb449d5e78e9f80de141c3 (diff) | |
| download | mullvadvpn-4d42bb21eb083d4863b3a25ebd58ea68f8faeb5b.tar.xz mullvadvpn-4d42bb21eb083d4863b3a25ebd58ea68f8faeb5b.zip | |
WIP
| -rw-r--r-- | ios/MullvadRustRuntime/GotaTun.swift | 8 | ||||
| -rw-r--r-- | ios/PacketTunnel/WireGuardAdapter/GotaAdapter.swift | 7 | ||||
| -rw-r--r-- | mullvad-ios/src/gotatun/config.rs | 67 |
3 files changed, 82 insertions, 0 deletions
diff --git a/ios/MullvadRustRuntime/GotaTun.swift b/ios/MullvadRustRuntime/GotaTun.swift index e1432f86d6..683b4c19d0 100644 --- a/ios/MullvadRustRuntime/GotaTun.swift +++ b/ios/MullvadRustRuntime/GotaTun.swift @@ -48,6 +48,14 @@ public class GotaTunConfig { handle, privateKey.map { $0 }, preSharedKeyOr(preSharedKey)?.map { $0 }, publicKey.map { $0 }, endpoint) } + public func addV4Addr(address: IPv4Address) { + + } + + public func addV6Addr(address: IPv6Address) { + + } + private func preSharedKeyOr(_ key: Data?) -> Data? { return key ?? Data(repeating: 0, count: 32) } diff --git a/ios/PacketTunnel/WireGuardAdapter/GotaAdapter.swift b/ios/PacketTunnel/WireGuardAdapter/GotaAdapter.swift index 606828d113..d91a9f44fc 100644 --- a/ios/PacketTunnel/WireGuardAdapter/GotaAdapter.swift +++ b/ios/PacketTunnel/WireGuardAdapter/GotaAdapter.swift @@ -107,6 +107,13 @@ public final class GotaAdapter: TunnelAdapterProtocol, TunnelDeviceInfoProtocol, preSharedKey: entryPeer.preSharedKey?.rawValue, publicKey: entryPeer.publicKey.rawValue, endpoint: entryPeer.endpoint.description) + + if let v4Addr = exit.interfaceAddresses.first( + where: { $0.address is IPv4Address }) { + config.set + } + + } config.addExit( diff --git a/mullvad-ios/src/gotatun/config.rs b/mullvad-ios/src/gotatun/config.rs index ee4dfabcb9..abe5737bb4 100644 --- a/mullvad-ios/src/gotatun/config.rs +++ b/mullvad-ios/src/gotatun/config.rs @@ -30,6 +30,8 @@ impl SwiftGotaTunConfiguration { pub struct GotaTunConfiguration { pub exit: Option<PeerConfiguration>, pub entry: Option<PeerConfiguration>, + pub private_ip_v4: Option<Ipv4Addr>, + pub private_ip_v6: Option<Ipv6Addr>, // TODO: add DAITA configuration } @@ -92,6 +94,24 @@ impl GotaTunConfiguration { fn set_peer(peer: &mut Option<PeerConfiguration>, config: PeerConfiguration) { *peer = Some(config); } + + fn set_ipv4_addr(&mut self, addr: &str) -> ConfigStatus { + let Ok(addr) = addr.parse() else { + return ConfigStatus::InvalidArg; + }; + + self.private_ip_v4 = Some(addr); + ConfigStatus::Success + } + + fn set_ipv6_addr(&mut self, addr: &str) -> ConfigStatus { + let Ok(addr) = addr.parse() else { + return ConfigStatus::InvalidArg; + }; + + self.private_ip_v6 = Some(addr); + ConfigStatus::Success + } } #[derive(Clone)] @@ -186,6 +206,53 @@ pub unsafe extern "C" fn mullvad_ios_gotatun_config_set_exit( /// #[unsafe(no_mangle)] +pub unsafe extern "C" fn mullvad_ios_gotatun_config_set_private_ipv4( + mut config: SwiftGotaTunConfiguration, + ipv4: *const u8, + peer_endpoint: *const c_char, +) -> i32 { + let cfg = unsafe { config.mut_config() }; +/// +#[unsafe(no_mangle)] +pub unsafe extern "C" fn mullvad_ios_gotatun_config_set_private_ipv4( + mut config: SwiftGotaTunConfiguration, + ipv4: *const u8, + peer_endpoint: *const c_char, +) -> i32 { + let cfg = unsafe { config.mut_config() }; + let cstr = unsafe { CStr::from_ptr(ptr) }; + let Ok(s) = cstr.to_str() { + return ConfigStatus::InvalidArg; + } + + config.set_ipv4_addr(&s); +} + let cstr = unsafe { CStr::from_ptr(ptr) }; + let Ok(s) = cstr.to_str() else { + return ConfigStatus::InvalidArg; + } + + config.set_ipv4_addr(&s); +} + +/// +#[unsafe(no_mangle)] +pub unsafe extern "C" fn mullvad_ios_gotatun_config_set_private_ipv6( + mut config: SwiftGotaTunConfiguration, + ipv4: *const u8, + peer_endpoint: *const c_char, +) -> i32 { + let cfg = unsafe { config.mut_config() }; + let cstr = unsafe { CStr::from_ptr(ptr) }; + let Ok(s) = cstr.to_str() else { + return ConfigStatus::InvalidArg; + } + + config.set_ipv6_addr(&s); +} + +/// +#[unsafe(no_mangle)] pub unsafe extern "C" fn mullvad_ios_gotatun_config_set_entry( mut config: SwiftGotaTunConfiguration, local_private_key: *const u8, |
