Revert CommonPacket name to ControlPacket

This commit is contained in:
Davide De Rosa 2018-09-08 13:13:14 +02:00
parent 856fa9e12e
commit 92dbb57666
2 changed files with 8 additions and 7 deletions

View File

@ -98,7 +98,7 @@ public class PacketStream {
}
}
class CommonPacket {
class ControlPacket {
let packetId: UInt32
let code: PacketCode
@ -123,7 +123,8 @@ class CommonPacket {
// Ruby: send_ctrl
func toBuffer() -> Data {
var raw = PacketWithHeader(code, key, sessionId)
raw.append(UInt8(0))
// TODO: put HMAC here when tls-auth
raw.append(UInt8(0)) // ackSize
raw.append(UInt32(packetId).bigEndian)
if let payload = payload {
raw.append(payload)

View File

@ -159,9 +159,9 @@ public class SessionProxy {
private let controlPlainBuffer: ZeroingData
private var controlQueueOut: [CommonPacket]
private var controlQueueOut: [ControlPacket]
private var controlQueueIn: [CommonPacket]
private var controlQueueIn: [ControlPacket]
private var controlPendingAcks: Set<UInt32>
@ -544,7 +544,7 @@ public class SessionProxy {
}
}
let controlPacket = CommonPacket(packetId, code, key, sessionId, payload)
let controlPacket = ControlPacket(packetId, code, key, sessionId, payload)
controlQueueIn.append(controlPacket)
controlQueueIn.sort { $0.packetId < $1.packetId }
@ -750,7 +750,7 @@ public class SessionProxy {
// MARK: Control
// Ruby: handle_ctrl_pkt
private func handleControlPacket(_ packet: CommonPacket) {
private func handleControlPacket(_ packet: ControlPacket) {
guard (packet.key == negotiationKey.id) else {
log.error("Bad key in control packet (\(packet.key) != \(negotiationKey.id))")
// deferStop(.shutdown, SessionError.badKey)
@ -955,7 +955,7 @@ public class SessionProxy {
repeat {
let subPayloadLength = min(maxCount, payload.count - offset)
let subPayloadData = payload.subdata(offset: offset, count: subPayloadLength)
let packet = CommonPacket(controlPacketIdOut, code, key, sessionId, subPayloadData)
let packet = ControlPacket(controlPacketIdOut, code, key, sessionId, subPayloadData)
controlQueueOut.append(packet)
controlPacketIdOut += 1