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:
@@ -63,13 +63,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"`
|
||||
}
|
||||
|
||||
// TCPConnectList is a list of TCPConnectEntry
|
||||
@@ -83,16 +80,13 @@ func NewTCPConnectList(results oonitemplates.Results) TCPConnectList {
|
||||
ip, sport, _ := net.SplitHostPort(connect.RemoteAddress)
|
||||
iport, _ := strconv.Atoi(sport)
|
||||
out = append(out, TCPConnectEntry{
|
||||
ConnID: connect.ConnID,
|
||||
DialID: connect.DialID,
|
||||
IP: ip,
|
||||
Port: iport,
|
||||
IP: ip,
|
||||
Port: iport,
|
||||
Status: TCPConnectStatus{
|
||||
Failure: makeFailure(connect.Error),
|
||||
Success: connect.Error == nil,
|
||||
},
|
||||
T: connect.DurationSinceBeginning.Seconds(),
|
||||
TransactionID: connect.TransactionID,
|
||||
T: connect.DurationSinceBeginning.Seconds(),
|
||||
})
|
||||
}
|
||||
return out
|
||||
@@ -259,10 +253,9 @@ 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"`
|
||||
TransactionID int64 `json:"transaction_id,omitempty"`
|
||||
Failure *string `json:"failure"`
|
||||
Request HTTPRequest `json:"request"`
|
||||
Response HTTPResponse `json:"response"`
|
||||
}
|
||||
|
||||
// RequestList is a list of RequestEntry
|
||||
@@ -316,7 +309,6 @@ func NewRequestList(results oonitemplates.Results) RequestList {
|
||||
entry.Response.Body.Value = string(in[idx].ResponseBodySnap)
|
||||
entry.Response.BodyIsTruncated = in[idx].MaxBodySnapSize > 0 &&
|
||||
int64(len(in[idx].ResponseBodySnap)) >= in[idx].MaxBodySnapSize
|
||||
entry.TransactionID = in[idx].TransactionID
|
||||
out = append(out, entry)
|
||||
}
|
||||
return out
|
||||
@@ -334,7 +326,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"`
|
||||
@@ -343,7 +334,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 (
|
||||
@@ -393,28 +383,23 @@ func (qtype dnsQueryType) makeanswerentry(addr string) DNSAnswerEntry {
|
||||
|
||||
func (qtype dnsQueryType) makequeryentry(resolve *modelx.ResolveDoneEvent) DNSQueryEntry {
|
||||
return DNSQueryEntry{
|
||||
DialID: resolve.DialID,
|
||||
Engine: resolve.TransportNetwork,
|
||||
Failure: makeFailure(resolve.Error),
|
||||
Hostname: resolve.Hostname,
|
||||
QueryType: string(qtype),
|
||||
ResolverAddress: resolve.TransportAddress,
|
||||
T: resolve.DurationSinceBeginning.Seconds(),
|
||||
TransactionID: resolve.TransactionID,
|
||||
}
|
||||
}
|
||||
|
||||
// NetworkEvent is a network event.
|
||||
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"`
|
||||
T float64 `json:"t"`
|
||||
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"`
|
||||
T float64 `json:"t"`
|
||||
}
|
||||
|
||||
// NetworkEventsList is a list of network events.
|
||||
@@ -431,35 +416,27 @@ func NewNetworkEventsList(results oonitemplates.Results) NetworkEventsList {
|
||||
for _, in := range results.NetworkEvents {
|
||||
if in.Connect != nil {
|
||||
out = append(out, &NetworkEvent{
|
||||
Address: in.Connect.RemoteAddress,
|
||||
ConnID: in.Connect.ConnID,
|
||||
DialID: in.Connect.DialID,
|
||||
Failure: makeFailure(in.Connect.Error),
|
||||
Operation: errorx.ConnectOperation,
|
||||
Proto: protocolName[in.Connect.ConnID >= 0],
|
||||
T: in.Connect.DurationSinceBeginning.Seconds(),
|
||||
TransactionID: in.Connect.TransactionID,
|
||||
Address: in.Connect.RemoteAddress,
|
||||
Failure: makeFailure(in.Connect.Error),
|
||||
Operation: errorx.ConnectOperation,
|
||||
T: in.Connect.DurationSinceBeginning.Seconds(),
|
||||
})
|
||||
// fallthrough
|
||||
}
|
||||
if in.Read != nil {
|
||||
out = append(out, &NetworkEvent{
|
||||
ConnID: in.Read.ConnID,
|
||||
Failure: makeFailure(in.Read.Error),
|
||||
Operation: errorx.ReadOperation,
|
||||
NumBytes: in.Read.NumBytes,
|
||||
Proto: protocolName[in.Read.ConnID >= 0],
|
||||
T: in.Read.DurationSinceBeginning.Seconds(),
|
||||
})
|
||||
// fallthrough
|
||||
}
|
||||
if in.Write != nil {
|
||||
out = append(out, &NetworkEvent{
|
||||
ConnID: in.Write.ConnID,
|
||||
Failure: makeFailure(in.Write.Error),
|
||||
Operation: errorx.WriteOperation,
|
||||
NumBytes: in.Write.NumBytes,
|
||||
Proto: protocolName[in.Write.ConnID >= 0],
|
||||
T: in.Write.DurationSinceBeginning.Seconds(),
|
||||
})
|
||||
// fallthrough
|
||||
@@ -471,13 +448,11 @@ func NewNetworkEventsList(results oonitemplates.Results) NetworkEventsList {
|
||||
// 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"`
|
||||
PeerCertificates []MaybeBinaryValue `json:"peer_certificates"`
|
||||
T float64 `json:"t"`
|
||||
TLSVersion string `json:"tls_version"`
|
||||
TransactionID int64 `json:"transaction_id,omitempty"`
|
||||
}
|
||||
|
||||
// TLSHandshakesList is a list of TLS handshakes
|
||||
@@ -489,13 +464,11 @@ func NewTLSHandshakesList(results oonitemplates.Results) TLSHandshakesList {
|
||||
for _, in := range results.TLSHandshakes {
|
||||
out = append(out, TLSHandshake{
|
||||
CipherSuite: tlsx.CipherSuiteString(in.ConnectionState.CipherSuite),
|
||||
ConnID: in.ConnID,
|
||||
Failure: makeFailure(in.Error),
|
||||
NegotiatedProtocol: in.ConnectionState.NegotiatedProtocol,
|
||||
PeerCertificates: makePeerCerts(in.ConnectionState.PeerCertificates),
|
||||
T: in.DurationSinceBeginning.Seconds(),
|
||||
TLSVersion: tlsx.VersionString(in.ConnectionState.Version),
|
||||
TransactionID: in.TransactionID,
|
||||
})
|
||||
}
|
||||
return out
|
||||
|
||||
@@ -823,22 +823,18 @@ func TestNewNetworkEventsListGood(t *testing.T) {
|
||||
NetworkEvents: []*modelx.Measurement{
|
||||
{
|
||||
Connect: &modelx.ConnectEvent{
|
||||
ConnID: 555,
|
||||
DurationSinceBeginning: 10 * time.Millisecond,
|
||||
DialID: 17,
|
||||
RemoteAddress: "1.1.1.1:443",
|
||||
},
|
||||
},
|
||||
{
|
||||
Read: &modelx.ReadEvent{
|
||||
ConnID: 555,
|
||||
DurationSinceBeginning: 20 * time.Millisecond,
|
||||
NumBytes: 1789,
|
||||
},
|
||||
},
|
||||
{
|
||||
Write: &modelx.WriteEvent{
|
||||
ConnID: 555,
|
||||
DurationSinceBeginning: 30 * time.Millisecond,
|
||||
NumBytes: 17714,
|
||||
},
|
||||
@@ -852,12 +848,6 @@ func TestNewNetworkEventsListGood(t *testing.T) {
|
||||
if out[0].Address != "1.1.1.1:443" {
|
||||
t.Fatal("wrong out[0].Address")
|
||||
}
|
||||
if out[0].ConnID != 555 {
|
||||
t.Fatal("wrong out[0].ConnID")
|
||||
}
|
||||
if out[0].DialID != 17 {
|
||||
t.Fatal("wrong out[0].DialID")
|
||||
}
|
||||
if out[0].Failure != nil {
|
||||
t.Fatal("wrong out[0].Failure")
|
||||
}
|
||||
@@ -867,9 +857,6 @@ func TestNewNetworkEventsListGood(t *testing.T) {
|
||||
if out[0].Operation != errorx.ConnectOperation {
|
||||
t.Fatal("wrong out[0].Operation")
|
||||
}
|
||||
if out[0].Proto != "tcp" {
|
||||
t.Fatal("wrong out[0].Proto")
|
||||
}
|
||||
if !floatEquals(out[0].T, 0.010) {
|
||||
t.Fatal("wrong out[0].T")
|
||||
}
|
||||
@@ -877,12 +864,6 @@ func TestNewNetworkEventsListGood(t *testing.T) {
|
||||
if out[1].Address != "" {
|
||||
t.Fatal("wrong out[1].Address")
|
||||
}
|
||||
if out[1].ConnID != 555 {
|
||||
t.Fatal("wrong out[1].ConnID")
|
||||
}
|
||||
if out[1].DialID != 0 {
|
||||
t.Fatal("wrong out[1].DialID")
|
||||
}
|
||||
if out[1].Failure != nil {
|
||||
t.Fatal("wrong out[1].Failure")
|
||||
}
|
||||
@@ -892,9 +873,6 @@ func TestNewNetworkEventsListGood(t *testing.T) {
|
||||
if out[1].Operation != errorx.ReadOperation {
|
||||
t.Fatal("wrong out[1].Operation")
|
||||
}
|
||||
if out[1].Proto != "tcp" {
|
||||
t.Fatal("wrong out[1].Proto")
|
||||
}
|
||||
if !floatEquals(out[1].T, 0.020) {
|
||||
t.Fatal("wrong out[1].T")
|
||||
}
|
||||
@@ -902,12 +880,6 @@ func TestNewNetworkEventsListGood(t *testing.T) {
|
||||
if out[2].Address != "" {
|
||||
t.Fatal("wrong out[2].Address")
|
||||
}
|
||||
if out[2].ConnID != 555 {
|
||||
t.Fatal("wrong out[2].ConnID")
|
||||
}
|
||||
if out[2].DialID != 0 {
|
||||
t.Fatal("wrong out[2].DialID")
|
||||
}
|
||||
if out[2].Failure != nil {
|
||||
t.Fatal("wrong out[2].Failure")
|
||||
}
|
||||
@@ -917,9 +889,6 @@ func TestNewNetworkEventsListGood(t *testing.T) {
|
||||
if out[2].Operation != errorx.WriteOperation {
|
||||
t.Fatal("wrong out[2].Operation")
|
||||
}
|
||||
if out[2].Proto != "tcp" {
|
||||
t.Fatal("wrong out[2].Proto")
|
||||
}
|
||||
if !floatEquals(out[2].T, 0.030) {
|
||||
t.Fatal("wrong out[2].T")
|
||||
}
|
||||
@@ -930,16 +899,13 @@ func TestNewNetworkEventsListGoodUDPAndErrors(t *testing.T) {
|
||||
NetworkEvents: []*modelx.Measurement{
|
||||
{
|
||||
Connect: &modelx.ConnectEvent{
|
||||
ConnID: -555,
|
||||
DurationSinceBeginning: 10 * time.Millisecond,
|
||||
DialID: 17,
|
||||
Error: errors.New("mocked error"),
|
||||
RemoteAddress: "1.1.1.1:443",
|
||||
},
|
||||
},
|
||||
{
|
||||
Read: &modelx.ReadEvent{
|
||||
ConnID: -555,
|
||||
DurationSinceBeginning: 20 * time.Millisecond,
|
||||
Error: errors.New("mocked error"),
|
||||
NumBytes: 1789,
|
||||
@@ -947,7 +913,6 @@ func TestNewNetworkEventsListGoodUDPAndErrors(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Write: &modelx.WriteEvent{
|
||||
ConnID: -555,
|
||||
DurationSinceBeginning: 30 * time.Millisecond,
|
||||
Error: errors.New("mocked error"),
|
||||
NumBytes: 17714,
|
||||
@@ -962,12 +927,6 @@ func TestNewNetworkEventsListGoodUDPAndErrors(t *testing.T) {
|
||||
if out[0].Address != "1.1.1.1:443" {
|
||||
t.Fatal("wrong out[0].Address")
|
||||
}
|
||||
if out[0].ConnID != -555 {
|
||||
t.Fatal("wrong out[0].ConnID")
|
||||
}
|
||||
if out[0].DialID != 17 {
|
||||
t.Fatal("wrong out[0].DialID")
|
||||
}
|
||||
if *out[0].Failure != "mocked error" {
|
||||
t.Fatal("wrong out[0].Failure")
|
||||
}
|
||||
@@ -977,9 +936,6 @@ func TestNewNetworkEventsListGoodUDPAndErrors(t *testing.T) {
|
||||
if out[0].Operation != errorx.ConnectOperation {
|
||||
t.Fatal("wrong out[0].Operation")
|
||||
}
|
||||
if out[0].Proto != "udp" {
|
||||
t.Fatal("wrong out[0].Proto")
|
||||
}
|
||||
if !floatEquals(out[0].T, 0.010) {
|
||||
t.Fatal("wrong out[0].T")
|
||||
}
|
||||
@@ -987,12 +943,6 @@ func TestNewNetworkEventsListGoodUDPAndErrors(t *testing.T) {
|
||||
if out[1].Address != "" {
|
||||
t.Fatal("wrong out[1].Address")
|
||||
}
|
||||
if out[1].ConnID != -555 {
|
||||
t.Fatal("wrong out[1].ConnID")
|
||||
}
|
||||
if out[1].DialID != 0 {
|
||||
t.Fatal("wrong out[1].DialID")
|
||||
}
|
||||
if *out[1].Failure != "mocked error" {
|
||||
t.Fatal("wrong out[1].Failure")
|
||||
}
|
||||
@@ -1002,9 +952,6 @@ func TestNewNetworkEventsListGoodUDPAndErrors(t *testing.T) {
|
||||
if out[1].Operation != errorx.ReadOperation {
|
||||
t.Fatal("wrong out[1].Operation")
|
||||
}
|
||||
if out[1].Proto != "udp" {
|
||||
t.Fatal("wrong out[1].Proto")
|
||||
}
|
||||
if !floatEquals(out[1].T, 0.020) {
|
||||
t.Fatal("wrong out[1].T")
|
||||
}
|
||||
@@ -1012,12 +959,6 @@ func TestNewNetworkEventsListGoodUDPAndErrors(t *testing.T) {
|
||||
if out[2].Address != "" {
|
||||
t.Fatal("wrong out[2].Address")
|
||||
}
|
||||
if out[2].ConnID != -555 {
|
||||
t.Fatal("wrong out[2].ConnID")
|
||||
}
|
||||
if out[2].DialID != 0 {
|
||||
t.Fatal("wrong out[2].DialID")
|
||||
}
|
||||
if *out[2].Failure != "mocked error" {
|
||||
t.Fatal("wrong out[2].Failure")
|
||||
}
|
||||
@@ -1027,9 +968,6 @@ func TestNewNetworkEventsListGoodUDPAndErrors(t *testing.T) {
|
||||
if out[2].Operation != errorx.WriteOperation {
|
||||
t.Fatal("wrong out[2].Operation")
|
||||
}
|
||||
if out[2].Proto != "udp" {
|
||||
t.Fatal("wrong out[2].Proto")
|
||||
}
|
||||
if !floatEquals(out[2].T, 0.030) {
|
||||
t.Fatal("wrong out[2].T")
|
||||
}
|
||||
@@ -1052,8 +990,7 @@ func TestNewTLSHandshakesListSuccess(t *testing.T) {
|
||||
TLSHandshakes: []*modelx.TLSHandshakeDoneEvent{
|
||||
{},
|
||||
{
|
||||
ConnID: 12345,
|
||||
Error: errors.New("mocked error"),
|
||||
Error: errors.New("mocked error"),
|
||||
},
|
||||
{
|
||||
ConnectionState: modelx.TLSConnectionState{
|
||||
@@ -1080,9 +1017,6 @@ func TestNewTLSHandshakesListSuccess(t *testing.T) {
|
||||
if out[0].CipherSuite != "" {
|
||||
t.Fatal("invalid out[0].CipherSuite")
|
||||
}
|
||||
if out[0].ConnID != 0 {
|
||||
t.Fatal("invalid out[0].ConnID")
|
||||
}
|
||||
if out[0].Failure != nil {
|
||||
t.Fatal("invalid out[0].Failure")
|
||||
}
|
||||
@@ -1102,9 +1036,6 @@ func TestNewTLSHandshakesListSuccess(t *testing.T) {
|
||||
if out[1].CipherSuite != "" {
|
||||
t.Fatal("invalid out[1].CipherSuite")
|
||||
}
|
||||
if out[1].ConnID != 12345 {
|
||||
t.Fatal("invalid out[1].ConnID")
|
||||
}
|
||||
if *out[1].Failure != "mocked error" {
|
||||
t.Fatal("invalid out[1].Failure")
|
||||
}
|
||||
@@ -1124,9 +1055,6 @@ func TestNewTLSHandshakesListSuccess(t *testing.T) {
|
||||
if out[2].CipherSuite != "TLS_AES_128_GCM_SHA256" {
|
||||
t.Fatal("invalid out[2].CipherSuite")
|
||||
}
|
||||
if out[2].ConnID != 0 {
|
||||
t.Fatal("invalid out[2].ConnID")
|
||||
}
|
||||
if out[2].Failure != nil {
|
||||
t.Fatal("invalid out[2].Failure")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user