From b5c665b60236b7868833b2c1d31a7510e1b54ddc Mon Sep 17 00:00:00 2001 From: David Levanon Date: Tue, 26 Apr 2022 14:37:44 +0300 Subject: [PATCH 1/2] set capture time for every packet, so long living readers would be accurate (#1043) --- tap/tlstapper/tls_poller.go | 10 +++++----- tap/tlstapper/tls_reader.go | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tap/tlstapper/tls_poller.go b/tap/tlstapper/tls_poller.go index 7b521a9a9..dc8d103d3 100644 --- a/tap/tlstapper/tls_poller.go +++ b/tap/tlstapper/tls_poller.go @@ -131,6 +131,7 @@ func (p *tlsPoller) handleTlsChunk(chunk *tlsChunk, extension *api.Extension, p.readers[key] = reader } + reader.timer.CaptureTime = time.Now() reader.chunks <- chunk if os.Getenv("MIZU_VERBOSE_TLS_TAPPER") == "true" { @@ -150,6 +151,9 @@ func (p *tlsPoller) startNewTlsReader(chunk *tlsChunk, ip net.IP, port uint16, k p.closeReader(key, r) }, progress: &api.ReadProgress{}, + timer: api.SuperTimer{ + CaptureTime: time.Now(), + }, } tcpid := p.buildTcpId(chunk, ip, port) @@ -166,13 +170,9 @@ func (p *tlsPoller) startNewTlsReader(chunk *tlsChunk, ip net.IP, port uint16, k func dissect(extension *api.Extension, reader *tlsReader, isRequest bool, tcpid *api.TcpID, tlsEmitter *tlsEmitter, options *api.TrafficFilteringOptions, reqResMatcher api.RequestResponseMatcher) { b := bufio.NewReader(reader) - - timer := api.SuperTimer{ - CaptureTime: time.Now(), - } err := extension.Dissector.Dissect(b, reader.progress, api.Ebpf, isRequest, tcpid, &api.CounterPair{}, - &timer, &api.SuperIdentifier{}, tlsEmitter, options, reqResMatcher) + &reader.timer, &api.SuperIdentifier{}, tlsEmitter, options, reqResMatcher) if err != nil { logger.Log.Warningf("Error dissecting TLS %v - %v", tcpid, err) diff --git a/tap/tlstapper/tls_reader.go b/tap/tlstapper/tls_reader.go index 908cbf1ad..67a1fae50 100644 --- a/tap/tlstapper/tls_reader.go +++ b/tap/tlstapper/tls_reader.go @@ -13,6 +13,7 @@ type tlsReader struct { data []byte doneHandler func(r *tlsReader) progress *api.ReadProgress + timer api.SuperTimer } func (r *tlsReader) Read(p []byte) (int, error) { From ee8dce4466a09603bbfe66a007bf26a21e6f2073 Mon Sep 17 00:00:00 2001 From: lirazyehezkel <61656597+lirazyehezkel@users.noreply.github.com> Date: Tue, 26 Apr 2022 15:40:42 +0300 Subject: [PATCH 2/2] Clear entry detailed on workspace change (#1045) --- ui-common/src/components/TrafficViewer/EntryDetailed.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-common/src/components/TrafficViewer/EntryDetailed.tsx b/ui-common/src/components/TrafficViewer/EntryDetailed.tsx index a139e8209..715439ddd 100644 --- a/ui-common/src/components/TrafficViewer/EntryDetailed.tsx +++ b/ui-common/src/components/TrafficViewer/EntryDetailed.tsx @@ -110,8 +110,8 @@ export const EntryDetailed = () => { const [entryData, setEntryData] = useState(null); useEffect(() => { - if (!focusedEntryId) return; - setEntryData(null); + setEntryData(null); + if (!focusedEntryId) return; setIsLoading(true); (async () => { try {