diff options
| author | Bug Magnet <marco.nikic@mullvad.net> | 2024-10-22 10:38:06 +0200 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2024-11-06 12:56:32 +0100 |
| commit | a69eb3005dd5b10cd1a035943b0e67187caeb808 (patch) | |
| tree | c77ed1d723b2121f2819d809063c87f77ed8b197 | |
| parent | 82f31fb9a647e0736e3e999044126542a25654f2 (diff) | |
| download | mullvadvpn-a69eb3005dd5b10cd1a035943b0e67187caeb808.tar.xz mullvadvpn-a69eb3005dd5b10cd1a035943b0e67187caeb808.zip | |
Remove the concept of opening and closing sockets
6 files changed, 14 insertions, 19 deletions
diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj index dabfa71078..c5be416824 100644 --- a/ios/MullvadVPN.xcodeproj/project.pbxproj +++ b/ios/MullvadVPN.xcodeproj/project.pbxproj @@ -9259,8 +9259,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/mullvad/wireguard-apple.git"; requirement = { - kind = revision; - revision = afb345188c187dddafae0f9e27c5466be11451c2; + branch = "icmp-socket-always-on"; + kind = branch; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/ios/MullvadVPN.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ios/MullvadVPN.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 2b8fd8c64f..a6a8201790 100644 --- a/ios/MullvadVPN.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ios/MullvadVPN.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -14,7 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/mullvad/wireguard-apple.git", "state" : { - "revision" : "afb345188c187dddafae0f9e27c5466be11451c2" + "branch" : "icmp-socket-always-on", + "revision" : "5e051810193e089230529691ea7b8d2244f3a05b" } } ], diff --git a/ios/PacketTunnelCore/Pinger/PingerProtocol.swift b/ios/PacketTunnelCore/Pinger/PingerProtocol.swift index 67c64c1448..9df8ac50b0 100644 --- a/ios/PacketTunnelCore/Pinger/PingerProtocol.swift +++ b/ios/PacketTunnelCore/Pinger/PingerProtocol.swift @@ -32,7 +32,7 @@ public struct PingerSendResult { public protocol PingerProtocol { var onReply: ((PingerReply) -> Void)? { get set } - func openSocket(bindTo interfaceName: String?, destAddress: IPv4Address) throws - func closeSocket() + func startPinging(destAddress: IPv4Address) throws + func stopPinging() func send() throws -> PingerSendResult } diff --git a/ios/PacketTunnelCore/Pinger/TunnelPinger.swift b/ios/PacketTunnelCore/Pinger/TunnelPinger.swift index 47c5d8734a..d5ad6a95ac 100644 --- a/ios/PacketTunnelCore/Pinger/TunnelPinger.swift +++ b/ios/PacketTunnelCore/Pinger/TunnelPinger.swift @@ -31,12 +31,7 @@ public final class TunnelPinger: PingerProtocol { self.logger = Logger(label: "TunnelPinger") } - deinit { - pingProvider.closeICMP() - } - - public func openSocket(bindTo interfaceName: String?, destAddress: IPv4Address) throws { - try pingProvider.openICMP(address: destAddress) + public func startPinging(destAddress: IPv4Address) throws { stateLock.withLock { self.destAddress = destAddress } @@ -64,10 +59,9 @@ public final class TunnelPinger: PingerProtocol { } } - public func closeSocket() { + public func stopPinging() { stateLock.withLock { self.destAddress = nil - pingProvider.closeICMP() } } diff --git a/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitor.swift b/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitor.swift index e2b3dbd17b..dbd8fcbf2f 100644 --- a/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitor.swift +++ b/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitor.swift @@ -298,12 +298,12 @@ public final class TunnelMonitor: TunnelMonitorProtocol { private func startMonitoring() { do { - guard let interfaceName = tunnelDeviceInfo.interfaceName, let probeAddress else { - logger.debug("Failed to obtain utun interface name or probe address.") + guard let probeAddress else { + logger.debug("Failed to obtain probe address.") return } - try pinger.openSocket(bindTo: interfaceName, destAddress: probeAddress) + try pinger.startPinging(destAddress: probeAddress) state.connectionState = .connecting startConnectivityCheckTimer() @@ -314,7 +314,7 @@ public final class TunnelMonitor: TunnelMonitorProtocol { private func stopMonitoring(resetRetryAttempt: Bool) { stopConnectivityCheckTimer() - pinger.closeSocket() + pinger.stopPinging() state.netStats = WgStats() state.lastSeenRx = nil diff --git a/ios/PacketTunnelCoreTests/Mocks/PingerMock.swift b/ios/PacketTunnelCoreTests/Mocks/PingerMock.swift index 0dd16f6f65..463acc54b4 100644 --- a/ios/PacketTunnelCoreTests/Mocks/PingerMock.swift +++ b/ios/PacketTunnelCoreTests/Mocks/PingerMock.swift @@ -34,14 +34,14 @@ class PingerMock: PingerProtocol { self.decideOutcome = decideOutcome } - func openSocket(bindTo interfaceName: String?, destAddress: IPv4Address) throws { + func startPinging(destAddress: IPv4Address) throws { stateLock.withLock { state.destAddress = destAddress state.isSocketOpen = true } } - func closeSocket() { + func stopPinging() { stateLock.withLock { state.isSocketOpen = false } |
