Use buffer for windows packet

This commit is contained in:
世界 2022-08-03 19:16:50 +08:00
parent 9fad6b0cf3
commit a116134e5b
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -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)