cleanup: remove ConnID, DialID, TransactionID (#395)
We are not using them anymore. The only nettest still using the legacy netx implementation is tor, for which setting these fields is useless, because it performs each measurement into a separate goroutine. Hence, let us start removing this part of the legacy netx codebase, which is hampering progress in other areas. Occurred to me while doing testing for the recent changes in error mapping (https://github.com/ooni/probe/issues/1505).
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/connid"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
||||
)
|
||||
@@ -68,11 +67,9 @@ type ErrorWrapperTLSHandshaker struct {
|
||||
func (h ErrorWrapperTLSHandshaker) Handshake(
|
||||
ctx context.Context, conn net.Conn, config *tls.Config,
|
||||
) (net.Conn, tls.ConnectionState, error) {
|
||||
connID := connid.Compute(conn.RemoteAddr().Network(), conn.RemoteAddr().String())
|
||||
tlsconn, state, err := h.TLSHandshaker.Handshake(ctx, conn, config)
|
||||
err = errorx.SafeErrWrapperBuilder{
|
||||
Classifier: errorx.ClassifyTLSFailure,
|
||||
ConnID: connID,
|
||||
Error: err,
|
||||
Operation: errorx.TLSHandshakeOperation,
|
||||
}.MaybeBuild()
|
||||
@@ -88,22 +85,19 @@ type EmitterTLSHandshaker struct {
|
||||
func (h EmitterTLSHandshaker) Handshake(
|
||||
ctx context.Context, conn net.Conn, config *tls.Config,
|
||||
) (net.Conn, tls.ConnectionState, error) {
|
||||
connID := connid.Compute(conn.RemoteAddr().Network(), conn.RemoteAddr().String())
|
||||
root := modelx.ContextMeasurementRootOrDefault(ctx)
|
||||
root.Handler.OnMeasurement(modelx.Measurement{
|
||||
TLSHandshakeStart: &modelx.TLSHandshakeStartEvent{
|
||||
ConnID: connID,
|
||||
DurationSinceBeginning: time.Now().Sub(root.Beginning),
|
||||
DurationSinceBeginning: time.Since(root.Beginning),
|
||||
SNI: config.ServerName,
|
||||
},
|
||||
})
|
||||
tlsconn, state, err := h.TLSHandshaker.Handshake(ctx, conn, config)
|
||||
root.Handler.OnMeasurement(modelx.Measurement{
|
||||
TLSHandshakeDone: &modelx.TLSHandshakeDoneEvent{
|
||||
ConnID: connID,
|
||||
ConnectionState: modelx.NewTLSConnectionState(state),
|
||||
Error: err,
|
||||
DurationSinceBeginning: time.Now().Sub(root.Beginning),
|
||||
DurationSinceBeginning: time.Since(root.Beginning),
|
||||
},
|
||||
})
|
||||
return tlsconn, state, err
|
||||
|
||||
@@ -109,9 +109,6 @@ func TestErrorWrapperTLSHandshakerFailure(t *testing.T) {
|
||||
if !errors.As(err, &errWrapper) {
|
||||
t.Fatal("cannot cast to ErrWrapper")
|
||||
}
|
||||
if errWrapper.ConnID == 0 {
|
||||
t.Fatal("unexpected ConnID")
|
||||
}
|
||||
if errWrapper.Failure != errorx.FailureEOFError {
|
||||
t.Fatal("unexpected Failure")
|
||||
}
|
||||
@@ -143,9 +140,6 @@ func TestEmitterTLSHandshakerFailure(t *testing.T) {
|
||||
if events[0].TLSHandshakeStart == nil {
|
||||
t.Fatal("missing TLSHandshakeStart event")
|
||||
}
|
||||
if events[0].TLSHandshakeStart.ConnID == 0 {
|
||||
t.Fatal("expected nonzero ConnID")
|
||||
}
|
||||
if events[0].TLSHandshakeStart.DurationSinceBeginning == 0 {
|
||||
t.Fatal("expected nonzero DurationSinceBeginning")
|
||||
}
|
||||
@@ -155,9 +149,6 @@ func TestEmitterTLSHandshakerFailure(t *testing.T) {
|
||||
if events[1].TLSHandshakeDone == nil {
|
||||
t.Fatal("missing TLSHandshakeDone event")
|
||||
}
|
||||
if events[1].TLSHandshakeDone.ConnID == 0 {
|
||||
t.Fatal("expected nonzero ConnID")
|
||||
}
|
||||
if events[1].TLSHandshakeDone.DurationSinceBeginning == 0 {
|
||||
t.Fatal("expected nonzero DurationSinceBeginning")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user