refactor(netx): move construction logic outside package (#798)

For testability, replace most if-based construction logic with
calls to well-tested factories living in other packages.

While there, acknowledge that a bunch of types could now be private
and make them private, modifying the code to call the public
factories allowing to construct said types instead.

Part of https://github.com/ooni/probe/issues/2121
This commit is contained in:
Simone Basso
2022-06-05 21:22:27 +02:00
committed by GitHub
parent 2d3d5d9cdc
commit 6b85dfce88
20 changed files with 476 additions and 185 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ func newDialManager(ndt7URL string, logger model.Logger, userAgent string) dialM
func (mgr dialManager) dialWithTestName(ctx context.Context, testName string) (*websocket.Conn, error) {
reso := netxlite.NewResolverStdlib(mgr.logger)
dlr := netxlite.NewDialerWithResolver(mgr.logger, reso)
dlr = bytecounter.NewContextAwareDialer(dlr)
dlr = bytecounter.WrapWithContextAwareDialer(dlr)
// Implements shaping if the user builds using `-tags shaping`
// See https://github.com/ooni/probe/issues/2112
dlr = netxlite.NewMaybeShapingDialer(dlr)