blob: e1d76a429b74f7530ccc6dad2d97b884b302b189 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package main
import (
"github.com/google/gopacket"
"github.com/google/gopacket/tcpassembly"
)
type BiDirectionalStreamFactory struct {
storage *Storage
serverIp string
}
// httpStream will handle the actual decoding of http requests.
type uniDirectionalStream struct {
net, transport gopacket.Flow
r StreamHandler
}
func (h *BiDirectionalStreamFactory) New(net, transport gopacket.Flow) tcpassembly.Stream {
hstream := &uniDirectionalStream{
net: net,
transport: transport,
r: NewStreamHandler(),
}
// go hstream.run() // Important... we must guarantee that data from the tcpreader stream is read.
// StreamHandler implements tcpassembly.Stream, so we can return a pointer to it.
return &hstream.r
}
|