Add MSG_SYS_END to all sent packets

This commit is contained in:
Andrew Gutekanst
2020-02-05 05:00:20 -05:00
parent 4e1cef9bf3
commit d4370c66ad

View File

@@ -93,11 +93,20 @@ func (s *Session) sendLoop() {
for {
// TODO(Andoryuuta): Test making this into a buffered channel and grouping the packet together before sending.
rawPacket := <-s.sendPackets
if rawPacket == nil {
s.logger.Debug("Got nil from s.SendPackets, exiting send loop")
return
}
s.cryptConn.SendPacket(rawPacket)
// Make a copy of the data.
terminatedPacket := make([]byte, len(rawPacket))
copy(terminatedPacket, rawPacket)
// Append the MSG_SYS_END tailing opcode.
terminatedPacket = append(terminatedPacket, []byte{0x00, 0x10}...)
s.cryptConn.SendPacket(terminatedPacket)
}
}