Example #1
0
// @Private
func (this *DefaultDispatcher) FilterPacketAndDispatch(destination v2net.Destination, link ray.OutboundRay, dispatcher proxy.OutboundHandler) {
	payload, err := link.OutboundInput().Read()
	if err != nil {
		log.Info("DefaultDispatcher: No payload towards ", destination, ", stopping now.")
		link.OutboundInput().Release()
		link.OutboundOutput().Release()
		return
	}
	dispatcher.Dispatch(destination, payload, link)
}
Example #2
0
func (this *Point) FilterPacketAndDispatch(packet v2net.Packet, link ray.OutboundRay, dispatcher proxy.OutboundHandler) {
	// 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 {
		log.Info("Point: No payload to dispatch, stopping dispatching now.")
		close(link.OutboundOutput())
		return
	}

	if changed {
		packet = v2net.NewPacket(packet.Destination(), chunk, moreChunks)
	}

	dispatcher.Dispatch(packet, link)
}