Skip to content

Commit 1492497

Browse files
authored
Make device object immutable; support Musl platform (#13)
1 parent 28f3728 commit 1492497

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

Sources/LCLPing/HTTP/HTTPPingClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ extension HTTPPingClient {
180180
public let resolvedAddress: SocketAddress
181181

182182
/// The outgoing device associated with the given interface name
183-
public var device: NIONetworkDevice?
183+
public private(set) var device: NIONetworkDevice?
184184

185185
/// Initialize a HTTP Ping Client `Configuration`.
186186
///

Sources/LCLPing/HTTP/NIOHTTPClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ final class NIOHTTPClient: Pingable {
214214
default:
215215
()
216216
}
217-
#elseif canImport(Glibc)
217+
#elseif canImport(Glibc) || canImport(Musl)
218218
return (channel as! SocketOptionProvider).setBindToDevice(device.name)
219219
#endif
220220
}

Sources/LCLPing/ICMP/ICMPPingClient.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public final class ICMPPingClient: Pingable {
190190
default:
191191
()
192192
}
193-
#elseif canImport(Glibc)
193+
#elseif canImport(Glibc) || canImport(Musl)
194194
return (channel as! SocketOptionProvider).setBindToDevice(device.name)
195195
#endif
196196
}
@@ -235,7 +235,7 @@ extension ICMPPingClient {
235235
public let resolvedAddress: SocketAddress
236236

237237
/// The outgoing device associated with the given interface name
238-
public var device: NIONetworkDevice?
238+
public private(set) var device: NIONetworkDevice?
239239

240240
public init(endpoint: EndpointTarget,
241241
count: Int = 10,

Sources/LCLPing/Utilities/LCLPing+SocketOption.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,26 @@
1212

1313
import Foundation
1414
import NIOCore
15+
#if canImport(Darwin)
16+
import Darwin
17+
#elseif canImport(Glibc)
18+
import Glibc
19+
#elseif canImport(Musl)
20+
import Musl
21+
#endif
1522

1623
extension NIOBSDSocket.Option {
1724
#if canImport(Darwin)
1825
public static let ip_bound_if: NIOBSDSocket.Option = Self(rawValue: IP_BOUND_IF)
1926
public static let ipv6_bound_if: NIOBSDSocket.Option = Self(rawValue: IPV6_BOUND_IF)
20-
#elseif canImport(Glibc)
27+
#elseif canImport(Glibc) || canImport(Musl)
2128
public static let so_bindtodevice = Self(rawValue: SO_BINDTODEVICE)
2229
#endif
2330
}
2431

2532
extension SocketOptionProvider {
26-
#if canImport(Glibc)
33+
#if canImport(Glibc) || canImport(Musl)
34+
2735
/// Sets the socket option SO_BINDTODEVICE to `value`.
2836
///
2937
/// - parameters:

0 commit comments

Comments
 (0)