From 6cd825bf9369670711ac612599b23809f22e3acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Em=C4=ABls?= Date: Tue, 21 Nov 2023 16:33:37 +0100 Subject: [PATCH] Fix the leaks For the packet tunnel to receive traffic, it needs to have a peer configured so that the system configures routes for it. Otherwise, no routes are applied and all traffic leaks. --- .../Actor/PacketTunnelActor+ErrorState.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ios/PacketTunnelCore/Actor/PacketTunnelActor+ErrorState.swift b/ios/PacketTunnelCore/Actor/PacketTunnelActor+ErrorState.swift index 71afd7cdfd44..077bfdbb25f4 100644 --- a/ios/PacketTunnelCore/Actor/PacketTunnelActor+ErrorState.swift +++ b/ios/PacketTunnelCore/Actor/PacketTunnelActor+ErrorState.swift @@ -7,6 +7,8 @@ // import Foundation +import MullvadTypes +import Network import WireGuardKitTypes extension PacketTunnelActor { @@ -114,7 +116,15 @@ extension PacketTunnelActor { privateKey: PrivateKey(), interfaceAddresses: [] ) - try await tunnelAdapter.start(configuration: configurationBuilder.makeConfiguration()) + var config = try configurationBuilder.makeConfiguration() + config.dns = [IPv4Address.loopback] + config.interfaceAddresses = [IPAddressRange(from: "10.64.0.1/8")!] + config.peer = TunnelPeer( + endpoint: .ipv4(IPv4Endpoint(string: "127.0.0.1:9090")!), + publicKey: PrivateKey().publicKey + ) + try? await tunnelAdapter.stop() + try await tunnelAdapter.start(configuration: config) } catch { logger.error(error: error, message: "Unable to configure the tunnel for error state.") }