Commit Graph

828 Commits

Author SHA1 Message Date
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
Simone Basso
e68adec9a5
fix(netxlite): http3 transport needs logging by default (#492)
Adapt other places where it was not using a logger to either choose
a reasonable logger or disable logging for backwards compat.

See https://github.com/ooni/probe/issues/1591
2021-09-08 20:49:01 +02:00
Simone Basso
18b2eb37ff
fix(netxlite/errorsx): serialize directly to JSON (#491)
This simplifies serializing errors to `*string`. It did not
occur to me before. It seems quite a nice improvement.

Part of https://github.com/ooni/probe/issues/1591
2021-09-08 17:42:36 +02:00
Simone Basso
957185d659
doc(netxlite/tls.go): explain what the handshake returns (#490)
Part of https://github.com/ooni/probe/issues/1591
2021-09-08 17:21:51 +02:00
Simone Basso
26360f5a29
feat(netxlite): introduce null dialers (#489)
See https://github.com/ooni/probe/issues/1591
2021-09-08 14:46:17 +02:00
Simone Basso
f2e3e5cc08
refactor(netxlite): finish grouping tests (#488)
They are now more readable. I'll do another pass and start
separating integration testing from unit testing.

I think we need to have some always on integration testing
for netxlite that runs on macOS, linux, and windows.

See https://github.com/ooni/probe/issues/1591
2021-09-08 11:39:27 +02:00
Simone Basso
493b72b170
refactor(netxlite): improve tests for http and http3 (#487)
* refactor(netxlite): improve tests for http and http3

See https://github.com/ooni/probe/issues/1591

* Update internal/netxlite/http3.go
2021-09-08 00:59:48 +02:00
Simone Basso
6d39118b26
refactor(netxlite): restructure dialer tests (#486)
While there, add one more test checking for whether the internal
CA bundle we use can actually be loaded.

Part of https://github.com/ooni/probe/issues/1591
2021-09-08 00:00:53 +02:00
Simone Basso
f054ec3201
refactor(netxlite/mocks): group tests, fix naming inconsistencies (#485)
Part of https://github.com/ooni/probe/issues/1591
2021-09-07 23:12:23 +02:00
Simone Basso
9e82e37ab8
refactor(netxlite/iox): group tests and avoid races (#484)
Part of https://github.com/ooni/probe/issues/1591
2021-09-07 22:41:34 +02:00
Simone Basso
1472f7530b
refactor(netxlite/errorsx): change all tests to be unit tests (#483)
Later we will try to write comprehensive integration tests for
the whole netxlite package. We want just unit tests here.
2021-09-07 22:10:29 +02:00
Simone Basso
b7786a7324
refactor(netxlite/errorsx): extract string-suffix classifier (#482)
This change makes the code more tidy and easier to read.

No functional change, though.

See https://github.com/ooni/probe/issues/1591.
2021-09-07 21:18:26 +02:00
Simone Basso
a56b284b0e
refactor(netxlite/errors): improve docs and format code (#481)
No real functional change. A few are needed and they will come
next. With this diff I just wanted to do cosmetic changes and
documentation changes, to ensure this package is okay.

See https://github.com/ooni/probe/issues/1591
2021-09-07 20:39:32 +02:00
Simone Basso
323266da83
fix(netxlite): add error wrappers (#480)
See https://github.com/ooni/probe/issues/1591
2021-09-07 19:56:42 +02:00
Simone Basso
ee78c76085
refactor: i/errorsx is now i/legacy/errorsx (#479)
We need still to add similar wrappers to internal/netxlite but we
will adopt a saner approach to error wrapping this time.

See https://github.com/ooni/probe/issues/1591
2021-09-07 17:52:42 +02:00
Simone Basso
8174d88bac
refactor(i/errorsx): always use the same error reporting pattern (#478)
For consistency and also because the SafeErrorWrapperBuilder seems
to be the building pattern than the original code assumed.

New code should not use it, but I'd rather keep legacy code consistent
formally and with its own original assumptions.

In particular, it matters that SafeErrorWrapperBuilder assigns the
most relevant operation that failed. We were not doing that when we
were manually creating a new ErrWrapper.

Part of https://github.com/ooni/probe/issues/1591
2021-09-07 17:23:24 +02:00
Simone Basso
83440cf110
refactor: split errorsx in good and legacy (#477)
The legacy part for now is internal/errorsx. It will stay there until
I figure out whether it also needs some extra bug fixing.

The good part is now in internal/netxlite/errorsx and contains all the
logic for mapping errors. We need to further improve upon this logic
by writing more thorough integration tests for QUIC.

We also need to copy the various dialer, conn, etc adapters that set
errors. We will put them inside netxlite and we will generate errors in
a way that is less crazy with respect to the major operation. (The
idea is to always wrap, given that now we measure in an incremental way
and we don't measure every operation together.)

Part of https://github.com/ooni/probe/issues/1591
2021-09-07 17:09:30 +02:00
Simone Basso
ccb3a644e1
refactor(errorsx): prepare for splitting the package (#476)
We will move the sane part of this package to i/netxlite/errorsx
and we will move the rest to i/e/legacy/errorsx.

What is the sane part? The sane part is error classifiers plus
the definition of ErrWrapper. The rest, including the rules
on how to decide whether an operation is major, are tricky and
we should consider them legacy and replace them with rules
that are more easy to understand and reason on.

Part of https://github.com/ooni/probe/issues/1591
2021-09-07 15:46:32 +02:00
Simone Basso
cef801fa23
refactor(errorsx): rename generator package (#475)
This is a preliminary change before merging errorsx into netxlite.

See https://github.com/ooni/probe/issues/1591
2021-09-07 15:04:26 +02:00