Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(probeservices): use api.ooni.io #926

Merged
merged 2 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion E2E/miniooni.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
set -e
backends=()
backends+=( "https://ps1.ooni.io" )
backends+=( "https://api.ooni.io" )
backends+=( "https://dvp6h0xblpcqp.cloudfront.net" )
backends+=( "https://ams-pg-test.ooni.org" )
miniooni="${1:-./miniooni}"
Expand Down
8 changes: 1 addition & 7 deletions QA/webconnectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ def assert_status_flags_are(ooni_exe, tk, desired):
def webconnectivity_https_ok_with_control_failure(ooni_exe, outfile):
"""Successful HTTPS measurement but control failure."""
args = [
"-iptables-reset-keyword",
"wcth.ooni.io",
"-iptables-reset-keyword",
"th.ooni.org",
]
Expand Down Expand Up @@ -83,8 +81,6 @@ def webconnectivity_https_ok_with_control_failure(ooni_exe, outfile):
def webconnectivity_http_ok_with_control_failure(ooni_exe, outfile):
"""Successful HTTP measurement but control failure."""
args = [
"-iptables-reset-keyword",
"wcth.ooni.io",
"-iptables-reset-keyword",
"th.ooni.org",
]
Expand Down Expand Up @@ -194,8 +190,6 @@ def webconnectivity_control_unreachable_and_using_http(ooni_exe, outfile):
plaintext HTTP protocol rather than HTTPS"""
args = []
args.append("-iptables-reset-keyword")
args.append("wcth.ooni.io")
args.append("-iptables-reset-keyword")
args.append("th.ooni.org")
tk = execute_jafar_and_return_validated_test_keys(
ooni_exe,
Expand Down Expand Up @@ -224,7 +218,7 @@ def webconnectivity_nonexistent_domain(ooni_exe, outfile):
tk = execute_jafar_and_return_validated_test_keys(
ooni_exe,
outfile,
"-i http://antani.ooni.io web_connectivity",
"-i http://www.ooni.nonexistent web_connectivity",
"webconnectivity_nonexistent_domain",
args,
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/apitool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func newclient() probeservices.Client {
ua := fmt.Sprintf("apitool/%s ooniprobe-engine/%s", version.Version, version.Version)
return probeservices.Client{
APIClientTemplate: httpx.APIClientTemplate{
BaseURL: "https://ams-pg.ooni.org/",
BaseURL: "https://api.ooni.io/",
HTTPClient: &http.Client{Transport: txp},
Logger: log.Log,
UserAgent: ua,
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/jafar/httpproxy/httpproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestBlock(t *testing.T) {
// Here we're filtering any domain containing ooni.io, so we
// expect the proxy to send 451 without actually proxing, thus
// there should not be any Via header in the output.
checkrequest(t, addr.String(), "mia-ps.ooni.io", 451, false)
checkrequest(t, addr.String(), "api.ooni.io", 451, false)
killproxy(t, server)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/jafar/tlsproxy/tlsproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestPass(t *testing.T) {
func TestBlock(t *testing.T) {
listener := newproxy(t, "ooni.io")
checkdialtls(t, listener.Addr().String(), false, &tls.Config{
ServerName: "mia-ps.ooni.io",
ServerName: "api.ooni.io",
})
killproxy(t, listener)
}
Expand Down
26 changes: 14 additions & 12 deletions internal/cmd/oohelper/internal/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestOOClientDoWithEmptyServerURL(t *testing.T) {

func TestOOClientDoWithInvalidTargetURL(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{TargetURL: "\t", ServerURL: "https://wcth.ooni.io"}
config := internal.OOConfig{TargetURL: "\t", ServerURL: "https://0.th.ooni.org"}
clnt := internal.OOClient{}
cresp, err := clnt.Do(ctx, config)
if !errors.Is(err, internal.ErrInvalidURL) {
Expand All @@ -104,7 +104,7 @@ func TestOOClientDoWithResolverFailure(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{
TargetURL: "http://www.example.com",
ServerURL: "https://wcth.ooni.io",
ServerURL: "https://0.th.ooni.org",
}
clnt := internal.OOClient{
HTTPClient: http.DefaultClient,
Expand All @@ -114,10 +114,12 @@ func TestOOClientDoWithResolverFailure(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if len(cresp.TCPConnect) > 0 {
// The current implementation of the test helper (the legacy codebase)
// only follows the IP addresses returned by the client.
t.Fatal("expected empty TCPConnect here")
if len(cresp.TCPConnect) <= 0 {
// The legacy implementation of the test helper (the legacy codebase)
// only follows the IP addresses returned by the client. However, since
// https://github.com/ooni/probe-cli/pull/890, the TH is following the
// IP addresses from the probe as well as its own addresses.
t.Fatal("expected non-empty TCPConnect here")
}
if cresp.HTTPRequest.StatusCode != 200 {
t.Fatal("expected 200 status code here")
Expand All @@ -131,7 +133,7 @@ func TestOOClientDoWithUnsupportedExplicitPort(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{
TargetURL: "http://www.example.com:8080",
ServerURL: "https://wcth.ooni.io",
ServerURL: "https://0.th.ooni.org",
}
clnt := internal.OOClient{
Resolver: internal.NewFakeResolverWithResult([]string{"1.1.1.1"}),
Expand Down Expand Up @@ -168,7 +170,7 @@ func TestOOClientDoWithRoundTripError(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{
TargetURL: "http://www.example.com",
ServerURL: "https://wcth.ooni.io",
ServerURL: "https://0.th.ooni.org",
}
clnt := internal.OOClient{
Resolver: internal.NewFakeResolverWithResult([]string{"1.1.1.1"}),
Expand All @@ -189,7 +191,7 @@ func TestOOClientDoWithInvalidStatusCode(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{
TargetURL: "http://www.example.com",
ServerURL: "https://wcth.ooni.io",
ServerURL: "https://0.th.ooni.org",
}
clnt := internal.OOClient{
Resolver: internal.NewFakeResolverWithResult([]string{"1.1.1.1"}),
Expand All @@ -214,7 +216,7 @@ func TestOOClientDoWithBodyReadError(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{
TargetURL: "http://www.example.com",
ServerURL: "https://wcth.ooni.io",
ServerURL: "https://0.th.ooni.org",
}
clnt := internal.OOClient{
Resolver: internal.NewFakeResolverWithResult([]string{"1.1.1.1"}),
Expand All @@ -240,7 +242,7 @@ func TestOOClientDoWithInvalidJSON(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{
TargetURL: "http://www.example.com",
ServerURL: "https://wcth.ooni.io",
ServerURL: "https://0.th.ooni.org",
}
clnt := internal.OOClient{
Resolver: internal.NewFakeResolverWithResult([]string{"1.1.1.1"}),
Expand Down Expand Up @@ -290,7 +292,7 @@ func TestOOClientDoWithParseableJSON(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{
TargetURL: "http://www.example.com",
ServerURL: "https://wcth.ooni.io",
ServerURL: "https://0.th.ooni.org",
}
clnt := internal.OOClient{
Resolver: internal.NewFakeResolverWithResult([]string{"1.1.1.1"}),
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/oohelper/oohelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func main() {
func wcth() interface{} {
serverURL := *server
if serverURL == "" {
serverURL = "https://wcth.ooni.io/"
serverURL = "https://0.th.ooni.org/"
}
clnt := internal.OOClient{HTTPClient: httpClient, Resolver: resolver}
config := internal.OOConfig{TargetURL: *target, ServerURL: serverURL}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/oohelperd/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestDNSDo(t *testing.T) {
t.Run("returns non-nil addresses list on nxdomin", func(t *testing.T) {
ctx := context.Background()
config := &dnsConfig{
Domain: "antani.ooni.org",
Domain: "www.ooni.nonexistent",
Logger: model.DiscardLogger,
NewResolver: func(model.Logger) model.Resolver {
return &mocks.Resolver{
Expand Down
5 changes: 1 addition & 4 deletions internal/engine/probeservices/benchselect.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import (
// Default returns the default probe services
func Default() []model.OOAPIService {
return []model.OOAPIService{{
Address: "https://ps1.ooni.io",
Type: "https",
}, {
Address: "https://ps2.ooni.io",
Address: "https://api.ooni.io",
Type: "https",
}, {
Front: "dkyhjv0wpi2dk.cloudfront.net",
Expand Down
52 changes: 9 additions & 43 deletions internal/engine/probeservices/probeservices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"io"
"net/http"
"regexp"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -399,31 +398,24 @@ func TestTryAllIntegrationWeRaceForFastestHTTPS(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
const pattern = "^https://ps[1-4].ooni.io$"
// put onion first so we also verify that we sort the endpoints
in := []model.OOAPIService{{
Type: "onion",
Address: "httpo://jehhrikjjqrlpufu.onion",
}, {
Type: "https",
Address: "https://ps1.ooni.io",
}, {
Type: "https",
Address: "https://ps2.ooni.io",
Address: "https://api.ooni.io",
}, {
Front: "dkyhjv0wpi2dk.cloudfront.net",
Type: "cloudfront",
Address: "https://dkyhjv0wpi2dk.cloudfront.net",
}, {
Type: "https",
Address: "https://ps3.ooni.io",
}}
sess := &mockable.Session{
MockableHTTPClient: http.DefaultClient,
MockableLogger: log.Log,
}
out := probeservices.TryAll(context.Background(), sess, in)
if len(out) != 3 {
if len(out) != 1 {
t.Fatal("invalid number of entries")
}
//
Expand All @@ -436,34 +428,8 @@ func TestTryAllIntegrationWeRaceForFastestHTTPS(t *testing.T) {
if out[0].Endpoint.Type != "https" {
t.Fatal("invalid endpoint type")
}
if ok, _ := regexp.MatchString(pattern, out[0].Endpoint.Address); !ok {
t.Fatal("invalid endpoint type")
}
//
if out[1].Duration <= 0 {
t.Fatal("invalid duration")
}
if out[1].Err != nil {
t.Fatal("invalid error")
}
if out[1].Endpoint.Type != "https" {
t.Fatal("invalid endpoint type")
}
if ok, _ := regexp.MatchString(pattern, out[1].Endpoint.Address); !ok {
t.Fatal("invalid endpoint type")
}
//
if out[2].Duration <= 0 {
t.Fatal("invalid duration")
}
if out[2].Err != nil {
t.Fatal("invalid error")
}
if out[2].Endpoint.Type != "https" {
t.Fatal("invalid endpoint type")
}
if ok, _ := regexp.MatchString(pattern, out[2].Endpoint.Address); !ok {
t.Fatal("invalid endpoint type")
if out[0].Endpoint.Address != "https://api.ooni.io" {
t.Fatal("invalid endpoint address")
}
}

Expand Down Expand Up @@ -574,32 +540,32 @@ func TestSelectBestSelectsTheFastest(t *testing.T) {
in := []*probeservices.Candidate{{
Duration: 10 * time.Millisecond,
Endpoint: model.OOAPIService{
Address: "https://ps1.ooni.io",
Address: "https://ps1.ooni.nonexistent",
Type: "https",
},
}, {
Duration: 4 * time.Millisecond,
Endpoint: model.OOAPIService{
Address: "https://ps2.ooni.io",
Address: "https://ps2.ooni.nonexistent",
Type: "https",
},
}, {
Duration: 7 * time.Millisecond,
Endpoint: model.OOAPIService{
Address: "https://ps3.ooni.io",
Address: "https://ps3.ooni.nonexistent",
Type: "https",
},
}, {
Duration: 11 * time.Millisecond,
Endpoint: model.OOAPIService{
Address: "https://ps4.ooni.io",
Address: "https://ps4.ooni.nonexistent",
Type: "https",
},
}}
expected := &probeservices.Candidate{
Duration: 4 * time.Millisecond,
Endpoint: model.OOAPIService{
Address: "https://ps2.ooni.io",
Address: "https://ps2.ooni.nonexistent",
Type: "https",
},
}
Expand Down
4 changes: 2 additions & 2 deletions internal/engine/sessionresolver/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func TestLittleLLookupHostWithSuccess(t *testing.T) {
},
}
ctx := context.Background()
ri := &resolverinfo{URL: "dot://dns-nonexistent.ooni.org", Score: 0.1}
ri := &resolverinfo{URL: "dot://www.ooni.nonexistent", Score: 0.1}
addrs, err := reso.lookupHost(ctx, ri, "dns.google")
if err != nil {
t.Fatal(err)
Expand All @@ -159,7 +159,7 @@ func TestLittleLLookupHostWithFailure(t *testing.T) {
},
}
ctx := context.Background()
ri := &resolverinfo{URL: "dot://dns-nonexistent.ooni.org", Score: 0.95}
ri := &resolverinfo{URL: "dot://www.ooni.nonexistent", Score: 0.95}
addrs, err := reso.lookupHost(ctx, ri, "dns.google")
if !errors.Is(err, errMocked) {
t.Fatal("not the error we expected", err)
Expand Down
4 changes: 2 additions & 2 deletions internal/netxlite/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestMeasureWithSystemResolver(t *testing.T) {
r := netxlite.NewStdlibResolver(log.Log)
defer r.CloseIdleConnections()
ctx := context.Background()
addrs, err := r.LookupHost(ctx, "antani.ooni.org")
addrs, err := r.LookupHost(ctx, "www.ooni.nonexistent")
if err == nil || err.Error() != netxlite.FailureDNSNXDOMAINError {
t.Fatal("not the error we expected", err)
}
Expand All @@ -75,7 +75,7 @@ func TestMeasureWithSystemResolver(t *testing.T) {
// Implementation note: Windows' resolver has caching so back to back tests
// will fail unless we query for something that could bypass the cache itself
// e.g. a domain containing a few random letters
addrs, err := r.LookupHost(ctx, randx.Letters(7)+".ooni.org")
addrs, err := r.LookupHost(ctx, randx.Letters(7)+".ooni.nonexistent")
if err == nil || err.Error() != netxlite.FailureGenericTimeoutError {
t.Fatal("not the error we expected", err)
}
Expand Down