Have encapsulation.ReadData read into a provided buffer.

Instead of unconditionally allocating its own.
This commit is contained in:
David Fifield 2023-06-26 02:12:46 +00:00
parent 648609dbea
commit 001f691b47
4 changed files with 122 additions and 58 deletions

View file

@ -173,12 +173,13 @@ func (handler *httpHandler) turbotunnelMode(conn net.Conn, addr net.Addr) error
go func() {
defer wg.Done()
defer close(done) // Signal the write loop to finish
var p [2048]byte
for {
p, err := encapsulation.ReadData(conn)
n, err := encapsulation.ReadData(conn, p[:])
if err != nil {
return
}
pconn.QueueIncoming(p, clientID)
pconn.QueueIncoming(p[:n], clientID)
}
}()