refactor: merge dnsx and errorsx into netxlite (#517)
When preparing a tutorial for netxlite, I figured it is easier to tell people "hey, this is the package you should use for all low-level networking stuff" rather than introducing people to a set of packages working together where some piece of functionality is here and some other piece is there. Part of https://github.com/ooni/probe/issues/1591
This commit is contained in:
parent
de130d249c
commit
6d3a4f1db8
169 changed files with 575 additions and 671 deletions
|
|
@ -11,7 +11,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
)
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ func TestGenerateDNSFailure(t *testing.T) {
|
|||
if urlMeasurements[0].DNS == nil {
|
||||
t.Fatal("DNS should not be nil")
|
||||
}
|
||||
if urlMeasurements[0].DNS.Failure == nil || *urlMeasurements[0].DNS.Failure != errorsx.FailureDNSNXDOMAINError {
|
||||
if urlMeasurements[0].DNS.Failure == nil || *urlMeasurements[0].DNS.Failure != netxlite.FailureDNSNXDOMAINError {
|
||||
t.Fatal("unexpected DNS failure type")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
func TestMeasureSuccess(t *testing.T) {
|
||||
|
|
@ -79,7 +79,7 @@ func TestMeasureInitialChecksFailWithNXDOMAIN(t *testing.T) {
|
|||
if resp.URLs[0].DNS == nil {
|
||||
t.Fatal("DNS entry should not be nil")
|
||||
}
|
||||
if *resp.URLs[0].DNS.Failure != errorsx.FailureDNSNXDOMAINError {
|
||||
if *resp.URLs[0].DNS.Failure != netxlite.FailureDNSNXDOMAINError {
|
||||
t.Fatal("unexpected failure")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/iox"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
"github.com/ooni/probe-cli/v3/internal/version"
|
||||
)
|
||||
|
|
@ -42,7 +42,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||
return
|
||||
}
|
||||
reader := &io.LimitedReader{R: req.Body, N: maxAcceptableBody}
|
||||
data, err := iox.ReadAllContext(req.Context(), reader)
|
||||
data, err := netxlite.ReadAllContext(req.Context(), reader)
|
||||
if err != nil {
|
||||
w.WriteHeader(400)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite/iox"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
const requestnoredirect = `{
|
||||
|
|
@ -188,7 +188,7 @@ func TestWorkingAsIntended(t *testing.T) {
|
|||
if resp.StatusCode != expect.respStatusCode {
|
||||
t.Fatalf("unexpected status code: %+v", resp.StatusCode)
|
||||
}
|
||||
data, err := iox.ReadAllContext(context.Background(), resp.Body)
|
||||
data, err := netxlite.ReadAllContext(context.Background(), resp.Body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -220,7 +220,7 @@ func TestHandlerWithInternalServerError(t *testing.T) {
|
|||
if resp.StatusCode != 500 {
|
||||
t.Fatalf("unexpected status code: %+v", resp.StatusCode)
|
||||
}
|
||||
_, err = iox.ReadAllContext(context.Background(), resp.Body)
|
||||
_, err = netxlite.ReadAllContext(context.Background(), resp.Body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue