Fix write cached packets

This commit is contained in:
世界 2023-05-01 12:41:32 +08:00
parent 7662278795
commit 8365dd48a1
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -413,7 +413,6 @@ func CopyPacketWithPool(destinationConn N.PacketWriter, source N.PacketReader, r
func WritePacketWithPool(destinationConn N.PacketWriter, packetBuffers []*N.PacketBuffer) (n int64, err error) { func WritePacketWithPool(destinationConn N.PacketWriter, packetBuffers []*N.PacketBuffer) (n int64, err error) {
frontHeadroom := N.CalculateFrontHeadroom(destinationConn) frontHeadroom := N.CalculateFrontHeadroom(destinationConn)
rearHeadroom := N.CalculateRearHeadroom(destinationConn) rearHeadroom := N.CalculateRearHeadroom(destinationConn)
var destination M.Socksaddr
for _, packetBuffer := range packetBuffers { for _, packetBuffer := range packetBuffers {
buffer := buf.NewPacket() buffer := buf.NewPacket()
readBufferRaw := buffer.Slice() readBufferRaw := buffer.Slice()
@ -426,7 +425,7 @@ func WritePacketWithPool(destinationConn N.PacketWriter, packetBuffers []*N.Pack
} }
dataLen := readBuffer.Len() dataLen := readBuffer.Len()
buffer.Resize(readBuffer.Start(), dataLen) buffer.Resize(readBuffer.Start(), dataLen)
err = destinationConn.WritePacket(buffer, destination) err = destinationConn.WritePacket(buffer, packetBuffer.Destination)
if err != nil { if err != nil {
buffer.Release() buffer.Release()
return return