diff --git a/Sources/LCLPing/HTTP/HTTPPingClient.swift b/Sources/LCLPing/HTTP/HTTPPingClient.swift index 86bdd47..57f4a44 100644 --- a/Sources/LCLPing/HTTP/HTTPPingClient.swift +++ b/Sources/LCLPing/HTTP/HTTPPingClient.swift @@ -180,7 +180,7 @@ extension HTTPPingClient { public let resolvedAddress: SocketAddress /// The outgoing device associated with the given interface name - public var device: NIONetworkDevice? + public private(set) var device: NIONetworkDevice? /// Initialize a HTTP Ping Client `Configuration`. /// diff --git a/Sources/LCLPing/HTTP/NIOHTTPClient.swift b/Sources/LCLPing/HTTP/NIOHTTPClient.swift index c6fa3eb..f30fc58 100644 --- a/Sources/LCLPing/HTTP/NIOHTTPClient.swift +++ b/Sources/LCLPing/HTTP/NIOHTTPClient.swift @@ -214,7 +214,7 @@ final class NIOHTTPClient: Pingable { default: () } - #elseif canImport(Glibc) + #elseif canImport(Glibc) || canImport(Musl) return (channel as! SocketOptionProvider).setBindToDevice(device.name) #endif } diff --git a/Sources/LCLPing/ICMP/ICMPPingClient.swift b/Sources/LCLPing/ICMP/ICMPPingClient.swift index 7898297..513475d 100644 --- a/Sources/LCLPing/ICMP/ICMPPingClient.swift +++ b/Sources/LCLPing/ICMP/ICMPPingClient.swift @@ -190,7 +190,7 @@ public final class ICMPPingClient: Pingable { default: () } - #elseif canImport(Glibc) + #elseif canImport(Glibc) || canImport(Musl) return (channel as! SocketOptionProvider).setBindToDevice(device.name) #endif } @@ -235,7 +235,7 @@ extension ICMPPingClient { public let resolvedAddress: SocketAddress /// The outgoing device associated with the given interface name - public var device: NIONetworkDevice? + public private(set) var device: NIONetworkDevice? public init(endpoint: EndpointTarget, count: Int = 10, diff --git a/Sources/LCLPing/Utilities/LCLPing+SocketOption.swift b/Sources/LCLPing/Utilities/LCLPing+SocketOption.swift index 2e654be..158948a 100644 --- a/Sources/LCLPing/Utilities/LCLPing+SocketOption.swift +++ b/Sources/LCLPing/Utilities/LCLPing+SocketOption.swift @@ -12,18 +12,26 @@ import Foundation import NIOCore +#if canImport(Darwin) +import Darwin +#elseif canImport(Glibc) +import Glibc +#elseif canImport(Musl) +import Musl +#endif extension NIOBSDSocket.Option { #if canImport(Darwin) public static let ip_bound_if: NIOBSDSocket.Option = Self(rawValue: IP_BOUND_IF) public static let ipv6_bound_if: NIOBSDSocket.Option = Self(rawValue: IPV6_BOUND_IF) - #elseif canImport(Glibc) + #elseif canImport(Glibc) || canImport(Musl) public static let so_bindtodevice = Self(rawValue: SO_BINDTODEVICE) #endif } extension SocketOptionProvider { - #if canImport(Glibc) + #if canImport(Glibc) || canImport(Musl) + /// Sets the socket option SO_BINDTODEVICE to `value`. /// /// - parameters: