Skip to content

Commit

Permalink
fix(webconnectivitylte): always save "connect" network events (#1398)
Browse files Browse the repository at this point in the history
We're not saving "connect" network events when TCP connect fails. This
diff fixes the codebase so that we always save these events.

Fix extracted from #1392.

Reference issue ooni/probe#2634.
  • Loading branch information
bassosimone authored Nov 28, 2023
1 parent c4241a0 commit 0a49338
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions internal/experiment/webconnectivitylte/cleartextflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,12 @@ func (t *CleartextFlow) Run(parentCtx context.Context, index int64) error {
tcpDialer := trace.NewDialerWithoutResolver(t.Logger)
tcpConn, err := tcpDialer.DialContext(tcpCtx, "tcp", t.Address)
t.TestKeys.AppendTCPConnectResults(trace.TCPConnects()...)
defer t.TestKeys.AppendNetworkEvents(trace.NetworkEvents()...) // here to include connect events
if err != nil {
ol.Stop(err)
return err
}
defer func() {
t.TestKeys.AppendNetworkEvents(trace.NetworkEvents()...)
tcpConn.Close()
}()
defer tcpConn.Close()

alpn := "" // no ALPN because we're not using TLS

Expand Down
6 changes: 2 additions & 4 deletions internal/experiment/webconnectivitylte/secureflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,12 @@ func (t *SecureFlow) Run(parentCtx context.Context, index int64) error {
tcpDialer := trace.NewDialerWithoutResolver(t.Logger)
tcpConn, err := tcpDialer.DialContext(tcpCtx, "tcp", t.Address)
t.TestKeys.AppendTCPConnectResults(trace.TCPConnects()...)
defer t.TestKeys.AppendNetworkEvents(trace.NetworkEvents()...) // here to include "connect" events
if err != nil {
ol.Stop(err)
return err
}
defer func() {
t.TestKeys.AppendNetworkEvents(trace.NetworkEvents()...)
tcpConn.Close()
}()
defer tcpConn.Close()

// perform TLS handshake
tlsSNI, err := t.sni()
Expand Down

0 comments on commit 0a49338

Please sign in to comment.