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:
Simone Basso
2021-06-23 13:36:45 +02:00
committed by GitHub
parent 1fefe5d9b8
commit c74c94d616
32 changed files with 78 additions and 896 deletions
@@ -22,9 +22,6 @@ import (
// uses a monotonic clock and is relative to a preconfigured "zero".
type Measurement struct {
// DNS events
//
// These are all identifed by a DialID. A ResolveEvent optionally has
// a reference to the TransactionID that started the dial, if any.
ResolveStart *ResolveStartEvent `json:",omitempty"`
DNSQuery *DNSQueryEvent `json:",omitempty"`
DNSReply *DNSReplyEvent `json:",omitempty"`
@@ -32,9 +29,6 @@ type Measurement struct {
// Syscalls
//
// These are all identified by a ConnID. A ConnectEvent has a reference
// to the DialID that caused this connection to be attempted.
//
// Because they are syscalls, we don't split them in start/done pairs
// but we record the amount of time in which we were blocked.
Connect *ConnectEvent `json:",omitempty"`
@@ -43,11 +37,6 @@ type Measurement struct {
Close *CloseEvent `json:",omitempty"`
// TLS events
//
// Identified by either ConnID or TransactionID. In the former case
// the TLS handshake is managed by net code, in the latter case it is
// instead managed by Golang's HTTP engine. It should not happen to
// have both ConnID and TransactionID different from zero.
TLSHandshakeStart *TLSHandshakeStartEvent `json:",omitempty"`
TLSHandshakeDone *TLSHandshakeDoneEvent `json:",omitempty"`
@@ -55,10 +44,6 @@ type Measurement struct {
//
// A round trip starts when we need a connection to send a request
// and ends when we've got the response headers or an error.
//
// The identifer here is TransactionID, where the transaction is
// like the round trip except that it terminates when we've finished
// reading the whole response body.
HTTPRoundTripStart *HTTPRoundTripStartEvent `json:",omitempty"`
HTTPConnectionReady *HTTPConnectionReadyEvent `json:",omitempty"`
HTTPRequestHeader *HTTPRequestHeaderEvent `json:",omitempty"`
@@ -68,10 +53,6 @@ type Measurement struct {
HTTPRoundTripDone *HTTPRoundTripDoneEvent `json:",omitempty"`
// HTTP body events
//
// They are identified by the TransactionID. You are not going to see
// these events if you don't fully read response bodies. But that's
// something you are supposed to do, so you should be fine.
HTTPResponseBodyPart *HTTPResponseBodyPartEvent `json:",omitempty"`
HTTPResponseDone *HTTPResponseDoneEvent `json:",omitempty"`
@@ -86,9 +67,6 @@ type Measurement struct {
// CloseEvent is emitted when the CLOSE syscall returns.
type CloseEvent struct {
// ConnID is the identifier of this connection.
ConnID int64
// DurationSinceBeginning is the number of nanoseconds since
// the time configured as the "zero" time.
DurationSinceBeginning time.Duration
@@ -103,13 +81,6 @@ type CloseEvent struct {
// ConnectEvent is emitted when the CONNECT syscall returns.
type ConnectEvent struct {
// ConnID is the identifier of this connection.
ConnID int64
// DialID is the identifier of the dial operation as
// part of which we called CONNECT.
DialID int64
// DurationSinceBeginning is the number of nanoseconds since
// the time configured as the "zero" time.
DurationSinceBeginning time.Duration
@@ -126,10 +97,6 @@ type ConnectEvent struct {
// SyscallDuration is the number of nanoseconds we were
// blocked waiting for the syscall to return.
SyscallDuration time.Duration
// TransactionID is the ID of the HTTP transaction that caused the
// current dial to run, or zero if there's no such transaction.
TransactionID int64 `json:",omitempty"`
}
// DNSQueryEvent is emitted when we send a DNS query.
@@ -137,10 +104,6 @@ type DNSQueryEvent struct {
// Data is the raw data we're sending to the server.
Data []byte
// DialID is the identifier of the dial operation as
// part of which we're sending this query.
DialID int64
// DurationSinceBeginning is the number of nanoseconds since
// the time configured as the "zero" time.
DurationSinceBeginning time.Duration
@@ -155,10 +118,6 @@ type DNSReplyEvent struct {
// Data is the raw data we've received and parsed.
Data []byte
// DialID is the identifier of the dial operation as
// part of which we've received this query.
DialID int64
// DurationSinceBeginning is the number of nanoseconds since
// the time configured as the "zero" time.
DurationSinceBeginning time.Duration
@@ -180,10 +139,6 @@ type ExtensionEvent struct {
// Severity of the emitted message ("WARN", "INFO", "DEBUG")
Severity string
// TransactionID is the identifier of this transaction, provided
// that we have an active one, otherwise is zero.
TransactionID int64
// Value is the extension dependent message. This message
// has the only requirement of being JSON serializable.
Value interface{}
@@ -196,12 +151,6 @@ type ExtensionEvent struct {
// "transaction" here starts with this event and does not finish
// until we have also finished receiving the response body.
type HTTPRoundTripStartEvent struct {
// DialID is the identifier of the dial operation that
// caused this round trip to start. Typically, this occures
// when doing DoH. If zero, means that this round trip has
// not been started by any dial operation.
DialID int64 `json:",omitempty"`
// DurationSinceBeginning is the number of nanoseconds since
// the time configured as the "zero" time.
DurationSinceBeginning time.Duration
@@ -209,9 +158,6 @@ type HTTPRoundTripStartEvent struct {
// Method is the request method
Method string
// TransactionID is the identifier of this transaction
TransactionID int64
// URL is the request URL
URL string
}
@@ -219,16 +165,9 @@ type HTTPRoundTripStartEvent struct {
// HTTPConnectionReadyEvent is emitted when the HTTP transport has got
// a connection which is ready for sending the request.
type HTTPConnectionReadyEvent struct {
// ConnID is the identifier of the connection that is ready. Knowing
// this ID allows you to bind HTTP events to net events.
ConnID int64
// DurationSinceBeginning is the number of nanoseconds since
// the time configured as the "zero" time.
DurationSinceBeginning time.Duration
// TransactionID is the identifier of this transaction
TransactionID int64
}
// HTTPRequestHeaderEvent is emitted when we have written a header,
@@ -241,9 +180,6 @@ type HTTPRequestHeaderEvent struct {
// Key is the header key
Key string
// TransactionID is the identifier of this transaction
TransactionID int64
// Value is the value/values of this header.
Value []string
}
@@ -264,9 +200,6 @@ type HTTPRequestHeadersDoneEvent struct {
// for the same reason of Headers.
Method string
// TransactionID is the identifier of this transaction
TransactionID int64
// URL is the original request URL. This is here
// for the same reason of Headers. We use an object
// rather than a string, because here you want to
@@ -287,9 +220,6 @@ type HTTPRequestDoneEvent struct {
// as well. This error however tells you that the issue was
// when sending the request, not when receiving the response.
Error error
// TransactionID is the identifier of this transaction
TransactionID int64
}
// HTTPResponseStartEvent is emitted when we receive the byte from
@@ -298,9 +228,6 @@ type HTTPResponseStartEvent struct {
// DurationSinceBeginning is the number of nanoseconds since
// the time configured as the "zero" time.
DurationSinceBeginning time.Duration
// TransactionID is the identifier of this transaction
TransactionID int64
}
const defaultBodySnapSize int64 = 1 << 20
@@ -368,9 +295,6 @@ type HTTPRoundTripDoneEvent struct {
// MaxBodySnapSize is the maximum size of the bodies snapshot.
MaxBodySnapSize int64
// TransactionID is the identifier of this transaction
TransactionID int64
}
// HTTPResponseBodyPartEvent is emitted after we have received
@@ -393,9 +317,6 @@ type HTTPResponseBodyPartEvent struct {
// Data is a reference to the body we've just read.
Data []byte
// TransactionID is the identifier of this transaction
TransactionID int64
}
// HTTPResponseDoneEvent is emitted after we have received the body,
@@ -407,16 +328,10 @@ type HTTPResponseDoneEvent struct {
// DurationSinceBeginning is the number of nanoseconds since
// the time configured as the "zero" time.
DurationSinceBeginning time.Duration
// TransactionID is the identifier of this transaction
TransactionID int64
}
// ReadEvent is emitted when the READ/RECV syscall returns.
type ReadEvent struct {
// ConnID is the identifier of this connection.
ConnID int64
// DurationSinceBeginning is the number of nanoseconds since
// the time configured as the "zero" time.
DurationSinceBeginning time.Duration
@@ -435,10 +350,6 @@ type ReadEvent struct {
// ResolveStartEvent is emitted when we start resolving a domain name.
type ResolveStartEvent struct {
// DialID is the identifier of the dial operation as
// part of which we're resolving this domain.
DialID int64
// DurationSinceBeginning is the number of nanoseconds since
// the time configured as the "zero" time.
DurationSinceBeginning time.Duration
@@ -446,10 +357,6 @@ type ResolveStartEvent struct {
// Hostname is the domain name to resolve.
Hostname string
// TransactionID is the ID of the HTTP transaction that caused the
// current dial to run, or zero if there's no such transaction.
TransactionID int64 `json:",omitempty"`
// TransportNetwork is the network used by the DNS transport, which
// can be one of "doh", "dot", "tcp", "udp", or "system".
TransportNetwork string
@@ -469,10 +376,6 @@ type ResolveDoneEvent struct {
// or more IP addresses that classify as bogons.
ContainsBogons bool
// DialID is the identifier of the dial operation as
// part of which we're resolving this domain.
DialID int64
// DurationSinceBeginning is the number of nanoseconds since
// the time configured as the "zero" time.
DurationSinceBeginning time.Duration
@@ -483,10 +386,6 @@ type ResolveDoneEvent struct {
// Hostname is the domain name to resolve.
Hostname string
// TransactionID is the ID of the HTTP transaction that caused the
// current dial to run, or zero if there's no such transaction.
TransactionID int64 `json:",omitempty"`
// TransportNetwork is the network used by the DNS transport, which
// can be one of "doh", "dot", "tcp", "udp", or "system".
TransportNetwork string
@@ -532,24 +431,12 @@ func SimplifyCerts(in []*x509.Certificate) (out []X509Certificate) {
// TLSHandshakeStartEvent is emitted when the TLS handshake starts.
type TLSHandshakeStartEvent struct {
// ConnID is the ID of the connection that started the TLS
// handshake, or zero if we don't know it. Typically, it is
// zero for connections managed by the HTTP transport, for
// which we know instead the TransactionID.
ConnID int64 `json:",omitempty"`
// DurationSinceBeginning is the number of nanoseconds since
// the time configured as the "zero" time.
DurationSinceBeginning time.Duration
// SNI is the SNI used when we force a specific SNI.
SNI string
// TransactionID is the ID of the transaction that started
// this TLS handshake, or zero if we don't know it. Typically,
// it is zero for explicit dials, and it's nonzero instead
// when a connection is managed by HTTP code.
TransactionID int64 `json:",omitempty"`
}
// TLSHandshakeDoneEvent is emitted when conn.Handshake returns.
@@ -558,31 +445,16 @@ type TLSHandshakeDoneEvent struct {
// error type, some fields may have little meaning.
ConnectionState TLSConnectionState
// ConnID is the ID of the connection that started the TLS
// handshake, or zero if we don't know it. Typically, it is
// zero for connections managed by the HTTP transport, for
// which we know instead the TransactionID.
ConnID int64
// DurationSinceBeginning is the number of nanoseconds since
// the time configured as the "zero" time.
DurationSinceBeginning time.Duration
// Error is the result of the TLS handshake.
Error error
// TransactionID is the ID of the transaction that started
// this TLS handshake, or zero if we don't know it. Typically,
// it is zero for explicit dials, and it's nonzero instead
// when a connection is managed by HTTP code.
TransactionID int64
}
// WriteEvent is emitted when the WRITE/SEND syscall returns.
type WriteEvent struct {
// ConnID is the identifier of this connection.
ConnID int64
// DurationSinceBeginning is the number of nanoseconds since
// the time configured as the "zero" time.
DurationSinceBeginning time.Duration