Learn isClient from the TCP stream

This commit is contained in:
M. Mert Yildiran
2021-08-25 17:59:08 +03:00
parent fc7d219941
commit 10b08317f7
2 changed files with 5 additions and 7 deletions

View File

@@ -91,7 +91,7 @@ func (h *tcpReader) Read(p []byte) (int, error) {
return l, nil
}
func (h *tcpReader) run(wg *sync.WaitGroup) {
func (h *tcpReader) run(wg *sync.WaitGroup, isClient bool) {
defer wg.Done()
data, err := io.ReadAll(h)
@@ -102,9 +102,7 @@ func (h *tcpReader) run(wg *sync.WaitGroup) {
r := bytes.NewReader(data)
for _, extension := range extensions {
for _, isClient := range []bool{true, false} {
r.Reset(data)
extension.Dissector.Dissect(bufio.NewReader(r), isClient, h.tcpID, h.Emitter)
}
}
}

View File

@@ -82,8 +82,8 @@ func (factory *tcpStreamFactory) New(net, transport gopacket.Flow, tcp *layers.T
}
factory.wg.Add(2)
// Start reading from channel stream.reader.bytes
go stream.client.run(&factory.wg)
go stream.server.run(&factory.wg)
go stream.client.run(&factory.wg, true)
go stream.server.run(&factory.wg, false)
}
return stream
}