예제 #1
0
func NewStream(tap *Wiretap, netFlow, tcpFlow gopacket.Flow) *Stream {
	return &Stream{
		ReaderStream: tcpreader.NewReaderStream(),
		tap:          tap,
		flow:         netFlow,
	}
}
예제 #2
0
파일: main.go 프로젝트: dazer-chen/gopacket
func (h *httpStreamFactory) New(net, transport gopacket.Flow) tcpassembly.Stream {
	hstream := &httpStream{
		net:       net,
		transport: transport,
		r:         tcpreader.NewReaderStream(),
	}
	go hstream.run() // Important... we must guarantee that data from the reader stream is read.

	// ReaderStream implements tcpassembly.Stream, so we can return a pointer to it.
	return &hstream.r
}
예제 #3
0
파일: main.go 프로젝트: kyleconroy/coiltap
func (f httpStreamFactory) New(net, transport gopacket.Flow) tcpassembly.Stream {
	src := transport.Src().String()
	if src == strconv.Itoa(f.port) {
		hstream := &responseStream{
			net:       net,
			transport: transport,
			r:         tcpreader.NewReaderStream(),
		}
		go hstream.run()
		return &hstream.r
	} else {
		hstream := &requestStream{
			net:       net,
			transport: transport,
			r:         tcpreader.NewReaderStream(),
		}
		go hstream.run()
		return &hstream.r
	}
}