This commit is contained in:
David Evans 2021-06-07 15:08:28 +01:00
parent f433f5e904
commit 80eeb955e3
2 changed files with 4 additions and 4 deletions

View File

@ -36,7 +36,7 @@ public class SOCKSClientHandler: ChannelDuplexHandler {
switch targetAddress { switch targetAddress {
case .address(.unixDomainSocket): case .address(.unixDomainSocket):
preconditionFailure("UNIX domain sockets are not supported.") preconditionFailure("UNIX domain sockets are not supported.")
case .domain(_, port: _), .address(.v4), .address(.v6): case .domain, .address(.v4), .address(.v6):
break break
} }
@ -81,7 +81,7 @@ public class SOCKSClientHandler: ChannelDuplexHandler {
context.write(data, promise: nil) context.write(data, promise: nil)
} }
public func writeBufferedData(context: ChannelHandlerContext) { func writeBufferedData(context: ChannelHandlerContext) {
while let (data, promise) = self.bufferedWrites.first { while let (data, promise) = self.bufferedWrites.first {
context.write(data, promise: promise) context.write(data, promise: promise)
self.bufferedWrites.removeFirst() self.bufferedWrites.removeFirst()

View File

@ -92,7 +92,7 @@ public enum AddressType: Hashable {
case .address(.unixDomainSocket): case .address(.unixDomainSocket):
fatalError("Unsupported") fatalError("Unsupported")
case .domain(let domain, port: _): case .domain(let domain, port: _):
return domain.count + 1 return domain.utf8.count + 1
} }
} }
} }
@ -174,7 +174,7 @@ extension ByteBuffer {
fatalError("UNIX domain sockets are not supported") fatalError("UNIX domain sockets are not supported")
case .domain(let domain, port: let port): case .domain(let domain, port: let port):
return self.writeInteger(UInt8(3)) return self.writeInteger(UInt8(3))
+ self.writeInteger(UInt8(domain.count)) + self.writeInteger(UInt8(domain.utf8.count))
+ self.writeString(domain) + self.writeString(domain)
+ self.writeInteger(port) + self.writeInteger(port)
} }