refactor(netx): reorganize by topic (#800)

Before finishing the ongoing refactoring and leaving whatever
is left of netx in tree, I would like to restructure it so that
we'll have an easy time next time we need to modify it.

Currently, every functionality lives into the `netx.go` file and
we have a support file called `httptransport.go`.

I would like to reorganize by topic, instead. This would allow
future me to more easily perform topic-specific changes.

While there, improve `netx`'s documentation and duplicate some of
this documentation inside `internal/README.md` to provide pointers
to previous documentation, historical context, and some help to
understand the logic architecture of network extensions (aka `netx`).

Part of https://github.com/ooni/probe-cli/pull/396
This commit is contained in:
Simone Basso 2022-06-06 14:27:25 +02:00 committed by GitHub
commit 64bffbd941
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 703 additions and 528 deletions

View file

@ -0,0 +1,21 @@
package netx
//
// QUICDialer from Config.
//
import (
"github.com/ooni/probe-cli/v3/internal/model"
"github.com/ooni/probe-cli/v3/internal/netxlite"
)
// NewQUICDialer creates a new QUICDialer using the given Config.
func NewQUICDialer(config Config) model.QUICDialer {
if config.FullResolver == nil {
config.FullResolver = NewResolver(config)
}
// TODO(bassosimone): we should count the bytes consumed by this QUIC dialer
ql := config.ReadWriteSaver.WrapQUICListener(netxlite.NewQUICListener())
logger := model.ValidLoggerOrDefault(config.Logger)
return netxlite.NewQUICDialerWithResolver(ql, logger, config.FullResolver, config.Saver)
}