refactor(netx): remove forwardes for tlsx (#365)

Part of https://github.com/ooni/probe/issues/1591
This commit is contained in:
Simone Basso
2021-06-08 21:14:45 +02:00
committed by GitHub
parent adbde7246b
commit a647cf4988
6 changed files with 13 additions and 23 deletions
+2 -14
View File
@@ -109,11 +109,7 @@ type tlsHandshaker interface {
net.Conn, tls.ConnectionState, error)
}
// NewDefaultCertPool returns a copy of the default x509
// certificate pool that we bundle from Mozilla.
var NewDefaultCertPool = tlsx.NewDefaultCertPool
var defaultCertPool *x509.CertPool = NewDefaultCertPool()
var defaultCertPool *x509.CertPool = tlsx.NewDefaultCertPool()
// NewResolver creates a new resolver from the specified config
func NewResolver(config Config) Resolver {
@@ -308,14 +304,6 @@ func NewDNSClient(config Config, URL string) (DNSClient, error) {
return NewDNSClientWithOverrides(config, URL, "", "", "")
}
// ErrInvalidTLSVersion indicates that you passed us a string
// that does not represent a valid TLS version.
var ErrInvalidTLSVersion = tlsx.ErrInvalidTLSVersion
// ConfigureTLSVersion configures the correct TLS version into
// the specified *tls.Config or returns an error.
var ConfigureTLSVersion = tlsx.ConfigureTLSVersion
// NewDNSClientWithOverrides creates a new DNS client, similar to NewDNSClient,
// with the option to override the default Hostname and SNI.
func NewDNSClientWithOverrides(config Config, URL, hostOverride, SNIOverride,
@@ -336,7 +324,7 @@ func NewDNSClientWithOverrides(config Config, URL, hostOverride, SNIOverride,
return c, err
}
config.TLSConfig = &tls.Config{ServerName: SNIOverride}
if err := ConfigureTLSVersion(config.TLSConfig, TLSVersion); err != nil {
if err := tlsx.ConfigureTLSVersion(config.TLSConfig, TLSVersion); err != nil {
return c, err
}
switch resolverURL.Scheme {
+2 -1
View File
@@ -14,6 +14,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/netx/httptransport"
"github.com/ooni/probe-cli/v3/internal/engine/netx/resolver"
"github.com/ooni/probe-cli/v3/internal/engine/netx/tlsdialer"
"github.com/ooni/probe-cli/v3/internal/engine/netx/tlsx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/trace"
)
@@ -1188,7 +1189,7 @@ func TestNewDNSClientBadUDPEndpoint(t *testing.T) {
func TestNewDNSCLientWithInvalidTLSVersion(t *testing.T) {
_, err := netx.NewDNSClientWithOverrides(
netx.Config{}, "dot://8.8.8.8", "", "", "TLSv999")
if !errors.Is(err, netx.ErrInvalidTLSVersion) {
if !errors.Is(err, tlsx.ErrInvalidTLSVersion) {
t.Fatalf("not the error we expected: %+v", err)
}
}