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:
parent
1fefe5d9b8
commit
c74c94d616
32 changed files with 78 additions and 896 deletions
|
|
@ -5,10 +5,7 @@ import (
|
|||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/connid"
|
||||
"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"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/dialer"
|
||||
)
|
||||
|
||||
|
|
@ -25,14 +22,11 @@ func (d EmitterDialer) DialContext(ctx context.Context, network, address string)
|
|||
root := modelx.ContextMeasurementRootOrDefault(ctx)
|
||||
root.Handler.OnMeasurement(modelx.Measurement{
|
||||
Connect: &modelx.ConnectEvent{
|
||||
ConnID: safeConnID(network, conn),
|
||||
DialID: dialid.ContextDialID(ctx),
|
||||
DurationSinceBeginning: stop.Sub(root.Beginning),
|
||||
Error: err,
|
||||
Network: network,
|
||||
RemoteAddress: address,
|
||||
SyscallDuration: stop.Sub(start),
|
||||
TransactionID: transactionid.ContextTransactionID(ctx),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -42,7 +36,6 @@ func (d EmitterDialer) DialContext(ctx context.Context, network, address string)
|
|||
Conn: conn,
|
||||
Beginning: root.Beginning,
|
||||
Handler: root.Handler,
|
||||
ID: safeConnID(network, conn),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +44,6 @@ type EmitterConn struct {
|
|||
net.Conn
|
||||
Beginning time.Time
|
||||
Handler modelx.Handler
|
||||
ID int64
|
||||
}
|
||||
|
||||
// Read implements net.Conn.Read
|
||||
|
|
@ -61,7 +53,6 @@ func (c EmitterConn) Read(b []byte) (n int, err error) {
|
|||
stop := time.Now()
|
||||
c.Handler.OnMeasurement(modelx.Measurement{
|
||||
Read: &modelx.ReadEvent{
|
||||
ConnID: c.ID,
|
||||
DurationSinceBeginning: stop.Sub(c.Beginning),
|
||||
Error: err,
|
||||
NumBytes: int64(n),
|
||||
|
|
@ -78,7 +69,6 @@ func (c EmitterConn) Write(b []byte) (n int, err error) {
|
|||
stop := time.Now()
|
||||
c.Handler.OnMeasurement(modelx.Measurement{
|
||||
Write: &modelx.WriteEvent{
|
||||
ConnID: c.ID,
|
||||
DurationSinceBeginning: stop.Sub(c.Beginning),
|
||||
Error: err,
|
||||
NumBytes: int64(n),
|
||||
|
|
@ -95,7 +85,6 @@ func (c EmitterConn) Close() (err error) {
|
|||
stop := time.Now()
|
||||
c.Handler.OnMeasurement(modelx.Measurement{
|
||||
Close: &modelx.CloseEvent{
|
||||
ConnID: c.ID,
|
||||
DurationSinceBeginning: stop.Sub(c.Beginning),
|
||||
Error: err,
|
||||
SyscallDuration: stop.Sub(start),
|
||||
|
|
@ -103,14 +92,3 @@ func (c EmitterConn) Close() (err error) {
|
|||
})
|
||||
return
|
||||
}
|
||||
|
||||
func safeLocalAddress(conn net.Conn) (s string) {
|
||||
if conn != nil && conn.LocalAddr() != nil {
|
||||
s = conn.LocalAddr().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func safeConnID(network string, conn net.Conn) int64 {
|
||||
return connid.Compute(network, safeLocalAddress(conn))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue