diff --git a/tun_windows.go b/tun_windows.go index 3717111..4aa27ef 100644 --- a/tun_windows.go +++ b/tun_windows.go @@ -316,11 +316,12 @@ func (e *WintunEndpoint) dispatchLoop() { if err != nil { break } - packet := make([]byte, n) - copy(packet, data[:n]) + packet := buf.NewSize(n) + common.Must1(packet.Write(data[:n])) pkt := stack.NewPacketBuffer(stack.PacketBufferOptions{ - Payload: gBuffer.NewWithData(packet), + Payload: gBuffer.NewWithData(packet.Bytes()), IsForwardedPacket: true, + OnRelease: packet.Release, }) var p tcpip.NetworkProtocolNumber ipHeader, ok := pkt.Data().PullUp(1)