bump websocket
This commit is contained in:
parent
1f8c8b8f61
commit
373c1a3447
@ -318,6 +318,7 @@ open class WebSocket : NSObject, StreamDelegate {
|
|||||||
inStream.delegate = self
|
inStream.delegate = self
|
||||||
outStream.delegate = self
|
outStream.delegate = self
|
||||||
if supportedSSLSchemes.contains(url.scheme!) {
|
if supportedSSLSchemes.contains(url.scheme!) {
|
||||||
|
certValidated = false
|
||||||
inStream.setProperty(StreamSocketSecurityLevel.negotiatedSSL as AnyObject, forKey: Stream.PropertyKey.socketSecurityLevelKey)
|
inStream.setProperty(StreamSocketSecurityLevel.negotiatedSSL as AnyObject, forKey: Stream.PropertyKey.socketSecurityLevelKey)
|
||||||
outStream.setProperty(StreamSocketSecurityLevel.negotiatedSSL as AnyObject, forKey: Stream.PropertyKey.socketSecurityLevelKey)
|
outStream.setProperty(StreamSocketSecurityLevel.negotiatedSSL as AnyObject, forKey: Stream.PropertyKey.socketSecurityLevelKey)
|
||||||
if disableSSLCertValidation {
|
if disableSSLCertValidation {
|
||||||
@ -631,7 +632,8 @@ open class WebSocket : NSObject, StreamDelegate {
|
|||||||
return buffer.fromOffset(bufferLen - extra)
|
return buffer.fromOffset(bufferLen - extra)
|
||||||
} else {
|
} else {
|
||||||
let isFin = (FinMask & baseAddress[0])
|
let isFin = (FinMask & baseAddress[0])
|
||||||
let receivedOpcode = OpCode(rawValue: (OpCodeMask & baseAddress[0]))
|
let receivedOpcodeRawValue = (OpCodeMask & baseAddress[0])
|
||||||
|
let receivedOpcode = OpCode(rawValue: receivedOpcodeRawValue)
|
||||||
let isMasked = (MaskMask & baseAddress[1])
|
let isMasked = (MaskMask & baseAddress[1])
|
||||||
let payloadLen = (PayloadLenMask & baseAddress[1])
|
let payloadLen = (PayloadLenMask & baseAddress[1])
|
||||||
var offset = 2
|
var offset = 2
|
||||||
@ -645,7 +647,7 @@ open class WebSocket : NSObject, StreamDelegate {
|
|||||||
if !isControlFrame && (receivedOpcode != .binaryFrame && receivedOpcode != .continueFrame &&
|
if !isControlFrame && (receivedOpcode != .binaryFrame && receivedOpcode != .continueFrame &&
|
||||||
receivedOpcode != .textFrame && receivedOpcode != .pong) {
|
receivedOpcode != .textFrame && receivedOpcode != .pong) {
|
||||||
let errCode = CloseCode.protocolError.rawValue
|
let errCode = CloseCode.protocolError.rawValue
|
||||||
doDisconnect(errorWithDetail("unknown opcode: \(String(describing: receivedOpcode))", code: errCode))
|
doDisconnect(errorWithDetail("unknown opcode: \(receivedOpcodeRawValue)", code: errCode))
|
||||||
writeError(errCode)
|
writeError(errCode)
|
||||||
return emptyBuffer
|
return emptyBuffer
|
||||||
}
|
}
|
||||||
@ -690,18 +692,13 @@ open class WebSocket : NSObject, StreamDelegate {
|
|||||||
if dataLength > UInt64(bufferLen) {
|
if dataLength > UInt64(bufferLen) {
|
||||||
len = UInt64(bufferLen-offset)
|
len = UInt64(bufferLen-offset)
|
||||||
}
|
}
|
||||||
let data: Data
|
if receivedOpcode == .connectionClose && len > 0 {
|
||||||
if len < 0 {
|
let size = MemoryLayout<UInt16>.size
|
||||||
len = 0
|
offset += size
|
||||||
data = Data()
|
len -= UInt64(size)
|
||||||
} else {
|
|
||||||
if receivedOpcode == .connectionClose && len > 0 {
|
|
||||||
let size = MemoryLayout<UInt16>.size
|
|
||||||
offset += size
|
|
||||||
len -= UInt64(size)
|
|
||||||
}
|
|
||||||
data = Data(bytes: baseAddress+offset, count: Int(len))
|
|
||||||
}
|
}
|
||||||
|
let data = Data(bytes: baseAddress+offset, count: Int(len))
|
||||||
|
|
||||||
if receivedOpcode == .connectionClose {
|
if receivedOpcode == .connectionClose {
|
||||||
var closeReason = "connection closed by server"
|
var closeReason = "connection closed by server"
|
||||||
if let customCloseReason = String(data: data, encoding: .utf8) {
|
if let customCloseReason = String(data: data, encoding: .utf8) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user