7a9499fee3
Like we did before for the resolver, a dialer should propagate the request to close idle connections to underlying types. See https://github.com/ooni/probe/issues/1591
28 lines
597 B
Go
28 lines
597 B
Go
package websteps
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
|
)
|
|
|
|
type TCPConfig struct {
|
|
Dialer netxlite.DialerLegacy
|
|
Endpoint string
|
|
Resolver netxlite.ResolverLegacy
|
|
}
|
|
|
|
// TCPDo performs the TCP check.
|
|
func TCPDo(ctx context.Context, config TCPConfig) (net.Conn, error) {
|
|
if config.Dialer != nil {
|
|
return config.Dialer.DialContext(ctx, "tcp", config.Endpoint)
|
|
}
|
|
resolver := config.Resolver
|
|
if resolver == nil {
|
|
resolver = &netxlite.ResolverSystem{}
|
|
}
|
|
dialer := NewDialerResolver(resolver)
|
|
return dialer.DialContext(ctx, "tcp", config.Endpoint)
|
|
}
|