ooni-probe-cli/internal/engine/experiment/webconnectivity
Simone Basso c2ea0b4704
feat(webconnectivity): try all the available THs (#980)
We introduce a fork of internal/httpx, named internal/httpapi, where there is a clear split between the concept of an API endpoint (such as https://0.th.ooni.org/) and of an API descriptor (such as using `GET` to access /api/v1/test-list/url).

Additionally, httpapi allows to create a SequenceCaller that tries to call a given API descriptor using multiple API endpoints. The SequenceCaller will stop once an endpoint works or when all the available endpoints have been tried unsuccessfully.

The definition of "success" is the following: we consider "failure" any error that occurs during the HTTP round trip or when reading the response body. We DO NOT consider "failure" errors (1) when parsing the input URL; (2) when the server returns >= 400; (3) when the server returns a string that does not parse as valid JSON. The idea of this classification of failures is that we ONLY want to retry when we see what looks like a network error that may be caused by (collateral or targeted) censorship.

We take advantage of the availability of this new package and we refactor web_connectivity@v0.4 and web_connectivity@v0.5 to use a SequenceCaller for calling the web connectivity TH API. This means that we will now try all the available THs advertised by the backend rather than just selecting and using the first one provided by the backend.

Because this diff is designed to be backported to the `release/3.16` branch, we have omitted additional changes to always use httpapi where we are currently using httpx. Yet, to remind ourselves about the need to do that, we have deprecated the httpx package. We will rewrite all the code currently using httpx to use httpapi as part of future work.

It is also worth noting that httpapi will allow us to refactor the backend code such that (1) we remove code to select a backend URL endpoint at the beginning and (2) we try several endpoints. The design of the code is such that we can add to the mix some endpoints using as `http.Client` a special client using a tunnel. This will allow us to automatically fallback backend queries.

Closes https://github.com/ooni/probe/issues/2353.

Related to https://github.com/ooni/probe/issues/1519.
2022-11-21 16:28:53 +01:00
..
internal chore: merge probe-engine into probe-cli (#201) 2021-02-02 12:05:47 +01:00
connects_test.go chore: merge probe-engine into probe-cli (#201) 2021-02-02 12:05:47 +01:00
connects.go refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
control_test.go refactor: move TH structs and definitions to model (#894) 2022-08-28 20:20:12 +02:00
control.go feat(webconnectivity): try all the available THs (#980) 2022-11-21 16:28:53 +01:00
dnsanalysis_test.go netxlite: call getaddrinfo and handle platform-specific oddities (#764) 2022-05-28 15:10:30 +02:00
dnsanalysis.go refactor: move TH structs and definitions to model (#894) 2022-08-28 20:20:12 +02:00
dnslookup_test.go chore: merge probe-engine into probe-cli (#201) 2021-02-02 12:05:47 +01:00
dnslookup.go cleanup: use ErrorToStringOrOK func in other tests that returns nil (#701) 2022-03-08 11:59:44 +01:00
doc.go fix: ensure experiments return nil when we want to submit (#654) 2022-01-07 13:17:20 +01:00
endpoints_test.go refactor: flatten and separate (#353) 2021-06-04 10:34:18 +02:00
endpoints.go refactor: flatten and separate (#353) 2021-06-04 10:34:18 +02:00
httpanalysis_test.go refactor: move tracex outside of engine/netx (#782) 2022-06-02 00:50:55 +02:00
httpanalysis.go refactor: move WebGetTitle inside measurexlite (#895) 2022-08-28 20:26:40 +02:00
httpget_test.go fix(webconnectivity): allow measuring https://1.1.1.1 (#241) 2021-03-08 12:05:43 +01:00
httpget.go cleanup: use ErrorToStringOrOK func in other tests that returns nil (#701) 2022-03-08 11:59:44 +01:00
summary_test.go refactor: move tracex outside of engine/netx (#782) 2022-06-02 00:50:55 +02:00
summary.go netxlite: call getaddrinfo and handle platform-specific oddities (#764) 2022-05-28 15:10:30 +02:00
webconnectivity_test.go feat(webconnectivity): try all the available THs (#980) 2022-11-21 16:28:53 +01:00
webconnectivity.go feat(webconnectivity): try all the available THs (#980) 2022-11-21 16:28:53 +01:00