Skip to content

Commit

Permalink
refactor(webconnectivitylte): use NewHTTPTransportWithOptions (#1494)
Browse files Browse the repository at this point in the history
There's no need to use the older NewHTTPTransport factory for creating a
new HTTP transport, because this codebase doesn't need to use any quirk
implemented by such a transport.

While there, move TODOs around the codebase.

Part of ooni/probe#2669.
  • Loading branch information
bassosimone committed Feb 8, 2024
1 parent 7a71438 commit 49382fe
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
11 changes: 2 additions & 9 deletions internal/experiment/webconnectivitylte/cleartextflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ func (t *CleartextFlow) Run(parentCtx context.Context, index int64) error {
trace := measurexlite.NewTrace(index, t.ZeroTime, fmt.Sprintf("depth=%d", t.Depth),
fmt.Sprintf("fetch_body=%v", t.PrioSelector != nil))

// TODO(bassosimone): the DSL starts measuring for throttling when we start
// fetching the body while here we start immediately. We should come up with
// a consistent policy otherwise data won't be comparable.

// start measuring throttling
sampler := throttling.NewSampler(trace)
defer func() {
Expand Down Expand Up @@ -144,10 +140,7 @@ func (t *CleartextFlow) Run(parentCtx context.Context, index int64) error {
}

// create HTTP transport
// TODO(https://github.com/ooni/probe/issues/2534): here we're using the QUIRKY netxlite.NewHTTPTransport
// function, but we can probably avoid using it, given that this code is
// not using tracing and does not care about those quirks.
httpTransport := netxlite.NewHTTPTransport(
httpTransport := netxlite.NewHTTPTransportWithOptions(
t.Logger,
netxlite.NewSingleUseDialer(tcpConn),
netxlite.NewNullTLSDialer(),
Expand Down Expand Up @@ -188,7 +181,7 @@ func (t *CleartextFlow) Run(parentCtx context.Context, index int64) error {
// if enabled, follow possible redirects
t.maybeFollowRedirects(parentCtx, httpResp)

// TODO: insert here additional code if needed
// ignore the response body
_ = httpRespBody

// completed successfully
Expand Down
11 changes: 2 additions & 9 deletions internal/experiment/webconnectivitylte/secureflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ func (t *SecureFlow) Run(parentCtx context.Context, index int64) error {
trace := measurexlite.NewTrace(index, t.ZeroTime, fmt.Sprintf("depth=%d", t.Depth),
fmt.Sprintf("fetch_body=%v", t.PrioSelector != nil))

// TODO(bassosimone): the DSL starts measuring for throttling when we start
// fetching the body while here we start immediately. We should come up with
// a consistent policy otherwise data won't be comparable.

// start measuring throttling
sampler := throttling.NewSampler(trace)
defer func() {
Expand Down Expand Up @@ -179,10 +175,7 @@ func (t *SecureFlow) Run(parentCtx context.Context, index int64) error {
}

// create HTTP transport
// TODO(https://github.com/ooni/probe/issues/2534): here we're using the QUIRKY netxlite.NewHTTPTransport
// function, but we can probably avoid using it, given that this code is
// not using tracing and does not care about those quirks.
httpTransport := netxlite.NewHTTPTransport(
httpTransport := netxlite.NewHTTPTransportWithOptions(
t.Logger,
netxlite.NewNullDialer(),
netxlite.NewSingleUseTLSDialer(tlsConn),
Expand Down Expand Up @@ -223,7 +216,7 @@ func (t *SecureFlow) Run(parentCtx context.Context, index int64) error {
// if enabled, follow possible redirects
t.maybeFollowRedirects(parentCtx, httpResp)

// TODO: insert here additional code if needed
// ignore the response body
_ = httpRespBody

// completed successfully
Expand Down
4 changes: 4 additions & 0 deletions internal/x/dslvm/quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ func (sx *QUICHandshakeStage) handshake(ctx context.Context, rtx Runtime, endpoi
return
}

// TODO(https://github.com/ooni/probe/issues/2670).
//
// Start measuring for throttling here.

// handle success
sx.Output <- &QUICConnection{Conn: quicConn, tx: trace, tlsConfig: config}
}
Expand Down
4 changes: 4 additions & 0 deletions internal/x/dslvm/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ func (sx *TCPConnectStage) connect(ctx context.Context, rtx Runtime, endpoint st
return
}

// TODO(https://github.com/ooni/probe/issues/2670).
//
// Start measuring for throttling here.

// handle success
sx.Output <- &TCPConnection{Conn: conn, tx: trace}
}
4 changes: 4 additions & 0 deletions internal/x/dslx/quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ func QUICHandshake(rt Runtime, options ...TLSHandshakeOption) Func[*Endpoint, *Q
if quicConn != nil {
closerConn = &quicCloserConn{quicConn}
tlsState = quicConn.ConnectionState().TLS // only quicConn can be nil

// TODO(https://github.com/ooni/probe/issues/2670).
//
// Start measuring for throttling here.
}

// possibly track established conn for late close
Expand Down
4 changes: 4 additions & 0 deletions internal/x/dslx/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func TCPConnect(rt Runtime) Func[*Endpoint, *TCPConnection] {
return nil, err
}

// TODO(https://github.com/ooni/probe/issues/2670).
//
// Start measuring for throttling here.

// handle success
state := &TCPConnection{
Address: input.Address,
Expand Down

0 comments on commit 49382fe

Please sign in to comment.