mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-10-21 23:46:45 +00:00
* Define `ReadProgress` struct and update `Dissector` interface such that the `bufio.Reader` progress can be learned on item emitting * Display the `requestSize` and `responseSize` fields in the UI * Update the tests * publish ui-common version 1.0.130 and bump to this version in ui/package.json file Co-authored-by: gadotroee <55343099+gadotroee@users.noreply.github.com> Co-authored-by: Roee Gadot <roee.gadot@up9.com>
46 lines
669 B
Go
46 lines
669 B
Go
package tlstapper
|
|
|
|
import (
|
|
"io"
|
|
"time"
|
|
|
|
"github.com/up9inc/mizu/tap/api"
|
|
)
|
|
|
|
type tlsReader struct {
|
|
key string
|
|
chunks chan *tlsChunk
|
|
data []byte
|
|
doneHandler func(r *tlsReader)
|
|
progress *api.ReadProgress
|
|
}
|
|
|
|
func (r *tlsReader) Read(p []byte) (int, error) {
|
|
var chunk *tlsChunk
|
|
|
|
for len(r.data) == 0 {
|
|
var ok bool
|
|
select {
|
|
case chunk, ok = <-r.chunks:
|
|
if !ok {
|
|
return 0, io.EOF
|
|
}
|
|
|
|
r.data = chunk.getRecordedData()
|
|
case <-time.After(time.Second * 3):
|
|
r.doneHandler(r)
|
|
return 0, io.EOF
|
|
}
|
|
|
|
if len(r.data) > 0 {
|
|
break
|
|
}
|
|
}
|
|
|
|
l := copy(p, r.data)
|
|
r.data = r.data[l:]
|
|
r.progress.Feed(l)
|
|
|
|
return l, nil
|
|
}
|