Commit Graph

1196 Commits

Author SHA1 Message Date
Simone Basso
2fa87f0e00
fix(wcth): match legacy TH w/ empty DNS reply (#546)
See https://github.com/ooni/probe/issues/1707#issuecomment-944322725
2021-10-15 16:20:07 +02:00
Simone Basso
2d1666b88b
fix(wcth): emit empty Addrs when input URL contains addr (#545)
Matches the behavior that the legacy TH implements in this
situation and reduces slightly the differences.

See https://github.com/ooni/probe/issues/1707#issuecomment-944143329
2021-10-15 12:00:20 +02:00
Simone Basso
730b00ff73
fix(ooniprobe): Measure returns EITHER measurement OR error now (#544)
See https://github.com/ooni/probe/issues/1816

This diff addresses the most immediate issue but there is probably
extra work to do, including testing and making sure experiments
do not return an error when they should not.
2021-10-14 12:16:55 +02:00
Simone Basso
4b8cae692b
fix(oohelperd): reduce errors to what the old TH would emit (#543)
Reducing the errors is not done in a perfect way.

We have documented the most striking differences inside
https://github.com/ooni/probe/issues/1707#issuecomment-942283746 and
some attempts to improve the situation further inside
https://github.com/ooni/probe/issues/1707#issuecomment-942341255.

A better strategy for the future would be to introduce more
specific timeout errors, such as dns_timeout_error, etc.

More testing may be needed to further validate and compare the
old and the new TH, but this requires Jafar improvements to
more precisely simulate more complex censorship.
2021-10-13 16:37:02 +02:00
Simone Basso
299834174a
fix(webconnectivity): gather longer HTML titles (#542)
Allows us to get http://www.isa.gov.il/Pages/default.aspx's one.

Discovered when working on https://github.com/ooni/probe/issues/1707.
2021-10-13 13:50:22 +02:00
Simone Basso
9e365661f0
fix(oohelperd): return HTTP headers as empty map on error (#541)
Part of https://github.com/ooni/probe/issues/1707
2021-10-13 13:27:09 +02:00
Simone Basso
43c349fe38
feat: annotate measurements with their architecture (#540)
Closes https://github.com/ooni/probe/issues/1772
2021-10-13 10:31:46 +02:00
Arturo Filastò
46e00888ae
Edits to the measurex tutorial (#534) 2021-10-11 17:48:45 +02:00
Simone Basso
1ffb2db0ca
fix(measurex): quic follow-up only with https scheme (#538)
Closes https://github.com/ooni/probe/issues/1799
2021-10-05 13:02:56 +02:00
Simone Basso
a6318d6de9
feat(webconnectivity): collect timing information (#537)
Work related to https://github.com/ooni/probe/issues/1797
2021-10-05 12:52:19 +02:00
Simone Basso
3f511d100b
fix(websteps): use correct input for each URL measurement (#536)
Closes https://github.com/ooni/probe/issues/1798
2021-10-05 12:29:00 +02:00
Simone Basso
9b52a050ba
fix: add missing reference to netxlite's tutorial (#535)
See https://github.com/ooni/probe-cli/pull/506
2021-10-04 15:37:48 +02:00
Simone Basso
762fb27c0b
fix(netxlite/quic): close udp conn after failed handshake (#533)
Closes https://github.com/ooni/probe/issues/1794
2021-09-30 18:00:38 +02:00
Simone Basso
86018ecb82
fix(measurex): make sure we don't redirect loop forever (#532)
This is the most immediate fix to the issue described by
https://github.com/ooni/probe/issues/1792.

So, the logic was actually miss the increment, which
would have been noticed with proper unit testing.

Anyway, I am not sure why the loop ensues in the first
time. By looking at the headers, it seems we're passing
the headers correctly.

So, even though this fix interrupts the loop, it still
remains the question of whether the loop is legit or
whether we're missing extra logic to properly redirect.
2021-09-30 14:07:25 +02:00
Simone Basso
ba9151d4fa
feat(webstepsx): websteps using measurex (#530)
This diff adds the prototype websteps implementation that used
to live at https://github.com/ooni/probe-cli/pull/506.

The code is reasonably good already and it's pointing to a roaming
test helper that I've properly configured.

You can run websteps with:

```
./miniooni -n websteps
```

This will go over the test list for your country.

At this stage the mechanics of the experiment is set, but we
still need to have a conversation on the following topics:

1. whether we're okay with reusing the data format used by other
OONI experiments, or we would like to use a more compact data
format (which may either be a more compact JSON or we can choose
to always submit compressed measurements for websteps);

2. the extent to which we would like to keep the measurement as
a collection of "the experiment saw this" and "the test helper
saw that" and let the pipeline choose an overall score: this is
clearly an option, but there is also the opposite option to
build a summary of the measurement on the probe.

Compared to the previous prototype of websteps, the main
architectural change we have here is that we are following
the point of view of the probe and the test helper is
much more dumb. Basically, the probe will choose which
redirection to follow and ask the test helper every time
it discovers a new URL to measure it w/o redirections.

Reference issue: https://github.com/ooni/probe/issues/1733
2021-09-30 02:06:27 +02:00
Simone Basso
d45e58c14f
doc(measurex): explain how to write experiments (#529)
Part of https://github.com/ooni/ooni.org/issues/361

Co-authored-by: Arturo Filastò <arturo@openobservatory.org>
2021-09-30 01:36:03 +02:00
Simone Basso
399d2f65da
feat(measurex): refactored measurement library (#528)
This commit introduce a measurement library that consists of
refactored code from earlier websteps experiments.

I am not going to add tests for the time being, because this library
is still a bit in flux, as we finalize websteps.

I will soon though commit documentation explaining in detail how
to use it, which currrently is at https://github.com/ooni/probe-cli/pull/506
and adds a new directory to internal/tutorial.

The core idea of this measurement library is to allow two
measurement modes:

1. tracing, which is what we're currently doing now, and the
tutorial shows how we can rewrite the measurement part of web
connectivity with measurex using less code. Under a tracing
approach, we construct a normal http.Client that however has
tracing configured, we gather events for resolve, connect, TLS
handshake, QUIC handshake, HTTP round trip, etc. and then we
try to make sense of what happened from the events stream;

2. step-by-step, which is what websteps does, and basically
means that after each operation you immediately write into
a Measurement structure its results and immediately draw the
conclusions on what seems odd (which later may become an
anomaly if we see what the test helper measured).

This library is also such that it produces a data format
compatible with the current OONI spec.

This work is part of https://github.com/ooni/probe/issues/1733.
2021-09-30 01:24:08 +02:00
Simone Basso
ff1c170562
feat(engine): allow runner to return many measurements (#527)
This is required to implement websteps, which is currently tracked
by https://github.com/ooni/probe/issues/1733.

We introduce the concept of async runner. An async runner will
post measurements on a channel until it is done. When it is done,
it will close the channel to notify the reader about that.

This change causes sync experiments now to strictly return either
a non-nil measurement or a non-nil error.

While this is a pretty much obvious situation in golang, we had
some parts of the codebase that were not robust to this assumption
and attempted to submit a measurement after the measure call
returned an error.

Luckily, we had enough tests to catch this change in our assumption
and this is why there are extra docs and tests changes.
2021-09-30 00:54:52 +02:00
Simone Basso
8931a36cb3
fix(netxlite): make test less flaky on macOS (#526)
The explanatory comment in the diff says it all.

Work done while I was converging with https://github.com/ooni/probe/issues/1733.
2021-09-30 00:25:05 +02:00
Simone Basso
24a6ac9a5f
fix(ooapi): disable tests we're not using (#525)
At the moment ooapi is not used. It will eventually be used since
it's a better way of accessing the OONI backend API.

To fix these tests, we need to fix the swagger emitted by the
backend API, which is not a priority at the moment, since we are
working instead to integrate websteps in miniooni.

Issue https://github.com/ooni/probe/issues/1790 tracks the work
required to re-enabled the tests I'm skipping with this diff.

This work is part of https://github.com/ooni/probe/issues/1733.
2021-09-30 00:04:11 +02:00
Simone Basso
26f84ccc20
fix(resolver_test.go): remove race and make deterministic (#524)
Should fix https://github.com/ooni/probe-cli/pull/523#issuecomment-930430124.

Work part of https://github.com/ooni/probe-cli/pull/506.
2021-09-29 20:33:39 +02:00
Simone Basso
b2b1a4b2f1
doc(netxlite): revamp the documentation (#523)
Part of https://github.com/ooni/probe-cli/pull/506. In parallel with
tutorials, we also need to make sure we have good documentation.
2021-09-29 20:21:25 +02:00
Simone Basso
b9a844ecee
feat: run ~always netxlite integration tests (#522)
* feat: run ~always netxlite integration tests

This diff ensures that we check on windows, linux, macos that our
fundamental networking library (netxlite) works.

We combine unit and integration tests.

This work is part of https://github.com/ooni/probe/issues/1733, where
I want to have more strong guarantees about the foundations.

* fix(filtering/tls_test.go): make portable on Windows

The trick here is to use the wrapped error so to normalize the
different errors messages we see on Windows.

* fix(netxlite/quic_test.go): make portable on windows

Rather than using the zero port, use the `x` port which fails
when the stdlib is parsing the address.

The zero port seems to work on Windows while it does not on Unix.

* fix(serialresolver_test.go): make error more timeout than before

This seems enough to convince Go on Windows about this error
being really a timeout timeouty timeouted thingie.
2021-09-29 16:04:26 +02:00
Simone Basso
9967803c31
fix(netxlite): map additional GetAddrInfoW errors (#521)
On Windows, GetAddrInfoW is a syscall and the Go resolver does
not attempt to map errors beyond WSA_HOST_NOT_FOUND, which becomes
"no such host", which we map to "dns_nxdomain_error".

See https://github.com/golang/go/blob/go1.17.1/src/net/lookup_windows.go#L16.

To map more GetAddrInfoW errors, thus, we need to enhance our
error classifier to have system specific errors.

Then, we need to filter for the WSA errors that are most likely
to pop up and map them to OONI failures. Those are three:

- WSANO_DATA which we have from our own UDP resolver as well
and which we can map to `dns_no_answer`

- WSANO_RECOVERY which we don't have but existed for MK so
we will use `dns_non_recoverable_failure`, which was an MK error

- WSATRY_AGAIN which likewise we map to the error that MK
used to emit, so `dns_temporary_failure`

This diff should address https://github.com/ooni/probe/issues/1467.
2021-09-29 11:21:28 +02:00
Simone Basso
9523753b87
fix: allow to build miniooni for windows (#520)
I need to run test on Windows and I just discovered that:

1. the `errno_unix.go` filename does not mean anything because
`unix` is not a valid platform, so we need a filename for
each platform that we care about;

2. on Windows we need to use WSA prefixed names;

3. `i/e/session_psiphon.go` was not building because of the
migration from `netxlite/iox` to `netxlite`.

This diff attempts to fix all three issues.

The reference issue is https://github.com/ooni/probe/issues/1733,
because I was working on such an issue.
2021-09-28 18:27:28 +02:00
Simone Basso
9ef4d9df7d
doc: add tutorial on how to use netxlite (#519)
The main tutorial will be the one at https://github.com/ooni/probe-cli/pull/506, but
it's useful to also document the primitives used by measurex.

So, here's the companion tutorial, which explains how to use the
features in netxlite to perform measurements.

This work is part of https://github.com/ooni/ooni.org/issues/361.
2021-09-28 18:15:38 +02:00
Simone Basso
1fd2b1fd53
feat(oonimkall): instrument code to understand CI issue (#518)
* feat(oonimkall): instrument code to understand CI issue

It seems ~difficult to reproduce the problem locally and I could not
see it after five runs of

```
go test -race -count 1 ./pkg/oonimkall/...
```

So, here's some diagnostic code that could help understanding the
reference issue https://github.com/ooni/probe/issues/1785.

Also, it seems the issue pops up much more frequently when running
CI anyway. So, I am going to leave this diff around and when it
appears again I have more context to fix the issue.

* fix(oonimkall): skip flaky test in short mode

See https://github.com/ooni/probe/issues/1785
2021-09-28 13:41:41 +02:00
Simone Basso
6d3a4f1db8
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
2021-09-28 12:42:01 +02:00
Simone Basso
de130d249c
refactor(dnsx): group tests together (#516)
Part of https://github.com/ooni/probe/issues/1591
2021-09-28 11:26:16 +02:00
Simone Basso
12cf4b9990
refactor(dnsx): prepare for merging with netxlite (#515)
Part of https://github.com/ooni/probe/issues/1591
2021-09-28 10:47:59 +02:00
Simone Basso
8b9fe1a160
feat(netxlite): implement LookupHTTPS (#514)
This new API call performs DNS lookups for HTTPS records.

Part of https://github.com/ooni/probe/issues/1733 and diff has been
extracted from https://github.com/ooni/probe-cli/pull/506.
2021-09-27 23:09:41 +02:00
Simone Basso
c6b69cbee8
fix(ooniprobe-cli.timer): run every 12h (#512)
See https://github.com/ooni/probe/issues/1786.
2021-09-27 22:02:51 +02:00
Simone Basso
24b230fd38
fix(netxlite/dns): more stricly mirror stdlib error strings (#513)
This diff attempts to modify the errors reported by our custom
resolver by matching more strings from the stdlib.

Part of https://github.com/ooni/probe/issues/1733 and diff has been
extracted from https://github.com/ooni/probe-cli/pull/506.
2021-09-27 16:48:46 +02:00
Simone Basso
201f602a40
feat(errorsx): introduce NewTopLevelGenericErrWrapper (#511)
Part of https://github.com/ooni/probe/issues/1733 and diff has been
extracted from https://github.com/ooni/probe-cli/pull/506.
2021-09-27 14:55:47 +02:00
Simone Basso
d7b9c8f0a8
fix(netxlite/errorsx): map "use of closed network connection" (#510)
Part of https://github.com/ooni/probe/issues/1733 and diff has been
extracted from https://github.com/ooni/probe-cli/pull/506.
2021-09-27 14:40:25 +02:00
Simone Basso
273774bb03
fix(netxlite/quic): wrap Close (#509)
While there, make sure netxlite has 100% coverage.

Part of https://github.com/ooni/probe/issues/1733 and diff
has been extracted from https://github.com/ooni/probe-cli/pull/506.
2021-09-27 14:14:17 +02:00
Simone Basso
deb1589bdb
fix(netxlite): do not mutate outgoing requests (#508)
I have recently seen a data race related our way of
mutating the outgoing request to set the host header.

Unfortunately, I've lost track of the race output,
because I rebooted my Linux box before saving it.

Though, after inspecting why and and where we're mutating
outgoing requets, I've found that:

1. we add the host header when logging to have it logged,
which is not a big deal since we already emit the URL
rather than just the URL path when logging a request, and
so we can safely zap this piece of code;

2. as a result, in measurements we may omit the host header
but again this is pretty much obvious from the URL itself
and so it should not be very important (nonetheless,
avoid surprises and keep the existing behavior);

3. when the User-Agent header is not set, we default to
a `miniooni/0.1.0-dev` user agent, which is probably not
very useful anyway, so we can actually remove it.

Part of https://github.com/ooni/probe/issues/1733 (this diff
has been extracted from https://github.com/ooni/probe-cli/pull/506).
2021-09-27 13:35:47 +02:00
Simone Basso
741a8bc4c2
feat(netxlite): introduce wrapping constructors (#507)
This diff has been extracted from https://github.com/ooni/probe-cli/pull/506.

In it, we introduce wrapping constructors for types and we
update the docs. These new constructures are used by the code
in https://github.com/ooni/probe-cli/pull/506.

In itself, this work is part of https://github.com/ooni/probe/issues/1733.
2021-09-27 12:00:43 +02:00
Simone Basso
985c1ba761
fix(oohelperd): reduce differences with legacy helper (#504)
Part of https://github.com/ooni/probe/issues/1707
2021-09-27 08:13:30 +02:00
Simone Basso
3cb782f0a2
refactor(netx): move dns transports in netxlite/dnsx (#503)
While there, modernize the way in which we run tests to avoid
depending on the fake files scattered around the tree and to
use some well defined mock structures instead.

Part of https://github.com/ooni/probe/issues/1591
2021-09-09 21:24:27 +02:00
Simone Basso
b3c36b5c7f
refactor(resolver): add CloseIdleConnections to SerialResolver (#502)
While there, generally convert more code to internal testing
and to using pointer receivers as well.

Part of https://github.com/ooni/probe/issues/1591.
2021-09-09 20:58:04 +02:00
Simone Basso
1eb9e8c9b0
refactor(netx/resolver): add CloseIdleConnections to RoundTripper (#501)
While there, also change to pointer receiver and use internal
testing for what are clearly unit tests.

Part of https://github.com/ooni/probe/issues/1591.
2021-09-09 20:49:12 +02:00
Simone Basso
5ab3c3b689
refactor(netx): use netxlite for AddressResolver (#500)
Part of https://github.com/ooni/probe/issues/1591.
2021-09-09 20:21:43 +02:00
Simone Basso
254a5511e9
doc(oohelper): tweak documentation (#499)
Part of https://github.com/ooni/probe/issues/1733
2021-09-09 19:55:23 +02:00
Simone Basso
c54cc73afa
refactor(oohelper): remove unnecessary dep from netx (#498)
There are a bunch of packages where we don't really need to depend
on netx but we can use local definitions that describe what we are
expecting from data structures we receive in input. This diff
addresses one of such cases.

Part of https://github.com/ooni/probe/issues/1591
2021-09-09 19:40:03 +02:00
Simone Basso
b5826a0c44
refactor(jafar): remove unnecessary dep on netx (#497) 2021-09-09 18:01:20 +02:00
Simone Basso
1d79d70b43
refactor: migrate apitool from netx to netxlite (#496)
I discovered which transport were used by apitool and made sure he gets the same transports now. While there, I discovered an issue with ooni/oohttp that has been fixed with cba9b1ce5e.

Part of https://github.com/ooni/probe/issues/1591
2021-09-09 01:19:17 +02:00
Simone Basso
00a85cb7f0
fix(quic): properly unwrap OONI errors from TransportError (#495)
Noticed while playing around with QUIC code.

Part of https://github.com/ooni/probe/issues/1544.
2021-09-09 00:07:38 +02:00
Simone Basso
50b58672c6
netxlite: code quality, improve tests, docs (#494)
See https://github.com/ooni/probe/issues/1591
2021-09-08 22:48:10 +02:00
Simone Basso
3cd88debdc
netxlite: improve docs, tests, and code quality (#493)
* netxlite: improve docs, tests, and code quality

* better documentation

* more strict testing of dialer (especially make sure we
document the quirk in https://github.com/ooni/probe/issues/1779
and we have tests to guarantee we don't screw up here)

* introduce NewErrWrapper factory for creating errors so we
have confidence we are creating them correctly

Part of https://github.com/ooni/probe/issues/1591
2021-09-08 21:19:51 +02:00