simplify content storage in packed packets

It's not necessary to store both the packetBuffer and the slice
containing the raw data in the packet.
This commit is contained in:
Marten Seemann
2020-02-11 11:50:57 +07:00
parent 077504f557
commit d642bf9098
10 changed files with 112 additions and 103 deletions

View File

@@ -218,7 +218,7 @@ func (h *packetHandlerMap) listen() {
defer close(h.listening)
for {
buffer := getPacketBuffer()
data := buffer.Slice
data := buffer.Data[:protocol.MaxReceivePacketSize]
// The packet size should not exceed protocol.MaxReceivePacketSize bytes
// If it does, we only read a truncated packet, which will then end up undecryptable
n, addr, err := h.conn.ReadFrom(data)