Move control data parsing

This commit is contained in:
Davide De Rosa 2018-09-09 17:25:54 +02:00
parent 19ce7de819
commit e6dd4de472
2 changed files with 8 additions and 5 deletions

View File

@ -35,7 +35,7 @@ class ControlChannel {
private var pendingAcks: Set<UInt32>
private(set) var plainBuffer: ZeroingData
private var plainBuffer: ZeroingData
private var dataCount: BidirectionalState<Int>
@ -59,6 +59,12 @@ class ControlChannel {
return !pendingAcks.isEmpty
}
func currentControlData(withTLS tls: TLSBox) throws -> ZeroingData {
var length = 0
try tls.pullRawPlainText(plainBuffer.mutableBytes, length: &length)
return plainBuffer.withOffset(0, count: length)
}
func addReceivedDataCount(_ count: Int) {
dataCount.inbound += count
}

View File

@ -806,10 +806,7 @@ public class SessionProxy {
}
do {
var length = 0
try negotiationKey.tls.pullRawPlainText(controlChannel.plainBuffer.mutableBytes, length: &length)
let controlData = controlChannel.plainBuffer.withOffset(0, count: length)
let controlData = try controlChannel.currentControlData(withTLS: negotiationKey.tls)
handleControlData(controlData)
} catch _ {
}