Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup(netxlite): QUICListener -> UDPListener #1247

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/netemx/oohelperd.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (f *OOHelperDFactory) NewHandler(env NetStackServerFactoryEnv, unet *netem.

handler.NewQUICDialer = func(logger model.Logger) model.QUICDialer {
return netx.NewQUICDialerWithResolver(
netx.NewQUICListener(),
netx.NewUDPListener(),
logger,
netx.NewStdlibResolver(logger),
)
Expand Down
22 changes: 11 additions & 11 deletions internal/netxlite/netx.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package netxlite
import "github.com/ooni/probe-cli/v3/internal/model"

// TODO(bassosimone,kelmenhorst): we should gradually refactor the top-level netxlite
// functions to operate on a [Net] struct using a nil-initialized Underlying field.
// functions to operate on a [Netx] struct using a nil-initialized Underlying field.

// Netx allows constructing netxlite data types using a specific [model.UnderlyingNetwork].
type Netx struct {
Expand All @@ -23,7 +23,7 @@ func (n *Netx) tproxyNilSafeProvider() *MaybeCustomUnderlyingNetwork {
}

// NewStdlibResolver is like [netxlite.NewStdlibResolver] but the constructed [model.Resolver]
// uses the [UnderlyingNetwork] configured inside the [Net] structure.
// uses the [model.UnderlyingNetwork] configured inside the [Netx] structure.
func (n *Netx) NewStdlibResolver(logger model.DebugLogger, wrappers ...model.DNSTransportWrapper) model.Resolver {
unwrapped := &resolverSystem{
t: WrapDNSTransport(&dnsOverGetaddrinfoTransport{provider: n.tproxyNilSafeProvider()}, wrappers...),
Expand All @@ -32,19 +32,19 @@ func (n *Netx) NewStdlibResolver(logger model.DebugLogger, wrappers ...model.DNS
}

// NewDialerWithResolver is like [netxlite.NewDialerWithResolver] but the constructed [model.Dialer]
// uses the [UnderlyingNetwork] configured inside the [Net] structure.
// uses the [model.UnderlyingNetwork] configured inside the [Netx] structure.
func (n *Netx) NewDialerWithResolver(dl model.DebugLogger, r model.Resolver, w ...model.DialerWrapper) model.Dialer {
return WrapDialer(dl, r, &DialerSystem{provider: n.tproxyNilSafeProvider()}, w...)
}

// NewQUICListener is like [netxlite.NewQUICListener] but the constructed [model.QUICListener]
// uses the [UnderlyingNetwork] configured inside the [Net] structure.
func (n *Netx) NewQUICListener() model.UDPListener {
// NewUDPListener is like [netxlite.NewUDPListener] but the constructed [model.UDPListener]
// uses the [model.UnderlyingNetwork] configured inside the [Netx] structure.
func (n *Netx) NewUDPListener() model.UDPListener {
return &udpListenerErrWrapper{&udpListenerStdlib{provider: n.tproxyNilSafeProvider()}}
}

// NewQUICDialerWithResolver is like [netxlite.NewQUICDialerWithResolver] but the constructed
// [model.QUICDialer] uses the [UnderlyingNetwork] configured inside the [Net] structure.
// [model.QUICDialer] uses the [model.UnderlyingNetwork] configured inside the [Netx] structure.
func (n *Netx) NewQUICDialerWithResolver(listener model.UDPListener, logger model.DebugLogger,
resolver model.Resolver, wrappers ...model.QUICDialerWrapper) (outDialer model.QUICDialer) {
baseDialer := &quicDialerQUICGo{
Expand All @@ -55,23 +55,23 @@ func (n *Netx) NewQUICDialerWithResolver(listener model.UDPListener, logger mode
}

// NewTLSHandshakerStdlib is like [netxlite.NewTLSHandshakerStdlib] but the constructed [model.TLSHandshaker]
// uses the [UnderlyingNetwork] configured inside the [Net] structure.
// uses the [model.UnderlyingNetwork] configured inside the [Netx] structure.
func (n *Netx) NewTLSHandshakerStdlib(logger model.DebugLogger) model.TLSHandshaker {
return newTLSHandshakerLogger(&tlsHandshakerConfigurable{provider: n.tproxyNilSafeProvider()}, logger)
}

// NewHTTPTransportStdlib is like [netxlite.NewHTTPTransportStdlib] but the constructed [model.HTTPTransport]
// uses the [UnderlyingNetwork] configured inside the [Net] structure.
// uses the [model.UnderlyingNetwork] configured inside the [Netx] structure.
func (n *Netx) NewHTTPTransportStdlib(logger model.DebugLogger) model.HTTPTransport {
dialer := n.NewDialerWithResolver(logger, n.NewStdlibResolver(logger))
tlsDialer := NewTLSDialer(dialer, n.NewTLSHandshakerStdlib(logger))
return NewHTTPTransport(logger, dialer, tlsDialer)
}

// NewHTTP3TransportStdlib is like [netxlite.NewHTTP3TransportStdlib] but the constructed [model.HTTPTransport]
// uses the [UnderlyingNetwork] configured inside the [Net] structure.
// uses the [model.UnderlyingNetwork] configured inside the [Netx] structure.
func (n *Netx) NewHTTP3TransportStdlib(logger model.DebugLogger) model.HTTPTransport {
ql := n.NewQUICListener()
ql := n.NewUDPListener()
reso := n.NewStdlibResolver(logger)
qd := n.NewQUICDialerWithResolver(ql, logger, reso)
return NewHTTP3Transport(logger, qd, nil)
Expand Down