NIO: undo exclusion of UDS on Windows (#1437)

This is in-scope for Windows now.
This commit is contained in:
Saleem Abdulrasool 2020-03-09 10:38:10 -07:00 committed by GitHub
parent 35078406c7
commit 7103febd74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 22 deletions

View File

@ -52,12 +52,10 @@ extension UnsafeMutablePointer where Pointee == sockaddr {
return self.withMemoryRebound(to: sockaddr_in6.self, capacity: 1) {
SocketAddress($0.pointee, host: $0.pointee.addressDescription())
}
#if !os(Windows)
case Posix.AF_UNIX:
return self.withMemoryRebound(to: sockaddr_un.self, capacity: 1) {
SocketAddress($0.pointee)
}
#endif
default:
return nil
}
@ -112,7 +110,6 @@ extension sockaddr_in6: SockAddrProtocol {
}
}
#if !os(Windows)
extension sockaddr_un: SockAddrProtocol {
mutating func withSockAddr<R>(_ body: (UnsafePointer<sockaddr>, Int) throws -> R) rethrows -> R {
var me = self
@ -128,7 +125,6 @@ extension sockaddr_un: SockAddrProtocol {
}
}
}
#endif
extension sockaddr_storage: SockAddrProtocol {
mutating func withSockAddr<R>(_ body: (UnsafePointer<sockaddr>, Int) throws -> R) rethrows -> R {
@ -178,7 +174,6 @@ extension sockaddr_storage {
}
}
#if !os(Windows)
/// Converts the `socketaddr_storage` to a `sockaddr_un`.
///
/// This will crash if `ss_family` != AF_UNIX!
@ -190,7 +185,6 @@ extension sockaddr_storage {
}
}
}
#endif
/// Converts the `socketaddr_storage` to a `SocketAddress`.
mutating func convert() -> SocketAddress {
@ -408,11 +402,9 @@ class BaseSocket: Selectable, BaseSocketProtocol {
case .v6(let address):
var addr = address.address
try addr.withSockAddr({ try doBind(ptr: $0, bytes: $1) })
#if !os(Windows)
case .unixDomainSocket(let address):
var addr = address.address
try addr.withSockAddr({ try doBind(ptr: $0, bytes: $1) })
#endif
}
}
}

View File

@ -172,7 +172,6 @@ public final class ServerBootstrap {
return bind0 { address }
}
#if !os(Windows)
/// Bind the `ServerSocketChannel` to a UNIX Domain Socket.
///
/// - parameters:
@ -182,7 +181,6 @@ public final class ServerBootstrap {
try SocketAddress(unixDomainSocketPath: unixDomainSocketPath)
}
}
#endif
/// Use the existing bound socket file descriptor.
///
@ -511,7 +509,6 @@ public final class ClientBootstrap: NIOTCPClientBootstrap {
}
}
#if !os(Windows)
/// Specify the `unixDomainSocket` path to connect to for the UDS `Channel` that will be established.
///
/// - parameters:
@ -525,7 +522,6 @@ public final class ClientBootstrap: NIOTCPClientBootstrap {
return group.next().makeFailedFuture(error)
}
}
#endif
/// Use the existing connected socket file descriptor.
///
@ -698,7 +694,6 @@ public final class DatagramBootstrap {
return bind0 { address }
}
#if !os(Windows)
/// Bind the `DatagramChannel` to a UNIX Domain Socket.
///
/// - parameters:
@ -708,7 +703,6 @@ public final class DatagramBootstrap {
return try SocketAddress(unixDomainSocketPath: unixDomainSocketPath)
}
}
#endif
private func bind0(_ makeSocketAddress: () throws -> SocketAddress) -> EventLoopFuture<Channel> {
let address: SocketAddress

View File

@ -20,10 +20,8 @@ public enum SocketAddressError: Error {
case unknown(host: String, port: Int)
/// The requested `SocketAddress` is not supported.
case unsupported
#if !os(Windows)
/// The requested UDS path is too long.
case unixDomainSocketPathTooLong
#endif
/// Unable to parse a given IP string
case failedToParseIPString(String)
}
@ -61,7 +59,6 @@ public enum SocketAddress: CustomStringConvertible {
}
}
#if !os(Windows)
/// A single Unix socket address for `SocketAddress`.
public struct UnixSocketAddress {
private let _storage: Box<sockaddr_un>
@ -73,7 +70,6 @@ public enum SocketAddress: CustomStringConvertible {
self._storage = Box(address)
}
}
#endif
/// An IPv4 `SocketAddress`.
case v4(IPv4Address)
@ -81,10 +77,8 @@ public enum SocketAddress: CustomStringConvertible {
/// An IPv6 `SocketAddress`.
case v6(IPv6Address)
#if !os(Windows)
/// An UNIX Domain `SocketAddress`.
case unixDomainSocket(UnixSocketAddress)
#endif
/// A human-readable description of this `SocketAddress`. Mostly useful for logging.
public var description: String {
@ -219,7 +213,6 @@ public enum SocketAddress: CustomStringConvertible {
self = .v6(.init(address: addr, host: host))
}
#if !os(Windows)
/// Creates a new Unix Domain Socket `SocketAddress`.
///
/// - parameters:
@ -257,7 +250,6 @@ public enum SocketAddress: CustomStringConvertible {
self = .unixDomainSocket(.init(address: addr))
}
#endif
/// Create a new `SocketAddress` for an IP address in string form.
///