Skip to content

Commit

Permalink
feat(netxlite): use *Netx for NewParallelUDPResolver
Browse files Browse the repository at this point in the history
The overall idea at this point is that we will have an interface
containing the methods we currently have inside *Netx and we will
sever the hard dependency between measurexlite and netxlite.

We will probably still need to import some contants from netxlite
but, for all effects and purposes, measurexlite would become
completely mockable (as it is now) with an explicit dependency
on the related behavior.

In turn, this refactoring would clarify which netxlite functionality
we use for measuring, which are legacy, and which we use for
communicating with the OONI backend. That change would definitely
make it obvious to modify netxlite and go in the overall direction
defined by ooni/probe#2531.
  • Loading branch information
bassosimone committed Sep 12, 2023
1 parent abc0261 commit 17c8041
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/netxlite/resolvercore.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,19 @@ func NewSerialUDPResolver(logger model.DebugLogger, dialer model.Dialer, address
// - dialer is the dialer to create and connect UDP conns
//
// - address is the server address (e.g., 1.1.1.1:53)
func NewParallelUDPResolver(logger model.DebugLogger, dialer model.Dialer, address string) model.Resolver {
func (netx *Netx) NewParallelUDPResolver(logger model.DebugLogger, dialer model.Dialer, address string) model.Resolver {
return WrapResolver(logger, NewUnwrappedParallelResolver(
wrapDNSTransport(NewUnwrappedDNSOverUDPTransport(dialer, address)),
))
}

// NewParallelUDPResolver is equivalent to creating an empty [*Netx]
// and calling its NewParallelUDPResolver method.
func NewParallelUDPResolver(logger model.DebugLogger, dialer model.Dialer, address string) model.Resolver {
netx := &Netx{Underlying: nil}
return netx.NewParallelUDPResolver(logger, dialer, address)
}

// WrapResolver creates a new resolver that wraps an
// existing resolver to add these properties:
//
Expand Down

0 comments on commit 17c8041

Please sign in to comment.