refactor: interfaces and data types into the model package (#642)
## Checklist - [x] I have read the [contribution guidelines](https://github.com/ooni/probe-cli/blob/master/CONTRIBUTING.md) - [x] reference issue for this pull request: https://github.com/ooni/probe/issues/1885 - [x] related ooni/spec pull request: N/A Location of the issue tracker: https://github.com/ooni/probe ## Description This PR contains a set of changes to move important interfaces and data types into the `./internal/model` package. The criteria for including an interface or data type in here is roughly that the type should be important and used by several packages. We are especially interested to move more interfaces here to increase modularity. An additional side effect is that, by reading this package, one should be able to understand more quickly how different parts of the codebase interact with each other. This is what I want to move in `internal/model`: - [x] most important interfaces from `internal/netxlite` - [x] everything that was previously part of `internal/engine/model` - [x] mocks from `internal/netxlite/mocks` should also be moved in here as a subpackage
This commit is contained in:
parent
69aca619ea
commit
273b70bacc
275 changed files with 1281 additions and 1375 deletions
|
|
@ -8,13 +8,14 @@ import (
|
|||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/lucas-clemente/quic-go/http3"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
// http3Dialer adapts a QUICContextDialer to work with
|
||||
// an http3.RoundTripper. This is necessary because the
|
||||
// http3.RoundTripper does not support DialContext.
|
||||
type http3Dialer struct {
|
||||
QUICDialer
|
||||
model.QUICDialer
|
||||
}
|
||||
|
||||
// dial is like QUICContextDialer.DialContext but without context.
|
||||
|
|
@ -33,10 +34,10 @@ type http3RoundTripper interface {
|
|||
// http3Transport is an HTTPTransport using the http3 protocol.
|
||||
type http3Transport struct {
|
||||
child http3RoundTripper
|
||||
dialer QUICDialer
|
||||
dialer model.QUICDialer
|
||||
}
|
||||
|
||||
var _ HTTPTransport = &http3Transport{}
|
||||
var _ model.HTTPTransport = &http3Transport{}
|
||||
|
||||
// RoundTrip implements HTTPTransport.RoundTrip.
|
||||
func (txp *http3Transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
|
|
@ -53,7 +54,7 @@ func (txp *http3Transport) CloseIdleConnections() {
|
|||
// dialer argument MUST NOT be nil. If the tlsConfig argument is nil,
|
||||
// then the code will use the default TLS configuration.
|
||||
func NewHTTP3Transport(
|
||||
logger Logger, dialer QUICDialer, tlsConfig *tls.Config) HTTPTransport {
|
||||
logger model.DebugLogger, dialer model.QUICDialer, tlsConfig *tls.Config) model.HTTPTransport {
|
||||
return &httpTransportLogger{
|
||||
HTTPTransport: &http3Transport{
|
||||
child: &http3.RoundTripper{
|
||||
|
|
|
|||
Loading…
Reference in a new issue