1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-02-09 09:45:44 -05:00

Fix for empty packets

This commit is contained in:
v2ray
2016-01-05 12:08:16 +01:00
parent 7c64093a7a
commit b9c3f2cb75
2 changed files with 35 additions and 10 deletions

View File

@@ -171,3 +171,24 @@ func (this *Point) DispatchToOutbound(context app.Context, packet v2net.Packet)
go this.och.Dispatch(packet, direct)
return direct
}
func (this *Point) FilterPacketAndDispatch(packet v2net.Packet, link ray.OutboundRay, dispatcher proxy.OutboundConnectionHandler) {
// Filter empty packets
chunk := packet.Chunk()
moreChunks := packet.MoreChunks()
changed := false
for chunk == nil && moreChunks {
changed = true
chunk, moreChunks = <-link.OutboundInput()
}
if chunk == nil && !moreChunks {
close(link.OutboundOutput())
return
}
if changed {
packet = v2net.NewPacket(packet.Destination(), chunk, moreChunks)
}
dispatcher.Dispatch(packet, link)
}