1
0
mirror of https://github.com/apple/swift-nio-extras.git synced 2025-05-22 05:19:34 +08:00

Adopt Sendable in NIOSOCKS ()

Incremental `Sendable` adoption.

Co-authored-by: Cory Benfield <lukasa@apple.com>
This commit is contained in:
David Nadoba 2022-08-23 14:28:01 +02:00 committed by GitHub
parent 1ef46c0352
commit b64e59956e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 23 additions and 11 deletions

@ -114,6 +114,11 @@ public final class SOCKSClientHandler: ChannelDuplexHandler {
}
}
#if swift(>=5.6)
@available(*, unavailable)
extension SOCKSClientHandler: Sendable {}
#endif
extension SOCKSClientHandler {
private func beginHandshake(context: ChannelHandlerContext) {
@ -207,7 +212,7 @@ extension SOCKSClientHandler: RemovableChannelHandler {
/// A `Channel` user event that is sent when a SOCKS connection has been established
///
/// After this event has been received it is save to remove the `SOCKSClientHandler` from the channel pipeline.
public struct SOCKSProxyEstablishedEvent {
public struct SOCKSProxyEstablishedEvent: NIOSendable {
public init() {
}
}

@ -121,3 +121,8 @@ public final class SOCKSServerHandshakeHandler: ChannelDuplexHandler, RemovableC
}
}
#if swift(>=5.6)
@available(*, unavailable)
extension SOCKSServerHandshakeHandler: Sendable {}
#endif

@ -12,8 +12,10 @@
//
//===----------------------------------------------------------------------===//
import NIOCore
/// The SOCKS authentication method to use, defined in RFC 1928.
public struct AuthenticationMethod: Hashable {
public struct AuthenticationMethod: Hashable, NIOSendable {
/// No authentication required
public static let noneRequired = AuthenticationMethod(value: 0x00)

@ -17,7 +17,7 @@ import NIOCore
/// Clients begin the SOCKS handshake process
/// by providing an array of suggested authentication
/// methods.
public struct ClientGreeting: Hashable {
public struct ClientGreeting: Hashable, NIOSendable {
/// The protocol version.
public let version: UInt8 = 5

@ -15,7 +15,7 @@
import NIOCore
/// Sent by the client and received by the server.
public enum ClientMessage: Hashable {
public enum ClientMessage: Hashable, NIOSendable {
/// Contains the proposed authentication methods.
case greeting(ClientGreeting)
@ -28,7 +28,7 @@ public enum ClientMessage: Hashable {
}
/// Sent by the server and received by the client.
public enum ServerMessage: Hashable {
public enum ServerMessage: Hashable, NIOSendable {
/// Used by the server to instruct the client of the authentication method to use.
case selectedAuthenticationMethod(SelectedAuthenticationMethod)

@ -24,7 +24,7 @@ import NIOCore
/// Instructs the SOCKS proxy server of the target host,
/// and how to connect.
public struct SOCKSRequest: Hashable {
public struct SOCKSRequest: Hashable, NIOSendable {
/// The SOCKS protocol version - we currently only support v5.
public let version: UInt8 = 5
@ -75,7 +75,7 @@ extension ByteBuffer {
/// What type of connection the SOCKS server should establish with
/// the target host.
public struct SOCKSCommand: Hashable {
public struct SOCKSCommand: Hashable, NIOSendable {
/// Typically the primary connection type, suitable for HTTP.
public static let connect = SOCKSCommand(value: 0x01)
@ -99,7 +99,7 @@ public struct SOCKSCommand: Hashable {
// MARK: - SOCKSAddress
/// The address used to connect to the target host.
public enum SOCKSAddress: Hashable {
public enum SOCKSAddress: Hashable, NIOSendable {
/// Socket Adress
case address(SocketAddress)
/// Host and port

@ -18,7 +18,7 @@ import NIOCore
/// The SOCKS Server's response to the client's request
/// indicating if the request succeeded or failed.
public struct SOCKSResponse: Hashable {
public struct SOCKSResponse: Hashable, NIOSendable {
/// The SOCKS protocol version - we currently only support v5.
public let version: UInt8 = 5
@ -69,7 +69,7 @@ extension ByteBuffer {
/// Used to indicate if the SOCKS client's connection request succeeded
/// or failed.
public struct SOCKSServerReply: Hashable {
public struct SOCKSServerReply: Hashable, NIOSendable {
/// The connection succeeded and data can now be transmitted.
public static let succeeded = SOCKSServerReply(value: 0x00)

@ -17,7 +17,7 @@ import NIOCore
/// Used by the SOCKS server to inform the client which
/// authentication method it would like to use out of those
/// offered.
public struct SelectedAuthenticationMethod: Hashable {
public struct SelectedAuthenticationMethod: Hashable, NIOSendable {
/// The SOCKS protocol version - we currently only support v5.
public let version: UInt8 = 5