feat(oohelperd): follow (and record) TH and probe endpoints (#890)
This diff introduces the following `oohelperd` enhancements: 1. measure both IP addresses resolved by the TH and IP addresses resolved by the probe; 2. when the URL scheme is http and there's no explicit port, measure both 80 and 443 (which will pay off big once we introduce support for optionally performing TLS handshakes); 3. include information about the probe and TH IP addresses into the results: who resolved each IP address, whether an address is a bogon, the ASN associated to an address. This diff is part of https://github.com/ooni/probe/issues/2237
This commit is contained in:
parent
867a243fef
commit
df0e099b73
7 changed files with 401 additions and 21 deletions
|
|
@ -10,6 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
|
||||
"github.com/ooni/probe-cli/v3/internal/measurexlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
|
@ -19,15 +20,21 @@ type ctrlTCPResult = webconnectivity.ControlTCPConnectResult
|
|||
|
||||
// tcpResultPair contains the endpoint and the corresponding result.
|
||||
type tcpResultPair struct {
|
||||
// Address is the IP address we measured.
|
||||
Address string
|
||||
|
||||
// Endpoint is the endpoint we measured.
|
||||
Endpoint string
|
||||
|
||||
// Result contains the results.
|
||||
Result ctrlTCPResult
|
||||
// TCP contains the TCP results.
|
||||
TCP ctrlTCPResult
|
||||
}
|
||||
|
||||
// tcpConfig configures the TCP connect check.
|
||||
type tcpConfig struct {
|
||||
// Address is the MANDATORY address to measure.
|
||||
Address string
|
||||
|
||||
// Endpoint is the MANDATORY endpoint to connect to.
|
||||
Endpoint string
|
||||
|
||||
|
|
@ -35,7 +42,7 @@ type tcpConfig struct {
|
|||
NewDialer func() model.Dialer
|
||||
|
||||
// Out is the MANDATORY where we'll post the TCP measurement results.
|
||||
Out chan tcpResultPair
|
||||
Out chan *tcpResultPair
|
||||
|
||||
// Wg is MANDATORY and is used to sync with the parent.
|
||||
Wg *sync.WaitGroup
|
||||
|
|
@ -47,19 +54,20 @@ func tcpDo(ctx context.Context, config *tcpConfig) {
|
|||
ctx, cancel := context.WithTimeout(ctx, timeout)
|
||||
defer cancel()
|
||||
defer config.Wg.Done()
|
||||
out := &tcpResultPair{
|
||||
Address: config.Address,
|
||||
Endpoint: config.Endpoint,
|
||||
TCP: webconnectivity.ControlTCPConnectResult{},
|
||||
}
|
||||
defer func() {
|
||||
config.Out <- out
|
||||
}()
|
||||
dialer := config.NewDialer()
|
||||
defer dialer.CloseIdleConnections()
|
||||
conn, err := dialer.DialContext(ctx, "tcp", config.Endpoint)
|
||||
if conn != nil {
|
||||
conn.Close()
|
||||
}
|
||||
config.Out <- tcpResultPair{
|
||||
Endpoint: config.Endpoint,
|
||||
Result: ctrlTCPResult{
|
||||
Failure: tcpMapFailure(newfailure(err)),
|
||||
Status: err == nil,
|
||||
},
|
||||
}
|
||||
out.TCP.Failure = tcpMapFailure(newfailure(err))
|
||||
out.TCP.Status = err == nil
|
||||
measurexlite.MaybeClose(conn)
|
||||
}
|
||||
|
||||
// tcpMapFailure attempts to map netxlite failures to the strings
|
||||
|
|
|
|||
Loading…
Reference in a new issue