Skip to content

Commit

Permalink
Changes from pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
acb-mv committed Sep 18, 2024
1 parent d11d793 commit 8bfb248
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions ios/PacketTunnelCore/Pinger/TunnelPinger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public final class TunnelPinger: PingerProtocol {
}
}

var socketHandle: Int32?

var pingProvider: ICMPPingProvider
private var pingProvider: ICMPPingProvider

private let logger: Logger

Expand Down Expand Up @@ -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)
Expand All @@ -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)
}
}
Expand Down
4 changes: 2 additions & 2 deletions ios/PacketTunnelCoreTests/Mocks/PingerMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class PingerMock: PingerProtocol {

networkStatsReporting.reportBytesSent(UInt64(icmpPacketSize))

return PingerSendResult(sequenceNumber: nextSequenceId, bytesSent: icmpPacketSize)
return PingerSendResult(sequenceNumber: nextSequenceId)
}

// MARK: - Types
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ios/PacketTunnelCoreTests/PingerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 8bfb248

Please sign in to comment.