diff options
| author | Andrew Bulhak <andrew.bulhak@mullvad.net> | 2024-09-18 15:25:21 +0200 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2024-09-18 16:26:55 +0200 |
| commit | e90f94db7b378fff8f2511ec9de82858c1e51eb7 (patch) | |
| tree | ba354a352da8eca04abd39f6879660e2bf04c2e0 | |
| parent | dee9d4e90af2dda070cbe72cc76cf4a375197012 (diff) | |
| download | mullvadvpn-e90f94db7b378fff8f2511ec9de82858c1e51eb7.tar.xz mullvadvpn-e90f94db7b378fff8f2511ec9de82858c1e51eb7.zip | |
Remove unused variable
4 files changed, 8 insertions, 10 deletions
diff --git a/ios/PacketTunnelCore/Pinger/TunnelPinger.swift b/ios/PacketTunnelCore/Pinger/TunnelPinger.swift index d1f7973b5e..f011fc9a01 100644 --- a/ios/PacketTunnelCore/Pinger/TunnelPinger.swift +++ b/ios/PacketTunnelCore/Pinger/TunnelPinger.swift @@ -32,9 +32,7 @@ public final class TunnelPinger: PingerProtocol { } } - var socketHandle: Int32? - - var pingProvider: ICMPPingProvider + private var pingProvider: ICMPPingProvider private let logger: Logger @@ -44,7 +42,7 @@ public final class TunnelPinger: PingerProtocol { self.pingQueue = DispatchQueue(label: "PacketTunnel.icmp") self.logger = Logger(label: "TunnelPinger") } - + deinit { pingProvider.closeICMP() } @@ -68,6 +66,7 @@ public final class TunnelPinger: PingerProtocol { let reply: PingerReply do { try pingProvider.sendICMPPing(seqNumber: sequenceNumber) + // NOTE: we cheat here by returning the destination address we were passed, rather than parsing it from the packet on the other side of the FFI boundary. reply = .success(destAddress, sequenceNumber) } catch { reply = .parseError(error) @@ -76,7 +75,6 @@ public final class TunnelPinger: PingerProtocol { replyQueue.async { [weak self] in guard let self else { return } - // NOTE: we cheat here by returning the destination address we were passed, rather than parsing it from the packet on the other side of the FFI boundary. self.onReply?(reply) } } diff --git a/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitor.swift b/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitor.swift index b723862191..e2b3dbd17b 100644 --- a/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitor.swift +++ b/ios/PacketTunnelCore/TunnelMonitor/TunnelMonitor.swift @@ -178,7 +178,7 @@ public final class TunnelMonitor: TunnelMonitorProtocol { nslock.lock() defer { nslock.unlock() } - guard let probeAddress, let newStats = getStats(), + guard let newStats = getStats(), state.connectionState == .connecting || state.connectionState == .connected else { return } diff --git a/ios/PacketTunnelCoreTests/Mocks/PingerMock.swift b/ios/PacketTunnelCoreTests/Mocks/PingerMock.swift index ab80bee914..0dd16f6f65 100644 --- a/ios/PacketTunnelCoreTests/Mocks/PingerMock.swift +++ b/ios/PacketTunnelCoreTests/Mocks/PingerMock.swift @@ -86,7 +86,7 @@ class PingerMock: PingerProtocol { networkStatsReporting.reportBytesSent(UInt64(icmpPacketSize)) - return PingerSendResult(sequenceNumber: nextSequenceId, bytesSent: icmpPacketSize) + return PingerSendResult(sequenceNumber: nextSequenceId) } // MARK: - Types @@ -96,7 +96,7 @@ class PingerMock: PingerProtocol { var sequenceId: UInt16 = 0 var isSocketOpen = false var onReply: ((PingerReply) -> Void)? - var destAddress: IPv4Address? = nil + var destAddress: IPv4Address? mutating func incrementSequenceId() -> UInt16 { sequenceId += 1 diff --git a/ios/PacketTunnelCoreTests/PingerTests.swift b/ios/PacketTunnelCoreTests/PingerTests.swift index 12fe12ddc5..e849b0fda2 100644 --- a/ios/PacketTunnelCoreTests/PingerTests.swift +++ b/ios/PacketTunnelCoreTests/PingerTests.swift @@ -25,8 +25,8 @@ final class PingerTests: XCTestCase { } } - try pinger.openSocket(bindTo: "lo0") - sendResult = try pinger.send(to: .loopback) + try pinger.openSocket(bindTo: "lo0", destAddress: .loopback) + sendResult = try pinger.send() waitForExpectations(timeout: .UnitTest.timeout) } |
