示例#1
0
func (this *UDPServer) handleConnection(destString string, inboundRay ray.InboundRay, source v2net.Destination, callback UDPResponseCallback) {
	for buffer := range inboundRay.InboundOutput() {
		callback(v2net.NewPacket(source, buffer, false))
	}
	this.Lock()
	delete(this.conns, destString)
	this.Unlock()
}
示例#2
0
func (this *HttpProxyServer) transport(input io.Reader, output io.Writer, ray ray.InboundRay) {
	var wg sync.WaitGroup
	wg.Add(2)
	defer wg.Wait()

	go func() {
		v2io.RawReaderToChan(ray.InboundInput(), input)
		close(ray.InboundInput())
		wg.Done()
	}()

	go func() {
		v2io.ChanToWriter(output, ray.InboundOutput())
		wg.Done()
	}()
}
示例#3
0
func (this *Server) transport(input io.Reader, output io.Writer, ray ray.InboundRay) {
	var wg sync.WaitGroup
	wg.Add(2)
	defer wg.Wait()

	go func() {
		v2reader := v2io.NewAdaptiveReader(input)
		defer v2reader.Release()

		v2io.Pipe(v2reader, ray.InboundInput())
		ray.InboundInput().Close()
		wg.Done()
	}()

	go func() {
		v2writer := v2io.NewAdaptiveWriter(output)
		defer v2writer.Release()

		v2io.Pipe(ray.InboundOutput(), v2writer)
		ray.InboundOutput().Release()
		wg.Done()
	}()
}