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:
@@ -70,13 +70,10 @@ type TCPConnectStatus struct {
|
||||
// TCPConnectEntry contains one of the entries that are part
|
||||
// of the "tcp_connect" key of a OONI report.
|
||||
type TCPConnectEntry struct {
|
||||
ConnID int64 `json:"conn_id,omitempty"`
|
||||
DialID int64 `json:"dial_id,omitempty"`
|
||||
IP string `json:"ip"`
|
||||
Port int `json:"port"`
|
||||
Status TCPConnectStatus `json:"status"`
|
||||
T float64 `json:"t"`
|
||||
TransactionID int64 `json:"transaction_id,omitempty"`
|
||||
IP string `json:"ip"`
|
||||
Port int `json:"port"`
|
||||
Status TCPConnectStatus `json:"status"`
|
||||
T float64 `json:"t"`
|
||||
}
|
||||
|
||||
// NewTCPConnectList creates a new TCPConnectList
|
||||
@@ -289,11 +286,10 @@ type HTTPResponse struct {
|
||||
// RequestEntry is one of the entries that are part of
|
||||
// the "requests" key of a OONI report.
|
||||
type RequestEntry struct {
|
||||
Failure *string `json:"failure"`
|
||||
Request HTTPRequest `json:"request"`
|
||||
Response HTTPResponse `json:"response"`
|
||||
T float64 `json:"t"`
|
||||
TransactionID int64 `json:"transaction_id,omitempty"`
|
||||
Failure *string `json:"failure"`
|
||||
Request HTTPRequest `json:"request"`
|
||||
Response HTTPResponse `json:"response"`
|
||||
T float64 `json:"t"`
|
||||
}
|
||||
|
||||
func addheaders(
|
||||
@@ -382,7 +378,6 @@ type DNSAnswerEntry struct {
|
||||
// DNSQueryEntry is a DNS query with possibly an answer
|
||||
type DNSQueryEntry struct {
|
||||
Answers []DNSAnswerEntry `json:"answers"`
|
||||
DialID int64 `json:"dial_id,omitempty"`
|
||||
Engine string `json:"engine"`
|
||||
Failure *string `json:"failure"`
|
||||
Hostname string `json:"hostname"`
|
||||
@@ -391,7 +386,6 @@ type DNSQueryEntry struct {
|
||||
ResolverPort *string `json:"resolver_port"`
|
||||
ResolverAddress string `json:"resolver_address"`
|
||||
T float64 `json:"t"`
|
||||
TransactionID int64 `json:"transaction_id,omitempty"`
|
||||
}
|
||||
|
||||
type dnsQueryType string
|
||||
@@ -467,16 +461,13 @@ func (qtype dnsQueryType) makequeryentry(begin time.Time, ev trace.Event) DNSQue
|
||||
// and most fields are optional. They are only added when it makes sense
|
||||
// for them to be there _and_ we have data to show.
|
||||
type NetworkEvent struct {
|
||||
Address string `json:"address,omitempty"`
|
||||
ConnID int64 `json:"conn_id,omitempty"`
|
||||
DialID int64 `json:"dial_id,omitempty"`
|
||||
Failure *string `json:"failure"`
|
||||
NumBytes int64 `json:"num_bytes,omitempty"`
|
||||
Operation string `json:"operation"`
|
||||
Proto string `json:"proto,omitempty"`
|
||||
T float64 `json:"t"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
TransactionID int64 `json:"transaction_id,omitempty"`
|
||||
Address string `json:"address,omitempty"`
|
||||
Failure *string `json:"failure"`
|
||||
NumBytes int64 `json:"num_bytes,omitempty"`
|
||||
Operation string `json:"operation"`
|
||||
Proto string `json:"proto,omitempty"`
|
||||
T float64 `json:"t"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// NewNetworkEventsList returns a list of DNS queries.
|
||||
@@ -543,7 +534,6 @@ func NewNetworkEventsList(begin time.Time, events []trace.Event) []NetworkEvent
|
||||
// TLSHandshake contains TLS handshake data
|
||||
type TLSHandshake struct {
|
||||
CipherSuite string `json:"cipher_suite"`
|
||||
ConnID int64 `json:"conn_id,omitempty"`
|
||||
Failure *string `json:"failure"`
|
||||
NegotiatedProtocol string `json:"negotiated_protocol"`
|
||||
NoTLSVerify bool `json:"no_tls_verify"`
|
||||
@@ -552,7 +542,6 @@ type TLSHandshake struct {
|
||||
T float64 `json:"t"`
|
||||
Tags []string `json:"tags"`
|
||||
TLSVersion string `json:"tls_version"`
|
||||
TransactionID int64 `json:"transaction_id,omitempty"`
|
||||
}
|
||||
|
||||
// NewTLSHandshakesList creates a new TLSHandshakesList
|
||||
|
||||
@@ -143,12 +143,6 @@ var ErrDNSBogon = errors.New("dns: detected bogon address")
|
||||
// this structure is to properly set Failure, which is also returned by
|
||||
// the Error() method, so be one of the OONI defined strings.
|
||||
type ErrWrapper struct {
|
||||
// ConnID is the connection ID, or zero if not known.
|
||||
ConnID int64
|
||||
|
||||
// DialID is the dial ID, or zero if not known.
|
||||
DialID int64
|
||||
|
||||
// Failure is the OONI failure string. The failure strings are
|
||||
// loosely backward compatible with Measurement Kit.
|
||||
//
|
||||
@@ -181,9 +175,6 @@ type ErrWrapper struct {
|
||||
// supposed to refer to the major operation that failed.
|
||||
Operation string
|
||||
|
||||
// TransactionID is the transaction ID, or zero if not known.
|
||||
TransactionID int64
|
||||
|
||||
// WrappedErr is the error that we're wrapping.
|
||||
WrappedErr error
|
||||
}
|
||||
@@ -201,12 +192,6 @@ func (e *ErrWrapper) Unwrap() error {
|
||||
// SafeErrWrapperBuilder contains a builder for ErrWrapper that
|
||||
// is safe, i.e., behaves correctly when the error is nil.
|
||||
type SafeErrWrapperBuilder struct {
|
||||
// ConnID is the connection ID, if any
|
||||
ConnID int64
|
||||
|
||||
// DialID is the dial ID, if any
|
||||
DialID int64
|
||||
|
||||
// Error is the error, if any
|
||||
Error error
|
||||
|
||||
@@ -216,9 +201,6 @@ type SafeErrWrapperBuilder struct {
|
||||
|
||||
// Operation is the operation that failed
|
||||
Operation string
|
||||
|
||||
// TransactionID is the transaction ID, if any
|
||||
TransactionID int64
|
||||
}
|
||||
|
||||
// MaybeBuild builds a new ErrWrapper, if b.Error is not nil, and returns
|
||||
@@ -230,12 +212,9 @@ func (b SafeErrWrapperBuilder) MaybeBuild() (err error) {
|
||||
classifier = toFailureString
|
||||
}
|
||||
err = &ErrWrapper{
|
||||
ConnID: b.ConnID,
|
||||
DialID: b.DialID,
|
||||
Failure: classifier(b.Error),
|
||||
Operation: toOperationString(b.Error, b.Operation),
|
||||
TransactionID: b.TransactionID,
|
||||
WrappedErr: b.Error,
|
||||
Failure: classifier(b.Error),
|
||||
Operation: toOperationString(b.Error, b.Operation),
|
||||
WrappedErr: b.Error,
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
@@ -17,27 +17,15 @@ import (
|
||||
|
||||
func TestMaybeBuildFactory(t *testing.T) {
|
||||
err := SafeErrWrapperBuilder{
|
||||
ConnID: 1,
|
||||
DialID: 10,
|
||||
Error: errors.New("mocked error"),
|
||||
TransactionID: 100,
|
||||
Error: errors.New("mocked error"),
|
||||
}.MaybeBuild()
|
||||
var target *ErrWrapper
|
||||
if errors.As(err, &target) == false {
|
||||
t.Fatal("not the expected error type")
|
||||
}
|
||||
if target.ConnID != 1 {
|
||||
t.Fatal("wrong ConnID")
|
||||
}
|
||||
if target.DialID != 10 {
|
||||
t.Fatal("wrong DialID")
|
||||
}
|
||||
if target.Failure != "unknown_failure: mocked error" {
|
||||
t.Fatal("the failure string is wrong")
|
||||
}
|
||||
if target.TransactionID != 100 {
|
||||
t.Fatal("the transactionID is wrong")
|
||||
}
|
||||
if target.WrappedErr.Error() != "mocked error" {
|
||||
t.Fatal("the wrapped error is wrong")
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"net"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/dialid"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/dialer"
|
||||
)
|
||||
|
||||
@@ -30,7 +29,6 @@ func (d DNSDialer) DialContext(
|
||||
if tlsCfg.ServerName == "" {
|
||||
tlsCfg.ServerName = onlyhost
|
||||
}
|
||||
ctx = dialid.WithDialID(ctx)
|
||||
var addrs []string
|
||||
addrs, err = d.LookupHost(ctx, onlyhost)
|
||||
if err != nil {
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"crypto/tls"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/dialid"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
||||
)
|
||||
|
||||
@@ -18,13 +17,9 @@ type ErrorWrapperDialer struct {
|
||||
func (d ErrorWrapperDialer) DialContext(
|
||||
ctx context.Context, network string, host string,
|
||||
tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlySession, error) {
|
||||
dialID := dialid.ContextDialID(ctx)
|
||||
sess, err := d.Dialer.DialContext(ctx, network, host, tlsCfg, cfg)
|
||||
err = errorx.SafeErrWrapperBuilder{
|
||||
// ConnID does not make any sense if we've failed and the error
|
||||
// does not make any sense (and is nil) if we succeeded.
|
||||
Classifier: errorx.ClassifyQUICFailure,
|
||||
DialID: dialID,
|
||||
Error: err,
|
||||
Operation: errorx.QUICHandshakeOperation,
|
||||
}.MaybeBuild()
|
||||
|
||||
@@ -8,13 +8,12 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/dialid"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/quicdialer"
|
||||
)
|
||||
|
||||
func TestErrorWrapperFailure(t *testing.T) {
|
||||
ctx := dialid.WithDialID(context.Background())
|
||||
ctx := context.Background()
|
||||
d := quicdialer.ErrorWrapperDialer{
|
||||
Dialer: MockDialer{Sess: nil, Err: io.EOF}}
|
||||
sess, err := d.DialContext(
|
||||
@@ -33,9 +32,6 @@ func errorWrapperCheckErr(t *testing.T, err error, op string) {
|
||||
if !errors.As(err, &errWrapper) {
|
||||
t.Fatal("cannot cast to ErrWrapper")
|
||||
}
|
||||
if errWrapper.DialID == 0 {
|
||||
t.Fatal("unexpected DialID")
|
||||
}
|
||||
if errWrapper.Operation != op {
|
||||
t.Fatal("unexpected Operation")
|
||||
}
|
||||
@@ -68,7 +64,7 @@ func TestErrorWrapperInvalidCertificate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestErrorWrapperSuccess(t *testing.T) {
|
||||
ctx := dialid.WithDialID(context.Background())
|
||||
ctx := context.Background()
|
||||
tlsConf := &tls.Config{
|
||||
NextProtos: []string{"h3"},
|
||||
ServerName: "www.google.com",
|
||||
|
||||
@@ -4,9 +4,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/dialid"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/transactionid"
|
||||
)
|
||||
|
||||
// EmitterTransport is a RoundTripper that emits events when they occur.
|
||||
@@ -20,8 +18,7 @@ func (txp EmitterTransport) RoundTrip(ctx context.Context, querydata []byte) ([]
|
||||
root.Handler.OnMeasurement(modelx.Measurement{
|
||||
DNSQuery: &modelx.DNSQueryEvent{
|
||||
Data: querydata,
|
||||
DialID: dialid.ContextDialID(ctx),
|
||||
DurationSinceBeginning: time.Now().Sub(root.Beginning),
|
||||
DurationSinceBeginning: time.Since(root.Beginning),
|
||||
},
|
||||
})
|
||||
replydata, err := txp.RoundTripper.RoundTrip(ctx, querydata)
|
||||
@@ -31,8 +28,7 @@ func (txp EmitterTransport) RoundTrip(ctx context.Context, querydata []byte) ([]
|
||||
root.Handler.OnMeasurement(modelx.Measurement{
|
||||
DNSReply: &modelx.DNSReplyEvent{
|
||||
Data: replydata,
|
||||
DialID: dialid.ContextDialID(ctx),
|
||||
DurationSinceBeginning: time.Now().Sub(root.Beginning),
|
||||
DurationSinceBeginning: time.Since(root.Beginning),
|
||||
},
|
||||
})
|
||||
return replydata, nil
|
||||
@@ -56,15 +52,11 @@ func (r EmitterResolver) LookupHost(ctx context.Context, hostname string) ([]str
|
||||
txp := qr.Transport()
|
||||
network, address = txp.Network(), txp.Address()
|
||||
}
|
||||
dialID := dialid.ContextDialID(ctx)
|
||||
txID := transactionid.ContextTransactionID(ctx)
|
||||
root := modelx.ContextMeasurementRootOrDefault(ctx)
|
||||
root.Handler.OnMeasurement(modelx.Measurement{
|
||||
ResolveStart: &modelx.ResolveStartEvent{
|
||||
DialID: dialID,
|
||||
DurationSinceBeginning: time.Now().Sub(root.Beginning),
|
||||
DurationSinceBeginning: time.Since(root.Beginning),
|
||||
Hostname: hostname,
|
||||
TransactionID: txID,
|
||||
TransportAddress: address,
|
||||
TransportNetwork: network,
|
||||
},
|
||||
@@ -73,11 +65,9 @@ func (r EmitterResolver) LookupHost(ctx context.Context, hostname string) ([]str
|
||||
root.Handler.OnMeasurement(modelx.Measurement{
|
||||
ResolveDone: &modelx.ResolveDoneEvent{
|
||||
Addresses: addrs,
|
||||
DialID: dialID,
|
||||
DurationSinceBeginning: time.Now().Sub(root.Beginning),
|
||||
DurationSinceBeginning: time.Since(root.Beginning),
|
||||
Error: err,
|
||||
Hostname: hostname,
|
||||
TransactionID: txID,
|
||||
TransportAddress: address,
|
||||
TransportNetwork: network,
|
||||
},
|
||||
|
||||
@@ -10,16 +10,13 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/dialid"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/handlers"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/transactionid"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/resolver"
|
||||
)
|
||||
|
||||
func TestEmitterTransportSuccess(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx = dialid.WithDialID(ctx)
|
||||
handler := &handlers.SavingHandler{}
|
||||
root := &modelx.MeasurementRoot{
|
||||
Beginning: time.Now(),
|
||||
@@ -48,9 +45,6 @@ func TestEmitterTransportSuccess(t *testing.T) {
|
||||
if !bytes.Equal(events[0].DNSQuery.Data, querydata) {
|
||||
t.Fatal("invalid query data")
|
||||
}
|
||||
if events[0].DNSQuery.DialID == 0 {
|
||||
t.Fatal("invalid query DialID")
|
||||
}
|
||||
if events[0].DNSQuery.DurationSinceBeginning <= 0 {
|
||||
t.Fatal("invalid duration since beginning")
|
||||
}
|
||||
@@ -60,9 +54,6 @@ func TestEmitterTransportSuccess(t *testing.T) {
|
||||
if !bytes.Equal(events[1].DNSReply.Data, replydata) {
|
||||
t.Fatal("missing reply data")
|
||||
}
|
||||
if events[1].DNSReply.DialID != 1 {
|
||||
t.Fatal("invalid query DialID")
|
||||
}
|
||||
if events[1].DNSReply.DurationSinceBeginning <= 0 {
|
||||
t.Fatal("invalid duration since beginning")
|
||||
}
|
||||
@@ -70,7 +61,6 @@ func TestEmitterTransportSuccess(t *testing.T) {
|
||||
|
||||
func TestEmitterTransportFailure(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx = dialid.WithDialID(ctx)
|
||||
handler := &handlers.SavingHandler{}
|
||||
root := &modelx.MeasurementRoot{
|
||||
Beginning: time.Now(),
|
||||
@@ -103,9 +93,6 @@ func TestEmitterTransportFailure(t *testing.T) {
|
||||
if !bytes.Equal(events[0].DNSQuery.Data, querydata) {
|
||||
t.Fatal("invalid query data")
|
||||
}
|
||||
if events[0].DNSQuery.DialID == 0 {
|
||||
t.Fatal("invalid query DialID")
|
||||
}
|
||||
if events[0].DNSQuery.DurationSinceBeginning <= 0 {
|
||||
t.Fatal("invalid duration since beginning")
|
||||
}
|
||||
@@ -113,8 +100,6 @@ func TestEmitterTransportFailure(t *testing.T) {
|
||||
|
||||
func TestEmitterResolverFailure(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx = dialid.WithDialID(ctx)
|
||||
ctx = transactionid.WithTransactionID(ctx)
|
||||
handler := &handlers.SavingHandler{}
|
||||
root := &modelx.MeasurementRoot{
|
||||
Beginning: time.Now(),
|
||||
@@ -143,18 +128,12 @@ func TestEmitterResolverFailure(t *testing.T) {
|
||||
if events[0].ResolveStart == nil {
|
||||
t.Fatal("missing ResolveStart field")
|
||||
}
|
||||
if events[0].ResolveStart.DialID == 0 {
|
||||
t.Fatal("invalid DialID")
|
||||
}
|
||||
if events[0].ResolveStart.DurationSinceBeginning <= 0 {
|
||||
t.Fatal("invalid duration since beginning")
|
||||
}
|
||||
if events[0].ResolveStart.Hostname != "www.google.com" {
|
||||
t.Fatal("invalid Hostname")
|
||||
}
|
||||
if events[0].ResolveStart.TransactionID == 0 {
|
||||
t.Fatal("invalid TransactionID")
|
||||
}
|
||||
if events[0].ResolveStart.TransportAddress != "https://dns.google.com/" {
|
||||
t.Fatal("invalid TransportAddress")
|
||||
}
|
||||
@@ -164,9 +143,6 @@ func TestEmitterResolverFailure(t *testing.T) {
|
||||
if events[1].ResolveDone == nil {
|
||||
t.Fatal("missing ResolveDone field")
|
||||
}
|
||||
if events[1].ResolveDone.DialID == 0 {
|
||||
t.Fatal("invalid DialID")
|
||||
}
|
||||
if events[1].ResolveDone.DurationSinceBeginning <= 0 {
|
||||
t.Fatal("invalid duration since beginning")
|
||||
}
|
||||
@@ -176,9 +152,6 @@ func TestEmitterResolverFailure(t *testing.T) {
|
||||
if events[1].ResolveDone.Hostname != "www.google.com" {
|
||||
t.Fatal("invalid Hostname")
|
||||
}
|
||||
if events[1].ResolveDone.TransactionID == 0 {
|
||||
t.Fatal("invalid TransactionID")
|
||||
}
|
||||
if events[1].ResolveDone.TransportAddress != "https://dns.google.com/" {
|
||||
t.Fatal("invalid TransportAddress")
|
||||
}
|
||||
@@ -189,8 +162,6 @@ func TestEmitterResolverFailure(t *testing.T) {
|
||||
|
||||
func TestEmitterResolverSuccess(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx = dialid.WithDialID(ctx)
|
||||
ctx = transactionid.WithTransactionID(ctx)
|
||||
handler := &handlers.SavingHandler{}
|
||||
root := &modelx.MeasurementRoot{
|
||||
Beginning: time.Now(),
|
||||
|
||||
@@ -3,8 +3,6 @@ package resolver
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/dialid"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/transactionid"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
||||
)
|
||||
|
||||
@@ -15,15 +13,11 @@ type ErrorWrapperResolver struct {
|
||||
|
||||
// LookupHost implements Resolver.LookupHost
|
||||
func (r ErrorWrapperResolver) LookupHost(ctx context.Context, hostname string) ([]string, error) {
|
||||
dialID := dialid.ContextDialID(ctx)
|
||||
txID := transactionid.ContextTransactionID(ctx)
|
||||
addrs, err := r.Resolver.LookupHost(ctx, hostname)
|
||||
err = errorx.SafeErrWrapperBuilder{
|
||||
Classifier: errorx.ClassifyResolveFailure,
|
||||
DialID: dialID,
|
||||
Error: err,
|
||||
Operation: errorx.ResolveOperation,
|
||||
TransactionID: txID,
|
||||
Classifier: errorx.ClassifyResolveFailure,
|
||||
Error: err,
|
||||
Operation: errorx.ResolveOperation,
|
||||
}.MaybeBuild()
|
||||
return addrs, err
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/dialid"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/transactionid"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/resolver"
|
||||
)
|
||||
@@ -30,8 +28,6 @@ func TestErrorWrapperFailure(t *testing.T) {
|
||||
Resolver: resolver.NewFakeResolverThatFails(),
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx = dialid.WithDialID(ctx)
|
||||
ctx = transactionid.WithTransactionID(ctx)
|
||||
addrs, err := r.LookupHost(ctx, "dns.google.com")
|
||||
if addrs != nil {
|
||||
t.Fatal("expected nil addr here")
|
||||
@@ -43,15 +39,6 @@ func TestErrorWrapperFailure(t *testing.T) {
|
||||
if errWrapper.Failure != errorx.FailureDNSNXDOMAINError {
|
||||
t.Fatal("unexpected failure")
|
||||
}
|
||||
if errWrapper.ConnID != 0 {
|
||||
t.Fatal("unexpected ConnID")
|
||||
}
|
||||
if errWrapper.DialID == 0 {
|
||||
t.Fatal("unexpected DialID")
|
||||
}
|
||||
if errWrapper.TransactionID == 0 {
|
||||
t.Fatal("unexpected TransactionID")
|
||||
}
|
||||
if errWrapper.Operation != errorx.ResolveOperation {
|
||||
t.Fatal("unexpected Operation")
|
||||
}
|
||||
|
||||
@@ -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