refactor: continue to simplify engine/netx (#769)

The objective of this diff is to simplify the code inside engine/netx
while moving more bits of code inside netxlite.

See https://github.com/ooni/probe/issues/2121
This commit is contained in:
Simone Basso 2022-05-31 08:11:07 +02:00 committed by GitHub
commit e4f10eeac2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 312 additions and 344 deletions

View file

@ -5,6 +5,7 @@ import (
"crypto/tls"
"github.com/ooni/probe-cli/v3/internal/model"
"github.com/ooni/probe-cli/v3/internal/netxlite"
)
// Config contains the configuration required for constructing an HTTP transport
@ -14,3 +15,25 @@ type Config struct {
TLSDialer model.TLSDialer
TLSConfig *tls.Config
}
// NewHTTP3Transport creates a new HTTP3Transport instance.
//
// Deprecation warning
//
// New code should use netxlite.NewHTTP3Transport instead.
func NewHTTP3Transport(config Config) model.HTTPTransport {
// Rationale for using NoLogger here: previously this code did
// not use a logger as well, so it's fine to keep it as is.
return netxlite.NewHTTP3Transport(model.DiscardLogger,
config.QUICDialer, config.TLSConfig)
}
// NewSystemTransport creates a new "system" HTTP transport. That is a transport
// using the Go standard library with custom dialer and TLS dialer.
//
// Deprecation warning
//
// New code should use netxlite.NewHTTPTransport instead.
func NewSystemTransport(config Config) model.HTTPTransport {
return netxlite.NewOOHTTPBaseTransport(config.Dialer, config.TLSDialer)
}