Commit Graph

749 Commits

Author SHA1 Message Date
Simone Basso
a6f5388bac
fix(filtering/dns.go): serve requests in parallel (#564)
Without this change, it takes too much to serve a single query and
we cannot properly use this code for QA.

See https://github.com/ooni/probe/issues/1803#issuecomment-957323297
2021-11-02 12:40:18 +01:00
Simone Basso
d9c43f1d1b
refactor(netxlite/filtering): use strings for blocking policies (#563)
This change will simplify follow-up work done as part of
https://github.com/ooni/probe/issues/1803#issuecomment-957323297 to
implement a comprehensive self-censoring solution.

While there, rename the "proxy" action to "pass" because what we
are effectively doing is passing traffic to the network (that's a
minor change but it seems a better analogy).
2021-11-02 12:31:42 +01:00
Simone Basso
f91de2ecd6
cleanup: move bogon checking code in netxlite (#562)
I develop this diff while working on https://github.com/ooni/probe/issues/1803#issuecomment-957323297.

While there, make sure we don't have duplicate bogon code
and always use the code inside netxlite.
2021-11-02 12:20:04 +01:00
Simone Basso
ffdafaf351
feat(netxlite): implement hooks for transparent proxy (#561)
See https://github.com/ooni/probe/issues/1803#issuecomment-957323297.
2021-11-02 12:04:40 +01:00
Simone Basso
eaa3d6eae0
chore: bump version to 3.12.0-alpha.1 (#559)
Part of https://github.com/ooni/probe/issues/1815
2021-10-22 17:52:48 +02:00
Simone Basso
1f0fcafb8a
fix: ensure we bind oohelperd with the repo's version number (#558)
Work related to https://github.com/ooni/probe/issues/1506#issuecomment-949715707.

This diff cherry-picks from the release/3.11 branch.
2021-10-22 17:21:38 +02:00
Srijan Srivastava
3f0da81bf8
made tutorial outputs more presentable (#555)
Closes https://github.com/ooni/probe/issues/1831
2021-10-22 16:17:57 +02:00
Simone Basso
d44970a43f
master: update deps and set version to 3.12.0-alpha (#548)
* chore: update all workflows to use go1.17.2

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

* chore: update all dependencies

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

* chore: run `go generate`

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

* chore: update the user-agent

Part of https://github.com/ooni/probe/issues/1815

* Set version to 3.12.0-alpha

Part of https://github.com/ooni/probe/issues/1815

* fix: update to ooni/probe-assets@v0.5.0

This overcomes https://github.com/ooni/probe/issues/1836 in the CLI and,
while there, let us also make maxminddb tests stricter.

* fix(QA/Dockerfile): build using go1.17

See https://github.com/ooni/probe-cli/pull/547#issuecomment-947760839

* chore(mk): use go1.17.2

Part of https://github.com/ooni/probe/issues/1815

* fix(codeql): always run for master

Otherwise we see a warning that there is no CodeQL information
available for the base branch and this is sub-optimal.

Part of https://github.com/ooni/probe/issues/1815
2021-10-20 18:16:40 +02:00
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
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
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
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
Simone Basso
5c217594d7
refactor(errorsx): autogenerate all failure names (#474)
Part of https://github.com/ooni/probe/issues/1591
2021-09-07 14:50:38 +02:00
Simone Basso
8b38ea7e98
refactor(errorsx): improve errno generating code (#473)
No functional change, as it's clearly obvious from the output.

While there, also rename the generator for certifi. We are planning
on merging errorsx into netxlite. The first step is to give different
names to the code generating programs.

See https://github.com/ooni/probe/issues/1591
2021-09-07 14:25:42 +02:00
Simone Basso
fe3c90479d
refactor(netxlite): adapt single-use-quic-dialer from websteps (#472)
This is the last bit of functionality we need before rewriting a
chunk of websteps to use netxlite.

To rewrite most of it, we still need to move over:

1. dnstransport code

2. errorsx code

With both done, netxlite is a good library for websteps as well
as for most other operations we perform outside of the experiments.

Part of https://github.com/ooni/probe/issues/1591
2021-09-06 22:14:49 +02:00
Simone Basso
b9c4ad0b2b
fix(netxlite): http3 propagates CloseIdleConnections to its dialer (#471)
With this change, we are now able to change more dependent code to simplify
the way in which we create and manage resolvers.

See https://github.com/ooni/probe/issues/1591
2021-09-06 21:52:00 +02:00
Simone Basso
bdad392b61
feat(netxlite): write factories for quic code (#470)
Part of https://github.com/ooni/probe/issues/1591
2021-09-06 21:34:14 +02:00
Simone Basso
3ba5626b95
feat(netxlite): add CloseIdleConnections to quic dialer (#469)
Like before, do not touch the rest of the tree. Rather create
compatibility types declared as legacy.

We will soon be able to close idle connections for an HTTP3
transport using any kind of resolvers more easily.

See https://github.com/ooni/probe/issues/1591
2021-09-06 20:56:14 +02:00
Simone Basso
aa77867145
fix(netxlite): clearly document quirk and make code robust (#468)
This quirk really saddens me. It's a piece of tech debt we're
carrying over from the original netx implementation.

We cannot remove it _until_ we have legacy netx code around.

The second best thing we can do is to clearly move this code in
a place where it's clear it's a quirk and write and use some extra
code that makes sure the quirk's assumptions are always met.

Sigh.

See https://github.com/ooni/probe/issues/1591
2021-09-06 20:17:45 +02:00
Simone Basso
ba5bae4769
refactor(netxlite): let NewHTTPTransport work with single-use dialers (#467)
To make this happen, we need to take as argument a TLSDialer rather than
a TLSHandshaker. Then, we need to arrange the code so that we always
enforce a timeout for both TCP and TLS connections.

Because a TLSDialer can be constructed with a custom TLSConfig, we cover
also the case where the users wants to provide such a config.

While there, make sure we have better unit tests of the HTTP code.

See https://github.com/ooni/probe/issues/1591
2021-09-06 19:27:59 +02:00
Simone Basso
3114d6ca0e
feat(netxlite): integrate websteps code to use ooni/oohttp (#466)
Part of https://github.com/ooni/probe/issues/1591
2021-09-06 17:21:34 +02:00
Simone Basso
6df27d919d
fix(netxlite): http factory that propagates close-idle-connections (#465)
While there reorganize mocks' tls implementation to use a single file
called tls.go (and tls_test.go) just like netxlite does.

While there write tests ensuring we always add timeouts when we are
making TCP connections (be them TLS or cleartext).

See https://github.com/ooni/probe/issues/1591
2021-09-06 16:53:28 +02:00
Simone Basso
2572376fdb
feat(netxlite): implement single use {,tls} dialer (#464)
This basically adapts already existing code inside websteps to
instead be into the netxlite package, where it belongs.

In the process, abstract the TLSDialer but keep a reference to the
previous name to avoid refactoring existing code (just for now).

While there, notice that the right name is CloseIdleConnections (i.e.,
plural not singular) and change the name.

While there, since we abstracted TLSDialer to be an interface, create
suitable factories for making a TLSDialer type from a Dialer and a
TLSHandshaker.

See https://github.com/ooni/probe/issues/1591
2021-09-06 14:12:30 +02:00
Simone Basso
ef9592f75e
feat(netxlite): TLSDialer closes idle connections (#463)
We are proceeding with this plan of every major type being able to
close idle connections, which will simplify making DNS resolvers.

See https://github.com/ooni/probe/issues/1591.
2021-09-06 13:29:37 +02:00
Simone Basso
3caf5800a2
fix(netxlite): gracefully handle utls panics (#462)
* fix(netxlite): gracefully handle utls panics

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

* fix(netxlite): remove wrong timeout from newly written test
2021-09-05 21:41:49 +02:00
Simone Basso
b834af83ac
feat: upgrade oohttp and propagate changes (#461)
Part of https://github.com/ooni/probe/issues/1506
2021-09-05 21:23:47 +02:00
Simone Basso
5b8df394b1
refactor(netxlite): add factories to create TLS handshakers (#460)
See https://github.com/ooni/probe/issues/1591
2021-09-05 20:59:42 +02:00
Simone Basso
6a1e92cace
feat(netxlite): add dialer factory, simplify resolver factory (#459)
See https://github.com/ooni/probe/issues/1591
2021-09-05 20:41:46 +02:00
Simone Basso
b52d784f00
fix(netxlite): resolver _always_ short circuits IP addrs (#458)
We will use this in a moment when we will add support for the
dnstransports that currently are in engine/netx.

See https://github.com/ooni/probe/issues/1591
2021-09-05 20:12:05 +02:00
Simone Basso
7a9499fee3
refactor(dialer): it should close idle connections (#457)
Like we did before for the resolver, a dialer should propagate the
request to close idle connections to underlying types.

See https://github.com/ooni/probe/issues/1591
2021-09-05 19:55:28 +02:00
Simone Basso
a3a27b1ebf
fix(netxlite): make default resolver converge faster (#456)
* fix(netxlite): make default resolver converge faster

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

* Update internal/netxlite/resolver.go

* fix(ndt7): adapt tests after previous change

Because now we're running the DNS resolution inside a goroutine
with a child context, the returned error string is different.

The previous error said we canceled the whole dialing operation,
while now we see directly that the context was canceled.
2021-09-05 18:50:05 +02:00
Simone Basso
a3654f60b7
refactor(netxlite): add more functions to resolver (#455)
We would like to refactor the code so that a DoH resolver owns the
connections of its underlying HTTP client.

To do that, we need first to incorporate CloseIdleConnections
into the Resolver model. Then, we need to add the same function
to all netxlite types that wrap a Resolver type.

At the same time, we want the rest of the code for now to continue
with the simpler definition of a Resolver, now called ResolverLegacy.

We will eventually propagate this change to the rest of the tree
and simplify the way in which we manage Resolvers.

To make this possible, we introduce a new factory function that
adapts a ResolverLegacy to become a Resolver.

See https://github.com/ooni/probe/issues/1591.
2021-09-05 18:03:50 +02:00
Simone Basso
2e0118d1a6
refactor(netxlite): hide details without breaking the rest of the tree (#454)
## Description

This PR continues the refactoring of `netx` under the following principles:

1. do not break the rest of the tree and do not engage in extensive tree-wide refactoring yet
2. move under `netxlite` clearly related subpackages (e.g., `iox`, `netxmocks`)
3. move into `internal/netxlite/internal` stuff that is clearly private of `netxlite`
4. hide implementation details in `netxlite` pending new factories
5. refactor `tls` code in `netxlite` to clearly separate `crypto/tls` code from `utls` code

After each commit, I run `go test -short -race ./...` locally. Each individual commit explains what it does. I will squash, but this operation will preserve the original commit titles, so this will give further insight on each step.

## Commits

* refactor: rename netxmocks -> netxlite/mocks

Part of https://github.com/ooni/probe/issues/1591

* refactor: rename quicx -> netxlite/quicx

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

* refactor: rename iox -> netxlite/iox

Regenerate sources and make sure the tests pass.

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

* refactor(iox): move MockableReader to netxlite/mocks

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

* refactor(netxlite): generator is an implementation detail

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

* refactor(netxlite): separate tls and utls code

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

* refactor(netxlite): hide most types but keep old names as legacy

With this change we avoid breaking the rest of the tree, but we start
hiding some implementation details a bit. Factories will follow.

See https://github.com/ooni/probe/issues/1591
2021-09-05 14:49:38 +02:00
Simone Basso
ae799c4942
fix: completely remove support for h3-29 (#453)
The quic-go library does not support it anymore. So, let us be consistent
and remove any reference to h3-29 from our codebase.

Closes https://github.com/ooni/probe/issues/1740.
2021-09-05 12:57:48 +02:00
Simone Basso
f0927ea00c
ci: master only runs coverage and only with go1.17 (+ fix flaky test) (#452)
* fix: disable debianrepo build on master branch

This just mitigates https://github.com/ooni/probe/issues/1741 and does
not fully address it, but I'd rather avoid delving into this problem until
I open a release/v3.11.0 branch and have to really fix this issue.

* fix: only run coverage using go1.17

This is the version of Go with which we are going to bless v3.11.0
therefore it's the only version of Go that matters.

Reference issue: https://github.com/ooni/probe/issues/1738.

* fix(ptx/obfs4_test.go): avoid context-vs-normal-code race

We want to test whether we get the context failure if the error
generated inside normal code happens _after_ the context cancellation.

The best way to do that is to write code that is not racy. To this
end, we just need to pause normal code until we know that the context
has returned to the caller. We also need to ensure we do not leak
a goroutine, hence we use a WaitGroup to check that.

Fixes https://github.com/ooni/probe/issues/1750
2021-09-05 12:44:44 +02:00
Simone Basso
276beb8719
fix(oohelper): do not stop if DNS fails locally (#450)
When a probe gets a local DNS failure, it will continue and nonetheless
query the test helper without any IP address, just an empty list.

This diff fixes the behavior of cmd/oohelper to do the same.

Work part of https://github.com/ooni/probe/issues/1707.
2021-09-05 12:06:02 +02:00
Simone Basso
619826ac34
fix: skip two integration tests in short mode (#451)
Reference issue: https://github.com/ooni/probe/issues/1769

Motivation: The CI is failing. Those are integration tests. Let us figure out the issue when we approach release. Until we approach release, do not let those tests distracting us. Normal merges should only pass the `-short` tests.
2021-09-05 11:58:02 +02:00
Simone Basso
8f18813e17
cli: upgrade to lucas-clemente/quic-go 0.23.0 (#449)
See https://github.com/ooni/probe/issues/1754 for a comprehensive description.
2021-08-23 16:49:22 +02:00
kelmenhorst
a9014e7950
cli: websteps: fix DNSDo (#447)
This fixes an inattention bug in the websteps code.
2021-08-20 16:09:21 +02:00
Simone Basso
2e5b4f13dd
fix(internal/platform): support freebsd (#445)
See https://github.com/ooni/probe/issues/1696
2021-08-20 14:00:06 +02:00
kelmenhorst
1874f7a7c2
enable utls for websteps (#442)
This diff enables `websteps` to use uTLS for TLS parroting. It integrates the `oohttp.StdlibTransport` wrapper which uses the `ooni/oohttp` fork. `oohttp` supports TLS-like connections like `utls.Conn`.
As a prototype, the testhelper and `websteps` code now uses the `utls.HelloChrome_Auto` fingerprint, i.e. the simulated TLS fingerprint of the Google Chrome browser.

It is a further contribution for my GSoC project.

Reference issue: https://github.com/ooni/probe/issues/1733
2021-08-18 16:10:27 +02:00
Simone Basso
f18a9852db
doc: mention the test helper spec we're using (#436)
See https://github.com/ooni/probe/issues/1729
2021-08-17 12:52:51 +02:00
Simone Basso
f2b6a5972f
refactor: sync messages with spec draft (#435)
Work part of: https://github.com/ooni/probe/issues/1733

Spec draft: https://github.com/ooni/spec/pull/219
2021-08-17 11:56:36 +02:00
Simone Basso
ce854e8ae1
refactor(oohelperd): better distinguish different helpers (#434)
Part of https://github.com/ooni/probe/issues/1733
2021-08-17 11:23:53 +02:00
Simone Basso
bef5b87a8a
refactor: fully move IDNAResolver to netxlite (#433)
We started doing this in https://github.com/ooni/probe-cli/pull/432.

This work is part of https://github.com/ooni/probe/issues/1733.
2021-08-17 11:02:12 +02:00
kelmenhorst
c31591f298
cli: new testhelper and the websteps experiment prototype (#432)
This is the extension of https://github.com/ooni/probe-cli/pull/431, and my final deliverable for GSoC 2021.

The diff introduces:

1) The new `testhelper` which supports testing multiple IP endpoints per domain and introduces HTTP/3 control measurements. The specification of the `testhelper` can be found at https://github.com/ooni/spec/pull/219. The `testhelper` algorithm consists of three main steps:

   * `InitialChecks` verifies that the input URL can be parsed, has an expected scheme, and contains a valid domain name.

   * `Explore` enumerates all the URLs that it discovers by redirection from the original URL, or by detecting h3 support at the target host.

   * `Generate` performs a step-by-step measurement of each discovered URL.

2) A prototype of the corresponding new experiment `websteps` which uses the control measurement of the `testhelper` to know which URLs to measure, and what to expect. The prototype does not yet have:

   * unit and integration tests,

   * an analysis tool to compare the control and the probe measurement.

This PR is my final deliverable as it is the outcome of the trials, considerations and efforts of my GSoC weeks at OONI. 
It fully integrates HTTP/3 (QUIC) support which has been only used in the `urlgetter` experiment until now.

Related issues: https://github.com/ooni/probe/issues/1729 and https://github.com/ooni/probe/issues/1733.
2021-08-17 10:29:06 +02:00
Simone Basso
14c1640f7f
feat(errorsx): cover more syscall errors and add tests (#430)
* feat(errorsx): cover more syscall errors and add tests

Part of https://github.com/ooni/probe/issues/1505

* fix tests
2021-07-08 12:23:37 +02:00
Simone Basso
3747598b4a
refactor(errorsx): auto-generate syscall errors mapping (#429)
* refactor(errorsx): auto-generate syscall errors mapping

Part of https://github.com/ooni/probe/issues/1505

* fix: generate independently of the platform
2021-07-02 15:22:02 +02:00
Simone Basso
a3c71dc282 refactor(netxlite): move generator in a subpackage
This way, we don't need to use `// +build ignore`, which prevents
the editor from linting the file itself.

Work part of https://github.com/ooni/probe/issues/1505.
2021-07-02 14:26:28 +02:00
Simone Basso
b9ff9136e2 refactor(errorsx): directly return ErrWrapper when needed
The utility of SafeErrWrapperBuilder is low. Let us instead change the
code to always create ErrWrapper when we're in this package.

While there, also note some TODO-next items.

Part of https://github.com/ooni/probe/issues/1505.
2021-07-02 14:00:46 +02:00
kelmenhorst
285290a98d netxlite: utls for TLS parroting
This is the ground work for https://github.com/ooni/probe/issues/1424.
2021-07-02 12:41:27 +02:00
Simone Basso
17bfb052c5
refactor(errorsx): start hiding private details and moving around stuff (#424)
* refactor(errorsx): start hiding private details and moving around stuff

Part of https://github.com/ooni/probe/issues/1505

* fix: remove now-addressed todo comments
2021-07-02 11:35:00 +02:00
Simone Basso
ceb2aa8a8d
fix(netx): make sure we save quic udp conn events (#423)
https://github.com/ooni/probe-cli/pull/421 was wrong because we need
a more rich interface for quic-go to call ReadMsgUDP.

With this commit, we use such an interface: OOBCapablePacketConn.

Still part of https://github.com/ooni/probe/issues/1505.
2021-07-02 11:00:12 +02:00
Simone Basso
30c7e2cdb3
feat(errorsx): add error wrapper for quic (#422)
Part of https://github.com/ooni/probe/issues/1505
2021-07-02 10:39:14 +02:00
Simone Basso
250a595f89
refactor: cleaner way of passing a UDPConn around (#421)
* refactor: cleaner way of passing a UDPConn around

Also part of https://github.com/ooni/probe/issues/1505

* Update internal/engine/netx/quicdialer/connectionstate.go
2021-07-01 21:56:29 +02:00
Simone Basso
ec350cba1a
refactor: move ErrorWrapperQUICDialer to errorsx (#420)
I needed to add some tests as integration tests due to circular
imports, but this is ~fine because we quite likely want many
integration tests in the errorsx package anyway.

Part of https://github.com/ooni/probe/issues/1505.
2021-07-01 20:58:15 +02:00
Simone Basso
5c52d99d57
refactor: move ErrorWrapperResolver to errorsx pkg (#419)
Part of https://github.com/ooni/probe/issues/1505
2021-07-01 18:51:40 +02:00
Simone Basso
863899469e
refactor: move ErrorWrapperTLSHandshaker to errorsx (#418)
Part of https://github.com/ooni/probe/issues/1505
2021-07-01 18:00:09 +02:00
Simone Basso
ceefcaf45e
refactor: move dialer's errorwrapper in i/errorsx (#417)
Part of https://github.com/ooni/probe/issues/1505
2021-07-01 17:15:44 +02:00
Simone Basso
72acd175a0
refactor: move i/e/n/errorx to i/errorsx (#416)
Still working towards https://github.com/ooni/probe/issues/1505
2021-07-01 16:34:36 +02:00
Simone Basso
6895946a34
refactor: introduce factory for stdlib http transport (#413)
With this factory, we want to construct ourselves the TLS dialer
so that we can use a dialer wrapper that always sets timeouts when
reading, addressing https://github.com/ooni/probe/issues/1609.

As a result, we cannot immediately replace the i/e/netx factory
for creating a new HTTP transport, since the functions signatures
are not directly compatible.

Refactoring is part of https://github.com/ooni/probe/issues/1505.
2021-07-01 15:26:08 +02:00
Simone Basso
f59e98fd05
fix(ptx): use another obfs4 bridge (#415)
See discussion at https://github.com/ooni/probe-cli/pull/413#issuecomment-871552943.
2021-07-01 15:13:01 +02:00
Simone Basso
4dc2907472
refactor: move base http3 transport into netxlite (#412)
This diff is part of https://github.com/ooni/probe/issues/1505.

You will notice that I have not adapted all the (great) tests we had
previously. They should live at another layer, and namely the one that
deals with performing measurements.

When I'm refactoring such a layer I'll ensure those tests that I have
not adapted here are reintroduced into the tree.
2021-06-30 15:19:10 +02:00
Simone Basso
527e1a0707
refactor: move httptransport w/ logging to netxlite (#411)
Part of https://github.com/ooni/probe/issues/1505
2021-06-26 18:11:47 +02:00
Simone Basso
046dd4545d
feat(netxlite): add QUICDialerLogger (#410)
Part of https://github.com/ooni/probe/issues/1505
2021-06-26 16:54:02 +02:00
Simone Basso
b07890af4d
fix(netxlite): improve TLS auto-configuration (#409)
Auto-configure every relevant TLS field as close as possible to
where it's actually used.

As a side effect, add support for mocking the creation of a TLS
connection, which should possibly be useful for uTLS?

Work that is part of https://github.com/ooni/probe/issues/1505
2021-06-25 20:51:59 +02:00
Simone Basso
f1f5ed342e
refactor: move quic dns dialing to netxlite (#408)
Part of https://github.com/ooni/probe/issues/1505
2021-06-25 18:38:13 +02:00
Simone Basso
a4d61a4be4
fix(netxlite): close quic packetconn (#407)
Noticed when working on https://github.com/ooni/probe/issues/1505.

Justification for this diff:

1. [DialEarlyContext calls dialContext with the last argument set to false](https://github.com/lucas-clemente/quic-go/blob/v0.21.1/client.go#L153);

2. [the semantics of the last argument is whether we own the connection](https://github.com/lucas-clemente/quic-go/blob/v0.21.1/client.go#L187);

3. [this value is propagated to the client data structure](https://github.com/lucas-clemente/quic-go/blob/v0.21.1/client.go#L269);

4. [client.dial](https://github.com/lucas-clemente/quic-go/blob/v0.21.1/client.go#L302) runs the session in a background goroutine and only destroys the `packetHandlers` when the connection is owned;

5. [packetHandlerMap.Destroy](https://github.com/lucas-clemente/quic-go/blob/v0.21.1/packet_handler_map.go#L293) closes the underlying PacketConn.

6. also, the documentation clearly states that when you use `DialEarlyContext` you can use the same packet conn multiple times, so it does not take ownership.
2021-06-25 17:58:42 +02:00
Simone Basso
925ca22b88
refactor: move quicdialing base functionality to netxlite (#406)
Part of https://github.com/ooni/probe/issues/1505
2021-06-25 17:04:24 +02:00
Simone Basso
c00cad1382
refactor(quicdialer): separate saving from listening (#405)
With this change, we will soon be able to move the creation of
a QUIC session inside of the netxlite package.

Part of https://github.com/ooni/probe/issues/1505.
2021-06-25 16:20:08 +02:00
Simone Basso
d031829a4b
refactor: move tlsdialer to netxlite (#404)
Part of https://github.com/ooni/probe/issues/1505
2021-06-25 13:42:48 +02:00
Simone Basso
7f2463d745
refactor: merge tlsx into netxlite (#403)
Part of https://github.com/ooni/probe/issues/1505
2021-06-25 12:39:45 +02:00
Simone Basso
f1ee763f94
refactor(netx): move tlshandshaker logger to netxlite (#402)
Part of https://github.com/ooni/probe/issues/1505
2021-06-25 12:21:34 +02:00
Simone Basso
acef18a955
fix(netx): repair BogonResolver tests (#401)
The BogonResolver relied on its wrapper resolver to pass along the
list of addresses _and_ the error. But the idiomatic thing to do is
often to return `nil` when there is an error.

I broke this very fragile assumption in https://github.com/ooni/probe-cli/pull/399.

I could of course fix it, but this assumption is clearly wrong
and we should not allow such fragile code in the tree.

We are not using BogonIsError much in the tree. The only place in
which we're using it for measuring seems to be dnscheck.

It may be that this surprising behavior was what caused the issue at
https://github.com/ooni/probe/issues/1510 in the first place.

Regardless, let's remove fragile code and adjust the test that was
failing. Also that test is quick so it can run in `-short` mode.

Spotted while working on https://github.com/ooni/probe/issues/1505.
2021-06-25 11:51:10 +02:00
Simone Basso
6b7d270bda
refactor: move tls handshaker to netxlite (#400)
Part of https://github.com/ooni/probe/issues/1505
2021-06-25 11:07:26 +02:00
Simone Basso
b8428b302f
refactor(netxlite): make sure we always use netxmocks (#399)
* refactor(netxlite): make sure we always use netmocks

While there, improve logging and make sure we test 100% of the
package with unit tests only. (We don't need to have integration
testing in this package because it's fairly simple/obvious.)

Part of https://github.com/ooni/probe/issues/1505

* further improve logs
2021-06-23 17:00:44 +02:00
Simone Basso
c5dd9a68f1
feat(netxmocks): implement mocks for netxlite.Resolver (#398)
While there, make sure we require using &netxmocks.Dialer.

Still part of https://github.com/ooni/probe/issues/1505
2021-06-23 16:21:13 +02:00
Simone Basso
16aa8e5538
refactor: rename i/e/n/mockablex => i/netxmocks (#397)
Needed to more easily do https://github.com/ooni/probe/issues/1505
2021-06-23 16:06:02 +02:00
Simone Basso
8a0beee808
refactor: start pivoting netx (#396)
What do I mean by pivoting? Netx is currently organized by row:

```
               | dialer | quicdialer | resolver | ...
 saving        |        |            |          | ...
 errorwrapping |        |            |          | ...
 logging       |        |            |          | ...
 mocking/sys   |        |            |          | ...
```

Every row needs to implement saving, errorwrapping, logging, mocking (or
adapting to the system or to some underlying library).

This causes cross package dependencies and, in turn, complexity. For
example, we need the `trace` package for supporting saving.

And `dialer`, `quickdialer`, et al. need to depend on such a package.

The same goes for errorwrapping.

This arrangement further complicates testing. For example, I am
currently working on https://github.com/ooni/probe/issues/1505 and
I realize it need to repeat integration tests in multiple places.

Let's say instead we pivot the above matrix as follows:

```
             | saving | errorwrapping | logging | ...
 dialer      |        |               |         | ...
 quicdialer  |        |               |         | ...
 logging     |        |               |         | ...
 mocking/sys |        |               |         | ...
 ...
```

In this way, now every row contains everything related to a specific
action to perform. We can now share code without relying on extra
support packages. What's more, we can write tests and, judding from
the way in which things are made, it seems we only need integration
testing in `errorwrapping` because it's where data quality matters
whereas, in all other cases, unit testing is fine.

I am going, therefore, to proceed with these changes and "pivot"
`netx`. Hopefully, it won't be too painful.
2021-06-23 15:53:12 +02:00
Simone Basso
c74c94d616
cleanup: remove ConnID, DialID, TransactionID (#395)
We are not using them anymore. The only nettest still using the
legacy netx implementation is tor, for which setting these fields
is useless, because it performs each measurement into a separate
goroutine. Hence, let us start removing this part of the legacy
netx codebase, which is hampering progress in other areas.

Occurred to me while doing testing for the recent changes in
error mapping (https://github.com/ooni/probe/issues/1505).
2021-06-23 13:36:45 +02:00
kelmenhorst
1fefe5d9b8
cli: error classification refactoring (#386)
* make errorx classifier less dependent on strings

* adapt errorx tests

* added syserror comment

* localized classification of quic errors

* localized classification of resolver errors

* (fix) move "no such host" error to global classifier

* moved x509 errors to local TLS error classifier

* added qtls error classification for quicdialer

* add Classifier to SafeErrWrapperBuilder

* windows/unix specific files for errno constants

* added errno ETIMEDOUT, tests

* added TLS alert constants

* added FailureSSLHandshake test, improved switch style

* added more network based system error constants for future use

* (fix) import style

* (fix) errorx typos/style

* (fix) robustness of SafeErrWrapperBuilder, added comments

* (fix) reversed unnecessary changes, added comments

* (fix) style and updated comment

* errorx: added future re-structuring comment

* (fix) typo TLS alert code 51

* added comment

* alert mapping: added comment

* Update errorx.go

* Update internal/engine/netx/errorx/errorx.go

Co-authored-by: Simone Basso <bassosimone@gmail.com>
2021-06-23 11:32:53 +02:00
Simone Basso
1eb6e758c6
refactor: move scrubbingLogger to the scrubber pkg (#394)
* refactor: move scrubbingLogger to the scrubber pkg

We need it exported so we can use it in the new implementation.

Part of https://github.com/ooni/probe/issues/1687

* fix test
2021-06-22 14:43:58 +02:00
Simone Basso
75ae99e9d4
refactor: move scrubber into its own package (#393)
Also part of https://github.com/ooni/probe/issues/1687
2021-06-22 14:08:29 +02:00
Simone Basso
760ac905d6
refactor: move bytecounting conn in bytecounter pkg (#392)
* refactor: move bytecounting conn in bytecounter pkg

This enables other pieces of code to request bytecounting without
depending on netx or on the perverse using-the-context-to-configure-
byte-counting mechanism.

Also occurred when working on https://github.com/ooni/probe/issues/1687

* fix: add missing docs
2021-06-22 13:44:36 +02:00
Simone Basso
23bc261464
refactor: move bytecounter to internal (#391)
It's generic enough to live outside of engine/netx.

Occurred to me while working on https://github.com/ooni/probe/issues/1687.
2021-06-22 13:00:29 +02:00
Simone Basso
520398dd8e
feat: tutorial on how to write the torsf experiment (#390)
Original tracking issue for Sprint 41: https://github.com/ooni/probe/issues/1507

Follow-up work in Sprint 42 tracked by: https://github.com/ooni/probe/issues/1689
2021-06-22 00:12:03 +02:00
Simone Basso
a50efdbcf1
feat(torsf): experiment that bootstraps tor using snowflake (#387)
The current implementation assumes the user has already installed tor
on the current system. If tor is not present, the experiment fails.

This is meant to be the first version of this experiment.

We are going to add more functionality in subsequent revisions of
this experiment, once we've collected more feedback.

Reference issue: https://github.com/ooni/probe/issues/1565.

Here's the spec PR: https://github.com/ooni/spec/pull/218.

Here's the issue tracking future work: https://github.com/ooni/probe/issues/1686
2021-06-18 13:51:18 +02:00
Simone Basso
85b16c8bd2
refactor(mlablocate*): move from i/e/internal to internal (#385)
We've been flattening the package structure for some time now.

While there, add very basic examples.
2021-06-15 19:51:03 +02:00
Simone Basso
d84cf5b69f
refactor(mlablocatev2): use interfaces, add missing tests, add docs (#384)
This is a very light refactoring of the mlablocatev2 package where we do
the following things:

1. use interfaces rather than depending on other pkgs where possible

2. add a missing test to the test suite

3. write more comprehensive docs (including todo-next comments)
2021-06-15 19:25:09 +02:00
Simone Basso
2613579768
refactor(mlablocate): use interface, remove unused fields, add docs (#383)
This is a very light refactoring of the mlablocate package where we do
the following things:

1. use interfaces rather depending on other pkgs where possible

2. only keep the fields we really need in the result struct

3. write more comprehensive docs (including todo-next comments)

While there, use `neubot/dash` rather than `ndt7` for the tests.
2021-06-15 18:57:52 +02:00
Simone Basso
34062cb177
refactor(mlablocate*): use internal testing (#382)
This is not an external package and it's fine to just use internal testing.

It reduces the complexity a little bit.
2021-06-15 18:11:47 +02:00
Federico Ceratto
8e26dbae8e
oohelperd packaging and CI (#374)
Closes https://github.com/ooni/backend/issues/499

Co-authored-by: Simone Basso <bassosimone@gmail.com>
2021-06-15 15:53:22 +02:00
Simone Basso
fd5405ade1
cleanup(all): stop using deprecated ioutil functions (#381)
Spotted while working on https://github.com/ooni/probe/issues/1417

See https://golang.org/pkg/io/ioutil/
2021-06-15 14:01:45 +02:00
Simone Basso
721ce95315
fix(all): introduce and use iox.CopyContext (#380)
* fix(all): introduce and use iox.CopyContext

This PR is part of https://github.com/ooni/probe/issues/1417.

In https://github.com/ooni/probe-cli/pull/379 we introduced a context
aware wrapper for io.ReadAll (formerly ioutil.ReadAll).

Here we introduce a context aware wrapper for io.Copy.

* fix(humanize): more significant digits

* fix: rename humanize files to follow the common pattern

* fix aligment

* fix test
2021-06-15 13:44:28 +02:00
Simone Basso
0fdc9cafb5
fix(all): introduce and use iox.ReadAllContext (#379)
* fix(all): introduce and use iox.ReadAllContext

This improvement over the ioutil.ReadAll utility returns early
if the context expires. This enables us to unblock stuck code in
case there's censorship confounding the TCP stack.

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

Compared to the functionality postulated in the above mentioned
issue, I choose to be more generic and separate limiting the
maximum body size (not implemented here) from using the context
to return early when reading a body (or any other reader).

After implementing iox.ReadAllContext, I made sure we always
use it everywhere in the tree instead of ioutil.ReadAll.

This includes many parts of the codebase where in theory we don't
need iox.ReadAllContext. Though, changing all the places makes
checking whether we're not using ioutil.ReadAll where we should
not be using it easy: `git grep` should return no lines.

* Update internal/iox/iox_test.go

* fix(ndt7): treat context errors as non-errors

The rationale is explained by the comment documenting reduceErr.

* Update internal/engine/experiment/ndt7/download.go
2021-06-15 11:57:40 +02:00
Simone Basso
576e035b20
fix(snowflake.go): default maxSnowflakes() to 1 (#378)
See https://github.com/ooni/probe-cli/pull/373#discussion_r651080925
2021-06-14 18:18:36 +02:00
kelmenhorst
10a2055163
quic: use RFC9000 version (#376)
* #1682: RFC9000 as main QUIC version

* removed extra ALPN values from the TLSConfig

* updated to quic-go v0.21.0

* only use h3
2021-06-14 16:59:24 +02:00
Simone Basso
69a44eb283
chore(snowflake.go): this TODO comment is now an issue (#375)
This work concludes https://github.com/ooni/probe/issues/1605.

The follow-up issue is https://github.com/ooni/probe/issues/1681.
2021-06-14 11:49:53 +02:00
Simone Basso
85c71c09dc
feat: introduce ptx package for pluggable transports dialers (#373)
* feat: introduce ptx package for pluggable transports dialers

Version 2 of the pluggable transports specification defines a function
that's like `Dial() (net.Conn, error`).

Because we use contexts as much as possible in `probe-cli`, we are
wrapping such an interface into a `DialContext` func.

The code for obfs4 is adapted from https://github.com/ooni/probe-cli/pull/341.

The code for snowflake is significantly easier than it is in
https://github.com/ooni/probe-cli/pull/341, because now Snowflake
supports the PTv2 spec (thanks @cohosh!).

The code for setting up a pluggable transport listener has also
been adapted from https://github.com/ooni/probe-cli/pull/341.

We cannot merge this code yet, because we need unit testing, yet the
newly added code already seems suitable for these use cases:

1. testing by dialing and seeing whether we can dial (which is not
very useful but still better than not doing it);

2. spawning tor+pluggable transports for circumvention (we need a
little more hammering like we did in https://github.com/ooni/probe-cli/pull/341,
which is basically https://github.com/ooni/probe/issues/1565, and then
we will be able to do that, as demonstrated by the new, simple client which
already allows us to use pluggable transports with tor);

3. testing by launching tor (when available) with a set of
pluggable transports (which depends on https://github.com/ooni/probe-engine/issues/897
and has not been assigned an issue yet).

* fix: tweaks after self code-review

* feat: write quick tests for ptx/obfs4

(They run in 0.4s, so I think it's fine for them to always run.)

* feat(ptx/snowflake): write unit and integration tests

* feat: create a fake PTDialer

The idea is that we'll use this simpler PTDialer for testing.

* feat: finish writing tests for new package

* Apply suggestions from code review

* Update internal/ptx/dependencies_test.go

Co-authored-by: Arturo Filastò <arturo@openobservatory.org>

* Update internal/ptx/dependencies_test.go

Co-authored-by: Arturo Filastò <arturo@openobservatory.org>

* chore: use as testing bridge one that's used by tor browser

The previous testing bridge used to be used by tor browser but
it was subsequently removed here:

e26e91bef8

See https://github.com/ooni/probe-cli/pull/373#discussion_r649820724

Co-authored-by: Arturo Filastò <arturo@openobservatory.org>
2021-06-14 10:20:54 +02:00
Simone Basso
06ee0e55a9
refactor(netx/dialer): hide implementation complexity (#372)
* refactor(netx/dialer): hide implementation complexity

This follows the blueprint of `module.Config` and `nodule.New`
described at https://github.com/ooni/probe/issues/1591.

* fix: ndt7 bug where we were not using the right resolver

* fix(legacy/netx): clarify irrelevant implementation change

* fix: improve comments

* fix(hhfm): do not use dialer.New b/c it breaks it

Unclear to me why this is happening. Still, improve upon the
previous situation by adding a timeout.

It does not seem a priority to look into this issue now.
2021-06-09 09:42:31 +02:00
Simone Basso
b7a6dbe47b
refactor(netx/dialer): we can simplify the proxy (#371)
The socks5 factory always returns a DialContext capable dialer. We just
need to cast to obtain such a dialer.

Also, the code will use the DialContext if passed a dialer that
implements DialContext.

Write a test that proves my point.

Part of https://github.com/ooni/probe/issues/1591.
2021-06-09 07:11:31 +02:00
Simone Basso
ee35b10a98
refactor(netx): dialer does not use legacy/netx anymore (#370)
Part of https://github.com/ooni/probe-engine/issues/897
2021-06-09 00:29:40 +02:00
Simone Basso
3672e14d3e
refactor(netx): towards removing connid, dialid, etc (#369)
I have verified that experiment/tor does not depend on this
functionality, therefore we can safely remove it.

Part of https://github.com/ooni/probe-engine/issues/897
2021-06-09 00:15:33 +02:00
Simone Basso
5b73230a6d
refactor(netx): move dialer's mockable types in mockablex (#368)
Part of https://github.com/ooni/probe/issues/1591
2021-06-08 23:59:30 +02:00
Simone Basso
b8cae3f5a6
cleanup(netx): remove unused proxy-via-context codepath (#367)
We always set the proxy explicitly now. So, let us remove this
extra bit of code we're not using.

Part of https://github.com/ooni/probe/issues/1507.
2021-06-08 22:26:24 +02:00
Simone Basso
8ad17775fa
refactor(netx): the TimeoutDialer is useless (#366)
We already configure a timeout in the underlying dialer, hence
there's no point in keeping the TimeoutDialer around.

Part of https://github.com/ooni/probe/issues/1507
2021-06-08 21:56:57 +02:00
Simone Basso
a647cf4988
refactor(netx): remove forwardes for tlsx (#365)
Part of https://github.com/ooni/probe/issues/1591
2021-06-08 21:14:45 +02:00
Simone Basso
adbde7246b
refactor(netx): remove the self censorship mechanism (#364)
We're currently use jafar for QA and jafar is a better mechanism,
even though it is not portable outside of Linux.

This self censorship mechanism was less cool and added a bunch
of (also cognitive) complexity to netx.

If we ever want to go down a self censorship like road, we probably
want to do as little work as possible in the problem and as much
work as possible inside a helper like jafar.

Part of https://github.com/ooni/probe/issues/1591.
2021-06-08 19:40:17 +02:00
Simone Basso
c553afdbd5
refactor(netx): start moving tls-specific code inside the tlsx pkg (#363)
* refactor(netx): move cert pool code inside tlsx

* refactor(netx): move more tls code inside tlsx
2021-06-08 15:39:25 +02:00
Simone Basso
626f0df66d chore(netx): fetch new CA bundle 2021-06-08 13:04:42 +02:00
Simone Basso
6620b0bbad refactor(netx): merge gocertifi into tlsx 2021-06-08 13:01:16 +02:00
Simone Basso
63cc692d66 refactor: move i/e/i/tlsx in i/e/netx 2021-06-08 12:56:39 +02:00
Simone Basso
704e5bd870 refactor(netx): extract tlsdialer from dialer 2021-06-08 12:52:15 +02:00
Simone Basso
e0311e8fed
chore: we are now at 3.11.0-alpha (#361) 2021-06-08 10:08:13 +02:00
Simone Basso
d4d1ac3832
cleanup(ndt7): remove redundant/unused code (#360) 2021-06-04 17:44:13 +02:00
Simone Basso
f271e71c0b
geolocate: first pass of code review and minor fixes (#359)
* doc(geolocate): minor cleanup

* more minor cleanups of geolocate

* remove disabled test and see whether now it works
2021-06-04 16:06:24 +02:00
Simone Basso
3cb6c7c6fb
refactor: move tunnel pkg down one level (#358)
* refactor: move tunnel pkg down one level

While there, reduce unnecessary dependency on external packages.

* file I forgot to commit
2021-06-04 15:15:41 +02:00
Simone Basso
39aec6677d
cleanup(shellx): do not directly depend on apex/log (#357) 2021-06-04 14:02:18 +02:00
Simone Basso
944d3c53fa
doc: improve and reference existing bug in the code (#356) 2021-06-04 12:50:23 +02:00
Simone Basso
4764d7f378
cleanup(platform): we don't need CGO anymore (#355)
* cleanup(platform): we don't need CGO anymore

Since go1.16, we have the `ios` port. So we can easily
disambiguate between ios and darwin.

This means we don't need to rely on CGO to correctly guess
whether we are on ios or darwin anymore.

So, now miniooni does not depend on a C compiler even
when you are not cross compiling.

* Update internal/platform/platform.go
2021-06-04 11:46:06 +02:00
Simone Basso
acd4ffff35
doc: cleanup and improve for recently moved pkgs (#354)
* chore(atomicx): review docs and add usage example

* chore(fsx): improve docs, return value, add examples

* fix(kvstore): correct typo and add example

* fix(multierror): add basic example

* doc: revamp ooapi documentation
2021-06-04 11:39:00 +02:00
Simone Basso
33de701263
refactor: flatten and separate (#353)
* refactor(atomicx): move outside the engine package

After merging probe-engine into probe-cli, my impression is that we have
too much unnecessary nesting of packages in this repository.

The idea of this commit and of a bunch of following commits will instead
be to reduce the nesting and simplify the structure.

While there, improve the documentation.

* fix: always use the atomicx package

For consistency, never use sync/atomic and always use ./internal/atomicx
so we can just grep and make sure we're not risking to crash if we make
a subtle mistake on a 32 bit platform.

While there, mention in the contributing guidelines that we want to
always prefer the ./internal/atomicx package over sync/atomic.

* fix(atomicx): remove unnecessary constructor

We don't need a constructor here. The default constructed `&Int64{}`
instance is already usable and the constructor does not add anything to
what we are doing, rather it just creates extra confusion.

* cleanup(atomicx): we are not using Float64

Because atomicx.Float64 is unused, we can safely zap it.

* cleanup(atomicx): simplify impl and improve tests

We can simplify the implementation by using defer and by letting
the Load() method call Add(0).

We can improve tests by making many goroutines updated the
atomic int64 value concurrently.

* refactor(fsx): can live in the ./internal pkg

Let us reduce the amount of nesting. While there, ensure that the
package only exports the bare minimum, and improve the documentation
of the tests, to ease reading the code.

* refactor: move runtimex to ./internal

* refactor: move shellx into the ./internal package

While there, remove unnecessary dependency between packages.

While there, specify in the contributing guidelines that
one should use x/sys/execabs instead of os/exec.

* refactor: move ooapi into the ./internal pkg

* refactor(humanize): move to ./internal and better docs

* refactor: move platform to ./internal

* refactor(randx): move to ./internal

* refactor(multierror): move into the ./internal pkg

* refactor(kvstore): all kvstores in ./internal

Rather than having part of the kvstore inside ./internal/engine/kvstore
and part in ./internal/engine/kvstore.go, let us put every piece of code
that is kvstore related into the ./internal/kvstore package.

* fix(kvstore): always return ErrNoSuchKey on Get() error

It should help to use the kvstore everywhere removing all the
copies that are lingering around the tree.

* sessionresolver: make KVStore mandatory

Simplifies implementation. While there, use the ./internal/kvstore
package rather than having our private implementation.

* fix(ooapi): use the ./internal/kvstore package

* fix(platform): better documentation
2021-06-04 10:34:18 +02:00
Simone Basso
a4cf473ee9
Release 3.10.0 beta.3 (#345)
* chore: run go-generate

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

* chore: update all the dependencies

Unclear to me why `go get -u -v ./...` did not actually update
all of them and I needed to spell out each of them and force to
update by going `go get -u -v $pkg@latest` ¯\_(ツ)_/¯.

Part of https://github.com/ooni/probe/issues/1468

* fix(c/o/i/d/actions_test.go): ensure we check for return value

Part of https://github.com/ooni/probe/issues/1468

* chore: update the user agents we use

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

* chore: set version to 3.10.0-beta.3

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

* chore: use probe-assets v0.3.1

Part of https://github.com/ooni/probe/issues/1468
2021-05-13 08:16:28 +02:00
Simone Basso
2344690960 chore: bump to 3.10.0-beta.2 2021-05-07 12:19:51 +02:00
Simone Basso
a9b3a3b3a5
fix(tunnel): pass /absolute/path/to/tor to cretz/bine (#323)
* fix(tunnel): pass /absolute/path/to/tor to cretz/bine

It seems cretz/bine is not aware of https://blog.golang.org/path-security
for now. I am planning to send over a diff for that later today.

In the meanwhile, do the right thing here, and make sure that we obtain
the absolute path to the tor binary before we continue.

This work is part of https://github.com/ooni/probe-engine/issues/283.

* fix tests when tor is not installed
2021-05-04 08:14:25 +02:00
Simone Basso
9d5a3321af
chore: link new TODOs with the relevant issues (#321)
Part of https://github.com/ooni/probe/issues/985
2021-04-29 18:43:31 +02:00
Simone Basso
1d70b81187
More progress towards release v3.10.0 (#320)
* chore: unvendor github.com/mitchellh/go-wordwrap

The library seems reasonably maintained and tested.

Part of https://github.com/ooni/probe/issues/1439

* fix(netx/quicdialer): ensure we handle all errors

Part of https://github.com/ooni/probe/issues/1439

* fix previous

* cleanup: remove unnecessary shutil fork

Part of https://github.com/ooni/probe/issues/1439

* doc: documented some undocumented functions

Part of https://github.com/ooni/probe/issues/1439

* fix(ooniprobe): rename mis-named function

Part of https://github.com/ooni/probe/issues/1439
2021-04-29 15:59:53 +02:00
Simone Basso
de60fb0588
Release v3.10.0-beta.1 (#319)
* fix(make): correctly write oonimkall.podspec

Part of https://github.com/ooni/probe/issues/1439

* chore: set version number to v3.10.0-beta.1

* fix(ios): don't build a target that requires git
2021-04-29 11:55:30 +02:00
Simone Basso
a88d2f35a8
Prepare 3.10.0-beta release (#313)
This diff implements part of the release checklist at https://github.com/ooni/probe/issues/1439. The plan is to bless a beta release and use it for further testing on Android devices. Afterward, we need to apply some extra changes to the `cli` (including https://github.com/ooni/probe-cli/pull/314 and https://github.com/ooni/probe-cli/pull/312). Finally, we will bless a full 3.10.0 release.
2021-04-28 09:34:14 +02:00
Simone Basso
11087db51a
chore: we're now at 3.10.0-alpha.1 (#310)
Part of https://github.com/ooni/probe/issues/1440
2021-04-20 09:20:04 +02:00
Simone Basso
54e590b776
fix(geolocate): do resolver lookup with proxy (#306)
The use cases for using a proxy become more clear over time. When I
originally wrote the proxy code the idea was to use the proxy to proxy
both the communication with the backend and measurements.

It become increasingly clear that we _only_ want to proxy the
communication with the backends. Therefore, there's no point in
skipping the resolver lookup step when we use a proxy.

Part of https://github.com/ooni/probe/issues/985
2021-04-07 18:48:02 +02:00
Simone Basso
654441f5cd
fix: move preventMistakes in InputLoader (#304)
This fixes an issue where URLs provided with --input are not
accepted by the preventMistakes filter.

The filter itself needs to execute _only_ on URLs returned
by the checkIn API, rather than on URLs returned by the
InputLoader, which may instead be user provided.

Reference issue: https://github.com/ooni/probe/issues/1435
2021-04-07 14:14:25 +02:00
Simone Basso
7172e750dd
fix(session): make sure tunnel code is tested (#301)
* fix(session): make sure tunnel code is tested

Part of https://github.com/ooni/probe/issues/985

* fix: add missing TunnelDir for correctness
2021-04-05 19:51:41 +02:00
Simone Basso
8b92037ae3
fix(tunnel/tor): keep tunneldir clean (#300)
* fix(tunnel/tor): keep tunneldir clean

This diff ensures that we don't keep the log file growing and
we also remove the temporary files created by the library we
are currently using for running tor from golang.

Part of https://github.com/ooni/probe/issues/985

* fix(session.go): tell use we're using a tunnel
2021-04-05 19:18:00 +02:00
Simone Basso
6aa2551c43
urlgetter: fix tunnel test (#299)
* urlgetter: fix tunnel test

This diff fixes the urlgetter test suite to make sure we
are correctly testing for tunnel creation.

While there, improve the way in which we create a testing
directory and add a test for that.

Part of https://github.com/ooni/probe/issues/985.

* fix comment

* fix comment
2021-04-05 18:25:43 +02:00
Simone Basso
973501dd11
feat(tunnel): implement the fake tunnel (#298)
This functionality should be helpful to test that the general
interface of the tunnel package is okay from the engine package.

Part of https://github.com/ooni/probe/issues/985
2021-04-05 17:41:15 +02:00
Simone Basso
76a50facc3
feat(tunnel): improve the test suite (#297)
Part of https://github.com/ooni/probe/issues/985
2021-04-05 16:38:25 +02:00
Simone Basso
2bafb179c3
refactor(tunnel): remove nil tunnels hack (#296)
* refactor(tunnel): remove nil tunnels hack

This code was originally introduced because a tunnel could be
nil in session.go. I have verified that every invocation of
tunnel.Start is careful to ensure that we have a tunnel name
and that we don't manipulate a nil tunnel.

For this reason, I'd rather remove this tricky bit of code and
further simplify the tunnel code.

Part of https://github.com/ooni/probe/issues/985

* even better docs
2021-04-05 16:08:16 +02:00
Simone Basso
c5ad5eedeb
feat: create tunnel inside NewSession (#286)
* feat: create tunnel inside NewSession

We want to create the tunnel when we create the session. This change
allows us to nicely ignore the problem of creating a tunnel when we
already have a proxy, as well as the problem of locking. Everything is
happening, in fact, inside of the NewSession factory.

Modify miniooni such that --tunnel is just syntactic sugar for
--proxy, at least for now. We want, in the future, to teach the
tunnel to possibly use a socks5 proxy.

Because starting a tunnel is a slow operation, we need a context in
NewSession. This causes a bunch of places to change. Not really a big
deal except we need to propagate the changes.

Make sure that the mobile code can create a new session using a
proxy for all the APIs we support.

Make sure all tests are still green and we don't loose coverage of
the various ways in which this code could be used.

This change is part of https://github.com/ooni/probe/issues/985.

* changes after merge

* fix: only keep tests that can hopefully work

While there, identify other places where we should add more
tests or fix integration tests.

Part of https://github.com/ooni/probe/issues/985
2021-04-05 15:28:13 +02:00
Simone Basso
a849213b59
fix(engine): break circular dep betwen session and tunnel (#295)
This diff breaks the circular dependency between session and
tunnel, by introducing the concept of early session.

An early session is a session that is able to fetch the psiphon
configuration file _only_ if it's embedded in the binary.

This breaks `miniooni --tunnel=psiphon` for users who have
access to the OONI backend. They are not the users we are
writing this feature for, though, so I think this is reasonable.

At the same time, this opens up the possibility of creating
a psiphon tunnel when constructing a session, which is the
approach I was following in https://github.com/ooni/probe-cli/pull/286.

This work is part of https://github.com/ooni/probe/issues/985.

Once this diff is in, I can land https://github.com/ooni/probe-cli/pull/286.
2021-04-05 12:02:35 +02:00
Simone Basso
8fe4e5410d
feat(tunnel): introduce persistent tunnel state dir (#294)
* feat(tunnel): introduce persistent tunnel state dir

This diff introduces a persistent state directory for tunnels, so that
we can bootstrap them more quickly after the first time.

Part of https://github.com/ooni/probe/issues/985

* fix: make tunnel dir optional

We have many tests where it does not make sense to explicitly
provide a tunnel dir because we're not using tunnels.

This should simplify setting up a session.

* fix(tunnel): repair tests

* final changes

* more cleanups
2021-04-05 11:27:41 +02:00
Simone Basso
47aa773731
refactor(tunnel): provide TorArgs and TorBinary directly (#293)
We're trying to remove a circular dependency between the measurement
Session and the tunnel package. To this end, continue to reduce the
dependency scope by providing TorArgs and TorBinary directly.

Part of https://github.com/ooni/probe/issues/985
2021-04-04 12:08:13 +02:00
Simone Basso
1eb63bc4b6
refactor(tunnel): remove dependecy from logger (#292)
Part of https://github.com/ooni/probe/issues/985
2021-04-04 11:23:03 +02:00
Simone Basso
dae53cb2a2
fix(tunnel/psiphon): don't overwrite config.WorkDir (#291)
Part of https://github.com/ooni/probe/issues/985
2021-04-03 21:34:19 +02:00
Simone Basso
d9aff19be5
refactor(tunnel): simplify tor implementation (#290)
Simplify interaction within the package by avoiding to have
a tor specific config. Use a Config instead.

Part of https://github.com/ooni/probe/issues/985.
2021-04-03 21:25:08 +02:00
Simone Basso
f739450370
refactor(tunnel): simplify psiphon implementation (#289)
Simplify interaction within the package by avoiding to have
a psiphon specific config. Use a Config instead.

Part of https://github.com/ooni/probe/issues/985.
2021-04-03 21:09:34 +02:00
Simone Basso
b53290cbfe
refactor(tunnel): pass the config as a pointer (#288)
Part of https://github.com/ooni/probe/issues/985
2021-04-03 20:12:56 +02:00
Simone Basso
ecb2aae1e8
refactor: merge psiphonx and torx into tunnel (#287)
* refactor: merge psiphonx and torx into tunnel

This is a case where it seems that merging these three packages into
a single package will enable us to better the implementation.

The goal is still https://github.com/ooni/probe/issues/985.

The roadblock I'm trying to overcome is
https://github.com/ooni/probe-cli/pull/286#pullrequestreview-627460104.

* avoid duplicating logger for now
2021-04-03 19:57:21 +02:00
Simone Basso
d7cd1ebcaf
refactor(riseupvpn): minor changes and annotations (#275) 2021-04-02 17:58:36 +02:00
Simone Basso
c89ecce3e0
feat: support embedding encrypted psiphon config (#285)
We use an optional build tag to hide this configuration. When you
choose this configuration, you need to provide the encrypted config
as well as the corresponding decryption key.

This is not the final design. This is an interim design to start
working and experimenting with this functionality. The general
idea here is to support psiphon in the binaries we build without
committing the psiphon config to the repository itself.

Part of https://github.com/ooni/probe/issues/985
2021-04-02 17:36:06 +02:00
Simone Basso
79e8424677
refactor: remove model.ExperimentOrchestraClient (#284)
* ongoing

* while there, make sure we test everything

* reorganize previous commit

* ensure we have reasonable coverage in session

The code in here would be better with unit tests. We have too many
integration tests and the tests overall are too slow. But it's also
true that I should not write a giant diff as part of this PR.
2021-04-02 12:03:18 +02:00
Simone Basso
4700ba791d
chore: set version to 3.10.0-alpha (#283) 2021-04-02 10:16:25 +02:00
Simone Basso
51459e23b2
fix(oohelper): make sure the CI is green (#282)
* chore(oohelper): increase tests verbosity

Hopefully this helps with https://github.com/ooni/probe/issues/1409.

* fix(oohelper): use a nonstandard resolver

* fix previous

* make the diff pleasant/committable/correct
2021-04-01 20:11:13 +02:00
Simone Basso
2ca9496c04
Release: update user-agent, bundled CA, version number (#281)
* chore: update the user-agent we use

Part of the check-list at https://github.com/ooni/probe/issues/1369.

* chore: set version to 3.9.0

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

* chore: run go generate ./...

This is meant to update the bundled CA. We have heard of issues with
our bundled CA, but it seems there have been no changes upstream.

The website https://curl.se/docs/caextract.html still lists as the
last change the one done on Jan 19, 2021, which is the version of
the CA that we're currently bundling.

For the sake of continuing with the release process, I am going
to further investigate the CA once the release is done.

This chore is part of https://github.com/ooni/probe/issues/1369.
2021-04-01 18:40:30 +02:00
Simone Basso
31e478b04e
refactor: redesign how we import assets (#260)
* fix(pkg.go.dev): import a subpackage containing the assets

We're trying to fix this issue that pkg.go.dev does not build.

Thanks to @hellais for this very neat idea! Let's keep our
fingers crossed and see whether it fixes!

* feat: use embedded geoip databases

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

Work done as part of https://github.com/ooni/probe/issues/1369.

* fix(assetsx): add tests

* feat: simplify and just vendor uncompressed DBs

* remove tests that seems not necessary anymore

* fix: run go mod tidy

* Address https://github.com/ooni/probe-cli/pull/260/files#r605181364

* rewrite a test in a better way

* fix: gently cleanup the legacy assetsdir

Do not remove the whole directory with brute force. Just zap the
files whose name we know. Then attempt to delete the legacy directory
as well. If not empty, just fail. This is fine because it means the
user has stored other files inside the directory.

* fix: create .miniooni if missing
2021-04-01 16:57:31 +02:00
Simone Basso
7ca32b5ce6
release process: update dependencies (#280)
Part of the check-list at https://github.com/ooni/probe/issues/1369
2021-03-31 16:40:58 +02:00
Simone Basso
bd451016f5
release 3.9.0 process: reduce warnings (#279)
* fix(riseupvpn): address gofmt warning

Thanks to https://goreportcard.com/report/github.com/ooni/probe-cli.

* fix(utils.go): correct the docu-comment

Thanks to https://goreportcard.com/report/github.com/ooni/probe-cli

* fix: improve spelling

Thanks to https://goreportcard.com/report/github.com/ooni/probe-cli

* fix(modelx_test.go): avoid inefassign warning

Thanks to https://goreportcard.com/report/github.com/ooni/probe-cli

* fix: reduce number of ineffective assignments

Thanks to https://goreportcard.com/report/github.com/ooni/probe-cli
2021-03-31 15:59:19 +02:00
cyBerta
991b0a6120
riseupvpn: reduce false positives (#233)
* fetch RiseupVPN CA cert with MultiGetter. It allows us to write better tests and ensures this test step is added in the logs

* Implement TransportStatus for RiseupVPN tests. It indicates if a whole transport is blocked, which is considered as a test anomaly

* Redesign unit tests for RiseupVPN. Instead of a real backend, mocked server responses are used. Tests for invalid CA certs and for TransportStatus are added.

* Update internal/engine/experiment/riseupvpn/riseupvpn.go

Co-authored-by: Simone Basso <bassosimone@gmail.com>
2021-03-30 12:02:51 +02:00
Simone Basso
a0763756b2
fix(miniooni): replace --limit with --max-runtime (#272)
Part of https://github.com/ooni/probe/issues/1299
2021-03-29 20:38:23 +02:00
Simone Basso
b718335ee3
refactor(inputloader): remove unnecessary javisms (#271)
Part of https://github.com/ooni/probe/issues/1299.
2021-03-29 20:00:50 +02:00
Simone Basso
1da64f6d9f
fix(internal/fsx): remove pre Go 1.16 definitions (#270)
Occurred to me while working on https://github.com/ooni/probe/issues/1299.
2021-03-29 19:37:32 +02:00
Simone Basso
87e5234586
refactor(inputloader): all fast tests together (#269)
This change allows us to have all fasts tests together. They are
mostly unit tests or integration tests that do not require the
network. The advantage of this strategy is the following. We can
now run all these tests with a single click in VSCode. In turn,
doing that tells us which lines of code we are not covering.

The tests requiring the network are in a separate file, so we can
easily see which lines of code are testing without using the network
and which ones instead depend on that. (Currently, 100% of the
inputloader.go file is tested without using the network.)

While there, rename the other file such that is clear that it
contains tests requiring the network. We now have some tests in
inputloader_test.go that are not strictly unit tests.

This refactoring was identified as useful while working
on https://github.com/ooni/probe/issues/1299.
2021-03-29 19:19:06 +02:00
Simone Basso
f5b5ac47b0
refactor: merge libminiooni into cmd/miniooni (#268)
We used to have an external package called libminiooni so that
third parties could use it. We wrote this such that we could
support github.com/bassosimone/aladdin.

That was actually a not-so-good idea because it added to the APIs
we needed to maintain.

Since the merge of engine into cli, such an API is not public
anymore and aladdin has been deprecated and archived.

Therefore, we can now cleanup the situation and merge libminiooni
into miniooni again, thus making the codebase more local.

This cleanup has been identified while working on
https://github.com/ooni/probe/issues/1299.
2021-03-29 19:03:53 +02:00
Simone Basso
5973c88a05
feat(inputloader): use check-in to fetch URLs (#267)
* ongoing work

* reduce diff with master

* feat(inputloader): use the check-in API

Part of https://github.com/ooni/probe/issues/1299

* fix: better naming for a variable

* chore: add more tests

* fix: add one more TODO
2021-03-29 18:46:26 +02:00
Simone Basso
e0b0dfedc1
feat(session): expose CheckIn method (#266)
* feat(session): expose CheckIn method

It seems to me the right thing to do is to query the CheckIn API
from the Session rather than querying it from InputLoader.

Then, InputLoader could just take a reference to a Session-like
interface that allows this functionality.

So, this diff exposes the Session.CheckIn method.

Doing that, in turn, required some refactoring to allow for
more and better unit tests.

While doing that, I also noticed that Session required a mutex
to be a well-behaving type, so I did that.

While doing that, I also tried to cover all the lines in session.go
and, as part of that, I have removed unused code.

Reference issue: https://github.com/ooni/probe/issues/1299.

* fix: reinstate comment I shan't have removed

* fix: repair broken test

* fix: a bit more coverage, annotations, etc.

* Update internal/engine/session.go

* Update internal/engine/session_integration_test.go

* Update internal/engine/session_internal_test.go
2021-03-29 15:04:41 +02:00
Simone Basso
0115d6c470
refactor(inputloader): better docs and naming (#265)
* refactor(inputloader): better docs and naming

Work done as part of https://github.com/ooni/probe/issues/1299.

* fix: correct a typo
2021-03-26 09:34:27 +01:00
Simone Basso
c94721d9e5
fix(sessionresolver): proxy check conditional on existing proxy (#264)
There was a face-palming error in the implementation causing the proxy
check to be implemented also without a proxy.

This meant that we were ALWAYS skipping http3 and system resolvers.

The bug has been introduced in 3.8.0. So, the currently released
version of the probe, sadly, has this beheavior :-(.

Reference issue https://github.com/ooni/probe/issues/1426.
2021-03-25 15:18:29 +01:00
Simone Basso
3b029ee0d6
feat(ExperimentOrchestraClient): add CheckIn (#263)
We use ExperimentOrchestraClient in several places to help us
calling probe-services APIs. We need to call CheckIn because we
want to use CheckIn in InputLoader.

(We also want to remove the URLs API, but that is not something
doable now, since the mobile app is still using this API via
the wrappers at pkg/oonimkall.)

Work part of https://github.com/ooni/probe/issues/1299.
2021-03-25 12:02:02 +01:00
Simone Basso
576059b3fa
fix: apply staticcheck suggestions (#262)
Preliminary work done as part of https://github.com/ooni/probe/issues/1299
2021-03-24 12:35:53 +01:00
Simone Basso
fc19c9901a
fix(webconnectivity): expose network events (#258)
* fix(webconnectivity): expose network events

By not exposing network events in webconnectivity, we are missing
several interesting, explanatory data points.

This diff fixes the issue by:

1. enriching the definition of network events to include extra
data useful for performing (manual) data analysis;

2. adding a tags field to network events such that we can add
tags to specific events and understand where they come from;

3. exposing all the (tagged) network events that happen when running
a webconnectivity experiment.

See https://github.com/ooni/probe-engine/issues/1157.

* progress

* more work towards landing this diff

* Apply suggestions from code review
2021-03-23 16:46:46 +01:00
Arturo Filastò
70d7c1a22c
Add signal to the im test group (#259)
* Add signal to the im test group

* fix(ipconfig_test.go): disable when running in CI

Reference issue: https://github.com/ooni/probe/issues/1418

* fix(geolocate): remove unused variable

Came across this while looking into this issue with the CI that
is now failing. Guess fixing it here comes across as leaving the
camp slightly less in a bad shape than how I found it.

Co-authored-by: Simone Basso <bassosimone@gmail.com>
2021-03-22 14:31:50 +01:00
Simone Basso
28ce79eff1
feat(ooapi): add toplevel client and simplify API (#248)
* feat(ooapi): add toplevel client and simplify API

This diff should simplify using ooapi from other packages by
adding more abstraction that wraps the existing code.

Part of https://github.com/ooni/probe/issues/1355.

* fix(ooapi): use correct comment for cloners

See https://github.com/ooni/probe-cli/pull/248#discussion_r590663843

* fix(ooapi): make sure the documentation is current

See https://github.com/ooni/probe-cli/pull/248#discussion_r590665773

* fix(ooapi): automate copying APIs

See https://github.com/ooni/probe-cli/pull/248#discussion_r590665837

* feat(ooapi): add unit tests for clientcall.go

See https://github.com/ooni/probe-cli/pull/248#discussion_r590666297

* fix(ooapi): rewrite integration tests to use toplevel API

See https://github.com/ooni/probe-cli/pull/248#discussion_r590665084
2021-03-19 09:30:42 +01:00
Simone Basso
c22828d369
chore: bless 3.9.0-alpha (#257) 2021-03-18 08:47:07 +01:00
Simone Basso
53e6b694cb
chore: bless 3.8.0 (#256) 2021-03-15 14:54:13 +01:00
Simone Basso
c324822870
fix(stunreachability): avoid goroutine spin and memleak (#255)
This fix addresses the bug described in issue https://github.com/ooni/probe/issues/1403.
2021-03-15 10:59:28 +01:00
Simone Basso
a02052fb0c
chore: rename stun_reachability => stunreachability (#254)
See https://github.com/ooni/probe/issues/1394

Ok @hellais @FedericoCeratto
2021-03-11 19:35:22 +01:00
Simone Basso
fbee736e90
fix(geolocate): no proxy when discovering our IP address (#251)
* fix(geolocate): no proxy when discovering our IP address

The use case of --proxy is that you cannot contact the OONI
backend otherwise. It is wrong, though, using the proxy when
discovering our IP address. The measurement won't use the
proxy anyway. Therefore, we need to use the IP address that
is performing the measurement. Not the one of the proxy.

What's more, stun is not using a proxy. Therefore, it does
not make much sense that http IP resolvers use a proxy. This
leads to inconsistencies. So, here's anothe reason why this
patch is a good thing (TM).

Finally, because knowing the IP address enables us to sanitize
the data, it's important we discover the correct IP.

Now, up until this point, the `--proxy` option has mostly
been a developers toy. But, users have asked us to have the
possibility of configuring a proxy.

This explains why I have been looking into making `--proxy`
right for a couple of hours now.

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

* fix(session): properly configure the IP lookupper
2021-03-10 12:01:08 +01:00
Simone Basso
f0110fe85a
fix(sessionresolver): honour the proxy (#250)
In reality, we are not going to use the sessionresolver when we're
using a proxy (I just tested). But, it nonetheless feels a lot more
robust to write a correct sessionresolver that handles the proxy
in the most correct way. That is, the sessionresolver will now skip
all the entries that cannot use a socks5 proxy (including among them
also the system resolver). What's more, it will construct a child
resolver that propagates the proxy.

We have confidence that this holds true because we have added a test
ensuring that we are really using the configured proxy.

See https://github.com/ooni/probe/issues/1381
2021-03-10 10:39:57 +01:00
Simone Basso
4da372a84d
feat(libminiooni): implement --version and --limit (#247)
See https://github.com/ooni/probe/issues/1380
2021-03-08 18:31:42 +01:00
Simone Basso
58788d3a83
chore: we're now at v3.8.0-alpha (#245) 2021-03-08 14:46:48 +01:00
Simone Basso
784d3d0f73
chore: release 3.7.0 (#244)
This comes just a few days after 3.6.0. It contains small
improvements required by ooni/probe-desktop.

For this reason, I am going to skeep the normal release
process and I am just bumping the version number.
2021-03-08 13:51:43 +01:00
Simone Basso
2ef5fb503a
fix(webconnectivity): allow measuring https://1.1.1.1 (#241)
* fix(webconnectivity): allow measuring https://1.1.1.1

There were two issues preventing us from doing so:

1. in netx, the address resolver was too later in the resolver
chain. Therefore, its result wasn't added to the events.

2. when building the DNSCache (in httpget.go), we didn't consider
the case where the input is an address. We need to treat this
case specially to make sure there is no DNSCache.

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

* fix: add unit tests for code making the dnscache

* fix(netx): make sure all tests pass

* chore: bump webconnectivity version
2021-03-08 12:05:43 +01:00
Simone Basso
55bdebe8b2
engine/ooapi: autogenerated API with login and caching (#234)
* internal/engine/ooapi: auto-generated API client

* feat: introduce the callers abstraction

* feat: implement API caching on disk

* feat: implement cloneWithToken when we require login

* feat: implement login

* fix: do not cache all APIs

* feat: start making space for more tests

* feat: implement caching policy

* feat: write tests for caching layer

* feat: add integration tests and fix some minor issues

* feat: write much more unit tests

* feat: add some more easy unit tests

* feat: add tests that use a local server

While there, make sure many fields we care about are OK.

* doc: write basic documentation

* fix: tweak sentence

* doc: improve ooapi documentation

* doc(ooapi): other documentation improvements

* fix(ooapi): remove caching for most APIs

We discussed this topic yesterday with @FedericoCeratto. The only
place where we want LRU caching is MeasurementMeta.

* feat(ooapi): improve handling of errors during login

This was also discussed yesterday with @FedericoCeratto

* fix(swaggerdiff_test.go): temporarily disable

Before I work on this, I need to tend onto other tasks.

* fix(ootest): add one more test case

We're going towards 100% coverage of this package, as it ought to be.

* feat(ooapi): test cases for when the probe clock is off

* fix(ooapi): change test to have 100% unittest coverage

* feat: sync server and client APIs definition

Companion PR: https://github.com/ooni/api/pull/218

* fix(ooapi): start testing again against API

* fix(ooapi): only generate each file once

* chore: set version to 3.7.0-alpha

While there, make sure we don't always skip a currently failing
riseupvpn test, and slightly clarify the readme.

* fix(kvstore): less scoped error message
2021-03-04 11:51:07 +01:00
Simone Basso
ae32ffa13b
chore: set version to 3.7.0-alpha (#240)
While there, make sure we don't always skip a currently failing
riseupvpn test, and slightly clarify the readme.
2021-03-04 11:36:41 +01:00
Simone Basso
0d4323ae66
Release 3.6.0 (#239)
* chore: update dependencies

* chore: update user agent for measurements

* chore: we're now at v3.6.0

* chore: update assets

* chore: update bundled CA

* fix: address some goreportcard.com warnings

* fix(debian/changelog): zap release that breaks out build scripts

We're forcing the content of changelog with `dch`, so it's fine to
not have any specific new release in there.

* fix: make sure tests are passing locally

Notably, I removed a chunk of code where we were checking for network
activity. Now we don't fetch the databases and it's not important. Before,
it was important because the databases are ~large.

* fix: temporarily comment out riseupvn integration tests

See https://github.com/ooni/probe/issues/1354 for work aimed at
reducing the rate of false positives (thanks @cyBerta!)
2021-03-03 14:42:17 +01:00
Simone Basso
034db78f94
refactor(sessionresolver): adapt to changing network conditions (#238)
* feat(sessionresolver): try many and use what works

* fix(sessionresolver): make sure we can use quic

* fix: the config struct is unnecessary

* fix: make kvstore optional

* feat: write simple integration test

* feat: start adding tests

* feat: continue writing tests

* fix(sessionresolver): add more unit tests

* fix(sessionresolver): finish adding tests

* refactor(sessionresolver): changes after code review
2021-03-03 11:28:39 +01:00
Simone Basso
322394fe63
feat: use go1.16 and resources embedding (#235)
* feat: use go1.16 embedding for resources

We want to embed everything that can be easily embedded. We should, at a
minimum, replace the downloading of resources and bindata.

Ref: https://github.com/ooni/probe/issues/1367.

* fix: get rid of bindata and use go embed instead

* fix: start unbreaking some automatic tests

* fix: fetch resources as part of the mobile build

* fix: convert more stuff to go1.16

I still expect many breakages, but we'll fix them.

* fix: make the windows CI green

* fix: get resources before running QA

* fix: go1.16 uses modules by default

* hopefully fix all other outstanding issues

* fix(QA/telegram.py): add another DC IP address

* Apply suggestions from code review
2021-03-02 12:08:24 +01:00
Arturo Filastò
f46fbcad16
Add new telegram DC endpoint (#232)
* Add new telegram DC endpoint

Based on: 65ba81f504/Telegram/SourceFiles/mtproto/mtproto_dc_options.cpp

* Update internal/engine/experiment/telegram/telegram.go

Co-authored-by: Simone Basso <bassosimone@gmail.com>
2021-02-26 14:11:24 +01:00
Arturo Filastò
5e5cfa72e7
MVP of a signal messenger test (#230)
* MVP of a signal messenger test

* Add minimal signal test unit tests

* Add Signal test to the im nettest group

* Add test for https://sfu.voip.signal.org/

* Fix bug in client-side determination of blocking status

* Add uptime.signal.org to the test targets

* Add more tests

* Check for invalid CA being passed
* Check that the update function works as expected

* Update internal/engine/experiment/signal/signal_test.go

Co-authored-by: Simone Basso <bassosimone@gmail.com>

* fix: back out URL we shouldn't have changed

When merging probe-engine into probe-cli, we changed too many URLs
and some of them should not have been changed.

I noticed this during the review of Signal and I choose to add
this commit to revert such changes.

While there, make sure the URL of the experiment is OK.

* fix(signal): reach 100% of coverage

Just so that we can focus on areas of the codebase where we need
more coverage, let us avoid missing an easy line to test.

Co-authored-by: Simone Basso <bassosimone@gmail.com>
2021-02-26 10:16:34 +01:00
Arturo Filastò
fe7b5eda68 Bump to version 3.5.2 2021-02-12 19:56:46 +01:00
Simone Basso
311c30a961
chore(miniooni): print start time (#227)
This is useful when someone is running manual measurements and is
sharing their measurements with us, because it means we don't need
manually keep track of this bit of information.

Closes https://github.com/ooni/probe-engine/issues/1194
2021-02-12 08:17:16 +01:00
Simone Basso
3155549513
fix(http body saver): properly deal with EOF terminated bodies (#226)
See https://github.com/ooni/probe-engine/issues/1191
2021-02-11 14:57:14 +01:00
Simone Basso
c41114261c
Revert "fix(riseupvpn): skip currently failing tests (#212)" (#225)
This reverts commit 43f95e2c9a.

We can now safely close https://github.com/ooni/probe/issues/1338,
since the upstream issue is gone. I think this issue we have seen is
also possibly related to https://github.com/ooni/probe/issues/1348.

Cc: @cyberta.
2021-02-11 10:10:52 +01:00
Simone Basso
18ca6d5f35
fix: use golang.org/x/sys/execabs (#224)
Closes https://github.com/ooni/probe-engine/issues/1195
2021-02-10 07:40:48 +01:00
Simone Basso
f53b3be66e
feat: add end-to-end testing to this repository (#220)
* feat: add end-to-end testing to this repository

Part of https://github.com/ooni/probe-engine/issues/1181

Motivation: we want to run this check from the repository where
we work the most, such that it's unlikely it pauses due to inactivity,
as it may happen for less frequently touched upon repositories.

Code adapted from https://github.com/ooni/e2etesting/

* fix: correct name for main branch
2021-02-04 14:25:03 +01:00
Simone Basso
26d807c50f
fix: always use probe-cli version (and make it alpha) (#219)
See https://github.com/ooni/probe-engine/issues/1181

While there, run `go fmt ./...`
2021-02-04 11:00:27 +01:00
Simone Basso
cc5fcede44
doc: merge the engine and the cli readmes (#215)
Part of https://github.com/ooni/probe/issues/1335
2021-02-03 19:29:12 +01:00
Simone Basso
31cf7d2fdf
doc: ensure all top dirs have an explanatory README (#214)
* doc: ensure all top dirs have an explanatory README

This makes the repository a lil bit nicer to newcomers.

Part of https://github.com/ooni/probe/issues/1335

* fix: re-run bindata to embed the README

The readme is small, so we can pay the price of adding it.

On a related note, I am very pleased the Go team implemented the
`//go:embed` feature, so we can get rid of this bindata thing.
2021-02-03 16:54:00 +01:00
Simone Basso
43f95e2c9a
fix(riseupvpn): skip currently failing tests (#212)
Part of https://github.com/ooni/probe/issues/1335.

Tracked also by https://github.com/ooni/probe/issues/1338.
2021-02-03 16:06:03 +01:00
Simone Basso
ef8fa97e13
chore: continue merging probe-engine into probe-cli (#211)
* chore: remove duplicate code of conduct

* chore: remove AUTHORS file

I doubt this actually has any value in the era of GitHub.

* chore: move CODEOWNERS to toplevel

* chore: move CONTRIBUTING.md to toplevel and adapt it

* chore: remove duplicated LICENSE file

* chore(engine): remove now-obsolete design document

* chore: remove the testusing test

We're not going to make this code importable from third parties
like we did for probe-engine. It seems this feature was only used
for the experiment in Spain so it makes sense to drop it.

* chore: enable code generation tests

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

* chore: enable code-ql checks

* cleanup: remove libooniffi code and tests

It seems this code is not used. We are not aware of anyone using it. And we
don't want to expose it publicly as an API. So, what to do?

I guess it's fine to delete it. If there is anyone that needs it, we have
in the history a reference to it and we can always reinstate it.

* chore: move issue templates to ooni/probe
2021-02-03 14:42:51 +01:00
Simone Basso
c824612812
refactor: enable automatic iOS builds (#209)
* refactor: enable automatic iOS builds

Part of https://github.com/ooni/probe/issues/1335

* fix: go mod tidy
2021-02-03 13:51:15 +01:00
Simone Basso
0c48bc0746
refactor: enable QA tests and jafar self test (#208)
* refactor: enable QA tests and jafar self test

Part of https://github.com/ooni/probe/issues/1335

* chore: make sure all workflows run on release branches
2021-02-03 13:20:37 +01:00
Simone Basso
4eeadd06a5
refactor: move more commands to internal/cmd (#207)
* refactor: move more commands to internal/cmd

Part of https://github.com/ooni/probe/issues/1335.

We would like all commands to be at the same level of engine
rather than inside engine (now that we can do it).

* fix: update .gitignore

* refactor: also move jafar outside engine

* We should be good now?
2021-02-03 12:23:15 +01:00
Simone Basso
6351d898d6
refactor: miniooni should be outside of the engine (#206)
* refactor: miniooni should be outside of the engine

This is part of https://github.com/ooni/probe/issues/1335. We also need
to think whether we wanna keep libminiooni and miniooni separated.

The previous use case for having a top-level libminiooni was that of
enabling others to integrate miniooni into other binaries.

This was usegul when studying internet censorship in Spain in May 2020.

I am wondering whether we should be keeping this complexity. I am not
sure about this and probably we should be killing it.

(In any case, reducing complexity is not the objective of this diff,
since I would like instead to move things around with minimal changes
and make sure we have a ~good repository organization here.)

* fix: import in libminiooni
2021-02-03 11:21:10 +01:00
Simone Basso
99b28c1d95
refactor: start building an Android package (#205)
* refactor: start building an Android package

Part of https://github.com/ooni/probe/issues/1335.

This seems also a good moment to move some packages out of the
engine, e.g., oonimkall. This package, for example, is a consumer
of the engine, so it makes sense it's not _inside_ it.

* fix: committed some stuff I didn't need to commit

* fix: oonimkall needs to be public to build

The side effect is that we will probably need to bump the major
version number every time we change one of these APIs.

(We can also of course choose to violate the basic guidelines of Go
software, but I believe this is bad form.)

I have no problem in bumping the major quite frequently and in
any case this monorepo solution is convinving me more than continuing
to keep a split between engine and cli. The need to embed assets to
make the probe more reliable trumps the negative effects of having to
~frequently bump major because we expose a public API.

* fix: let's not forget about libooniffi

Honestly, I don't know what to do with this library. I added it
to provide a drop in replacement for MK but I have no idea whether
it's used and useful. I would not feel comfortable exposing it,
unlike oonimkall, since we're not using it.

It may be that the right thing to do here is just to delete the
package and reduce the amount of code we're maintaining?

* woops, we're still missing the publish android script

* fix(publish-android.bash): add proper API key

* ouch fix another place where the name changed
2021-02-03 10:51:14 +01:00
Simone Basso
6714b79f97
refactor: integrate more probe-engine workflows (#204)
This diff is part of https://github.com/ooni/probe/issues/1335.

We are moving more probe-engine workflows to toplevel.

The general idea here is to migrate all possible workflows and to
delete the ones that we cannot use in this repo (if any).
2021-02-02 15:57:37 +01:00
Simone Basso
90d15c1c09
refactor: build miniooni from toplevel (#203)
* refactor: build miniooni from toplevel

Of course, also move the specific test checking whether we are
still able of building miniooni.

Part of https://github.com/ooni/probe/issues/1335

* build for current branch just to confirm

* fix: correct the path where linux/arm binary is

* okay, it works, we can remove the special rule
2021-02-02 15:34:03 +01:00
Simone Basso
47dd063b77
fix: add missing files causing tests to fail (#202)
* fix: add missing files causing tests to fail

See https://github.com/ooni/probe/issues/1335#issuecomment-771559718

* fix: toggle verbose so we better understand the tests output
2021-02-02 14:18:22 +01:00
Simone Basso
d57c78bc71
chore: merge probe-engine into probe-cli (#201)
This is how I did it:

1. `git clone https://github.com/ooni/probe-engine internal/engine`

2. ```
(cd internal/engine && git describe --tags)
v0.23.0
```

3. `nvim go.mod` (merging `go.mod` with `internal/engine/go.mod`

4. `rm -rf internal/.git internal/engine/go.{mod,sum}`

5. `git add internal/engine`

6. `find . -type f -name \*.go -exec sed -i 's@/ooni/probe-engine@/ooni/probe-cli/v3/internal/engine@g' {} \;`

7. `go build ./...` (passes)

8. `go test -race ./...` (temporary failure on RiseupVPN)

9. `go mod tidy`

10. this commit message

Once this piece of work is done, we can build a new version of `ooniprobe` that
is using `internal/engine` directly. We need to do more work to ensure all the
other functionality in `probe-engine` (e.g. making mobile packages) are still WAI.

Part of https://github.com/ooni/probe/issues/1335
2021-02-02 12:05:47 +01:00
Simone Basso
b1ce300c8d
fix: import path should be github.com/ooni/probe-cli/v3 (#200)
See https://github.com/ooni/probe/issues/1335#issuecomment-771499511
2021-02-02 10:32:46 +01:00
Arturo Filastò
b84fe2c7e3
Merge pull request #197 from ooni/fix-list-ui
Fixup the rightpad on the list command
2021-01-22 13:48:54 +01:00
Arturo Filastò
06699445a7 Fixup the rightpad on the list command 2021-01-22 12:46:57 +01:00
Simone Basso
f2af3db193
fix(show): make sure we quote URL/query (#196) 2021-01-22 12:14:19 +01:00
Simone Basso
9577d7e11e
chore: 3.5.0-alpha for the master branch 2021-01-20 14:06:12 +01:00
Simone Basso
795f3be44e
chore: release 3.4.0 (#195)
This release only contains updates in debian packaging. All other platforms
could safely continue to use 3.2.0 or 3.3.0.

I didn't want to make a path release, though, because I didn't want to convey
the meaning that something was fixed.

Related to https://github.com/ooni/ooni.org/issues/677
2021-01-20 13:31:54 +01:00
Simone Basso
dc6b492986
chore: v3.4.0-alpha for the main branch 2021-01-19 20:36:38 +01:00
Simone Basso
4853ddf810
chore: bless v3.3.0 (#194) 2021-01-19 20:25:00 +01:00
Simone Basso
504a4e79d4
feat: implement darwin launch agent (#192)
* feat: sketch out periodic command

* feat: sketch out periodic command for macOS

* feat: implement darwin's launch agent

* refactor: better way to run on darwin

Make sure we have code that builds on all platforms.

* fix(run): max 10 URLs with darwin in unattended mode

* feat: add support for seeing/streaming logs

* feat: implement the status command and add usage hints

* feat(periodic): run onboarding if needed

* fix: no too confusing function names

* fix: s/periodic/autorun/

Discussed earlier this morning with @hellais.

* fix: we cannot show logs before Big Sur

Bug reported by @hellais.
2021-01-14 18:32:05 +01:00
Simone Basso
6fbad8555f
chore: set version to 3.3.0-alpha 2021-01-13 00:47:12 +01:00
Simone Basso
40d5f86698
chore: bless 3.2.0 (#191) 2021-01-13 00:40:48 +01:00
Simone Basso
acfa429127
chore: update deps (probe-engine 0.22.0 et al.) (#190)
The CloseReport method is gone. We don't need to close reports
anymore with the new OONI backend.

The InputsRequired flags now is InputsOrQueryTestLists.
2021-01-13 00:25:25 +01:00
Arturo Filastò
af4cbd1846
Implement support for not writing to disk and fetching measurements f… (#189)
* Implement support for not writing to disk and fetching measurements from the API

* Handle case of input not being set

* Comment about exposing raw_measurement in probe-engine

* Add basic test for GetMeasurementJSON

* Update internal/database/actions.go

Co-authored-by: Simone Basso <bassosimone@gmail.com>
2021-01-11 19:59:20 +01:00
Arturo Filastò
5cfce6acd0 Implement informed consent migration using the config file 2021-01-08 14:14:14 +01:00
Simone Basso
1a4b70c9aa chore: we're now at 3.2.0-alpha 2020-12-08 15:59:48 +01:00
Simone Basso
c9ea92fc53
chore: bless 3.1.0 (#186) 2020-12-07 19:42:13 +01:00
cyBerta
9192ead36d
cli: expose riseupvpn (#171) 2020-12-07 17:14:48 +01:00
Simone Basso
d402cd9090
feat: implement the unattended group (#183)
We don't want to run performance in the background because this
causes too much traffic towards m-lab servers.

When we'll have the check-in API, this will be the entry point we'll
use to contact such an API and get things to do.

Part of https://github.com/ooni/probe/issues/1289.
2020-12-01 16:52:12 +01:00
Simone Basso
60d08eef3b
refactor: move code to run group in nettests package (#182)
Part of https://github.com/ooni/probe/issues/1289
2020-12-01 15:04:04 +01:00
Simone Basso
2381c50dc5
feat: implement syslog logging (#181)
* feat: implement syslog logging

With this functionality in tree, macOS users could easily access
ooniprobe logs by filtering by process name in the console app.

Part of https://github.com/ooni/probe/issues/1289

* fix: build on windows

* fix: all build issues
2020-12-01 13:31:15 +01:00
Simone Basso
cfd3b8f9b2
feat(cli/run): read inputs from file/cmdline (#180)
This diff introduces the possibility of specifying --input-file file
multiple times to force ooniprobe to read inputs from file.

Like we do for miniooni, the file shall contain a single entry per
line and this entry should be a URL for websites.

Likewise, one can specify --input URL multiple times.

This implementation is a very simple, initial implementation and there
is a bunch of changes I'd like to add on top of it.

And also perhaps a bunch of cleanups.

I've chosen to expose these flag _only_ for websites for now.

Part of https://github.com/ooni/probe/issues/1283.
2020-12-01 07:21:33 +01:00
Simone Basso
a324e94973
refactor(webconnectivity): use engine.InputLoader (#179)
This diff pins to ooni/probe-engine@3049779878
and starts using the recently introduced probe-engine APIs.

Namely, here, we use the InputLoader for loading URLs.

I've confirmed manually everything is still working as intended.

Part of https://github.com/ooni/probe/issues/1283.

(In particular, the InputLoader is the abstraction allowing us to load
input from several sources, including command line flags and external
files.)
2020-11-30 15:39:25 +01:00
Simone Basso
2fc160b202
cleanup(nettests): remove unused OnDataUsage (#178)
Part of https://github.com/ooni/probe/issues/1283
2020-11-26 19:12:27 +01:00
Simone Basso
95906fbcce
feat: use ooni/probe-engine@286613b74e and cleanup (#177)
* feat: use ooni/probe-engine@286613b74e and cleanup

1. zap unused configuration settings from the config file but do not
bump the version number because doing that _may_ interact in unexpected
ways with probe-desktop (hence https://github.com/ooni/probe/issues/1297)
and also because we've just _removed_ stuff for now, therefore any
previous configuration file will continue to work, except that we'll
be ignoring a bunch of options. In a future version of probe-cli I'll
spend some time to further improve config file management.

2. accordingly, make sure all current configuration files that are around
in the tree are current and only feature supported options.

3. update to ooni/probe-engine@286613b74e, which contains a bunch of
APIs that should allow us to simplify the interaction between the cli and
the engine, by sharing code more cleverly.

4. zap GetTestKeys because now we use code in probe-engine instead.

5. zap LogSummary because it was not being used.

6. the main change related to cleaning up the config and to the update
to the latest probe-engine is that include_{cc,asn,ip} settings are
gone and we now share the CC and the ASN and we never share the IP addr.

Reference issue: https://github.com/ooni/probe/issues/1283.

After this change is landed, there's a bunch more work to do to further
unify cli and engine. The final state will be that the cli uses ~the code
used by miniooni, so it will have a bunch of desirable options.

* fix: bindata after recent changes
2020-11-26 18:48:20 +01:00
Simone Basso
e4ef279b80
fix(onboard): fail if input is /dev/null (#176)
When the input is /dev/null, every read returns EOF. In general, it
may also happen that read doesn't work as intended. So, the robust thing
to do here is to ensure that we check the return values. By doing that
we notice of io.EOF errors and we don't proceed with the onboarding.

This diff fixes the issue described by https://github.com/ooni/probe/issues/1281
however it may be that we also want (in the near or not-so-near future)
to stop onboarding if the input terminal is not a tty. This is however a
possible future evolution that should not prevent us for committing and
merging this simple fix that unblocks creating a Debian package.
2020-11-24 09:19:34 +01:00
Simone Basso
7eedf4d947 feat(geoip, info): write comprehensive unit tests 2020-11-20 12:19:51 +01:00
Simone Basso
fa803300bb refactor(ooni): introduce interfaces for testability 2020-11-20 12:19:51 +01:00
Simone Basso
c55f67273e
chore: set version to 3.0.12-alpha (#172)
* chore: set version to 3.0.12-alpha

I need to bless 3.0.11 now to pin to ooni/probe-engine v0.20.2.

* chore: update all dependencies

Most notably, pin to ooni/probe-engine 0.20.2.
2020-11-17 18:22:46 +01:00
Simone Basso
9e238c27dd
refactor(internal/ooni): Context => Probe (#170)
Closes https://github.com/ooni/probe/issues/939
2020-11-13 19:01:06 +01:00
Simone Basso
163922e001
refactor: run go fmt ./... (#169) 2020-11-13 18:42:10 +01:00
Simone Basso
c81393b31a
refactor: move ooni into the internal package (#168)
With this commit we've reorganised the package structure. Now I will
go more in depth and perform further refactoring.
2020-11-13 17:47:29 +01:00
Simone Basso
bc85efa6e5
refactor: version is now an internal package (#167)
Like for previous commits, just refactoring/yak shaving.
2020-11-13 17:37:06 +01:00
Simone Basso
a4ae94b5ec
refactor: now utils is an internal package (#166)
Let us make internal everything because this is not a library.
2020-11-13 17:28:02 +01:00
Simone Basso
a58dff3050
refactor: nettests is now an internal package (#165)
I'm moving everything into internal packages since this ain't a library.

While there, remove typo that was causing a build breakage.
2020-11-13 17:14:26 +01:00
Simone Basso
fb2ca32004
refactor: config is now a private package (#164)
We are working on ooniprobe for Debian. Before starting to apply
changes to the codebase, I'd like to apply some refactoring steps
that I've been thinking about for quite some time.

The general concept here is that the purpose of this repository
changed since it was designed and now there is probe-engine which
is a library, therefore, this repo can be mostly private.
2020-11-13 16:58:14 +01:00
Sarath
73d6b550e5
Replace ooni with ooniprobe in example usage (#163) 2020-11-13 16:57:01 +01:00
Arturo Filastò
c0a95c037f
Add support for deleting all measurements (#158)
Co-authored-by: Simone Basso <bassosimone@gmail.com>
2020-11-13 07:43:00 +01:00
Simone Basso
f1f2350bfa
Release v3.0.7 (#152)
* Update go-bindata and regenerate binary data

* Pin to ooni/probe-engine 0.17.0 and update dependencies

* Set version to 3.0.7

* Readme.md: better release instructions
2020-09-30 10:54:58 +02:00
Simone Basso
4c65147009
WIP: Start preparing release v3.0.7 (#147)
* Use ooni/probe-engine 0.16.0
* Update all the other dependencies
* Use GitHub Actions rather than Travis CI
* Automatically build and test binaries on the target OS (for Windows, macOS, Linux on amd64)
* Make sure we correctly measure coverage
* Make sure we use `-race` when running tests
* Remove unnecessary scripts
* Make sure the README is up-to-date
* Write small script to update binary data and add GitHub Actions checks for it
* Notice that we needed to run ./updatebindata.sh and run it
* Self documenting instructions regarding cross compiling
* Set version number to v3.0.7-beta

Part of https://github.com/ooni/probe-engine/issues/748
2020-08-22 11:20:50 +02:00
Simone Basso
b4934b1619
Use ooni/probe-engine 0.12.0+patches (#133)
* nettests/groups.go: remove redundant struct names

* go.mod go.sum: update deps except probe-engine

* Update to ooni/probe-engine@e768161f91

The API has changed. Methods that used to change bits of the session have
been removed. Now the session is more immutable than before.

As such, we need to completely fill the config before using it.

* Set IncludeCountry to always true

Co-authored-by: Arturo Filastò <arturo@filasto.net>
2020-06-04 11:19:38 +02:00
Arturo Filastò
f2e62b7ad7 Always include the country code and drop include_probe_cc setting
Fixes: https://github.com/ooni/probe/issues/1183
2020-06-02 19:16:09 +02:00
Arturo Filastò
35016a183e Interrupt the nettestGroup loop early on termination
Fixes ooni/probe#1013
2020-02-20 12:24:24 +01:00
Simone Basso
040bee0ee6
Optionally treat EOF on stdin just like SIGTERM (#111)
* Optionally treat EOF on stdin just like SIGTERM

On Unix, Node.js allows us to gracefully kill a process. On Windows
this is more compex. You certainly cannot rely on the default `kill()`
function, which calls `TerminateProcess`.

There is a bunch of C/C++ extensions that in principle allow you to
attempt to gracefully shutdown a Windows process.

But, hey, here's a reality check. Node.js controls our stdin. Node.js
does IPC easy. Controlling uv_spawn flags and using the right not well maintained
C/C++ Node.js extension to kill a process is fragile.

So, treat EOF and any other error on stdin as equivalent to SIGTERM.

However, systemd.

The sane thing to do with systemd is `StandardInput=null`. With such
configuration, stdin immediately returns EOF.

Then, introduce the `OONI_STDIN_EOF_IMPLIES_SIGTERM` environment
variable. When it is `true`, this behaviour is enabled, e.g.:

```bash
export OONI_STDIN_EOF_IMPLIES_SIGTERM=true  # behaviour enabled
ooniprobe run
```

I want the default to be disabled because:

1. in the future we may find a better way to solve this problem and I
don't want the _default behaviour_ to change in such case

2. we know we need this knob for ooniprobe-desktop, and we will not
fail to provide it, so it won't suprise/damage us

3. a person trying to write a systemd unit for ooniprobe would be very
surprised to find out they need to disable this behaviour, if it was
enabled by default by this PR

Hence, I believe this design is consistent with designing for the
future and for trying to minimize surprises.

Also, why an environment variable and not a command line flag? Because:

1. we don't want such hypothetical flag to be available where it does not
make sense, e.g., for all subcommands but `run`

2. we don't want the ooni/probe-desktop app to write conditional
code because it needs to check the command we're using and then decide
whether to add such hypothetical flag

Also, why not enabling this only on Windows? Because again we don't
want the ooni/probe-desktop app to write conditional code.

To summarize: we want ooni/probe-desktop app to see the same behaviour
everywhere and we want others to be the least surprised.

Related to https://github.com/ooni/probe/issues/1005

* Update ooni.go
2020-02-13 14:53:06 +01:00
Arturo Filastò
20fb419126 Explicitly handle SIGINT 2020-02-07 15:33:37 +01:00
Arturo Filastò
cf21fd1fd8 Improve error handling 2020-02-05 18:28:10 +01:00
Arturo Filastò
b22f224ad3 Fix bug in measurement_file_path collision
We were writing to the same measurement_file_path for a given test
group, because we were using a different filename only in the case of a
many input test, but not in the case of many test_names inside of a
given test group.
2020-02-05 18:26:26 +01:00
Arturo Filastò
52332c0977 Changes based on feedback from @bassosimone 2020-01-29 18:48:12 +01:00
Arturo Filastò
4711a76c11 Handle the case when we try to access an old measurement 2020-01-29 10:43:08 +01:00
Arturo Filastò
e38d42d33a Update the actions tests 2020-01-28 12:08:09 +01:00
Arturo Filastò
e3d68457b3 Implement writing using the new single measurement pattern 2020-01-28 11:53:00 +01:00
Arturo Filastò
af46a495f4 Update bindata 2020-01-28 11:52:37 +01:00
Arturo Filastò
27d98a8660 Small cosmetic fix 2020-01-28 11:05:09 +01:00
Arturo Filastò
8dff1cc54a Use ~/.ooniprobe as the home directory (#101)
* Use ~/.ooniprobe as the home directory

Remove all probe-legacy related to code since there is no more conflict
between the two
Fixes: ooni/probe#972

* Update .gitignore

Co-authored-by: Simone Basso <bassosimone@gmail.com>
2020-01-27 15:19:32 +01:00
Arturo Filastò
24316728b9 Improve the output and extraction of psiphon metrics 2020-01-07 16:13:13 +02:00
Simone Basso
1e8b482c23
Allow to specify custom software name and version (#94)
In turn, this allows us to identify as ooniprobe-cli v3.0.0-rc.5.

Closes #41.
2019-12-29 14:07:57 +01:00
Simone Basso
955509e6f8 nettests: don't say ETA is infinite
1. only print time left if ETA is positive

2. skip ETA calculation with a single input

3. don't compute ETA for first entry[*]

[*] this is actually what avoids emitting infinite but the other
parts of this diff felt useful yak shaving as well.

Closes #91
2019-12-28 18:28:08 +01:00
Simone Basso
259ab41b15 Implement the circumvention nettest group
Only Psiphon for now. Closes #87 #77.
2019-12-28 17:48:07 +01:00
Arturo Filastò
7bbbab8774 Handle the SIGINT and SIGTERM signals to support stopping a test cleanly (#84) 2019-12-27 11:32:08 +01:00
Arturo Filastò
274e533b2e Fix import for groups 2019-12-02 18:05:02 +02:00
Arturo Filastò
58199a020e Refactoring to reduce package count
* Consolidate util and utils into the same package
* Move internal/onboard into internal/cli/onboard
* Move maybeOnboard into the onboard package
2019-12-02 15:15:50 +02:00
Arturo Filastò
bc1314ca61
Add support for calculating the estimate time remaining (#71) 2019-11-14 12:01:40 +01:00
Simone Basso
946289d6fe
Use more general ooni/probe-engine API (#67)
No functional change, just importing less stuff and meddling
much less with the internals of ooni/probe-engine.
2019-10-28 14:05:05 +01:00
Simone Basso
7cde93fca4
Make sure ooniprobe show <id> is WAI (#61)
1. the description of the command and the helper function are
clear hints that the command is intended to show a single JSON
measurement at a time (also the use case seems clear) [*]

2. the function used to read lines was failing for all my
measurements that take input. Since that was not the optimal
pattern anyway, use a better pattern to fix it.

3. some changes are automatically applied by my editor (VSCode
with the Go plugin) and I am fine with them.

4. while reading code, I also applied my preferred pattern
wrt whitespaces, i.e.: no whitespace inside functions, if a
function feels too long in this way, just break it.

Closes #57

[*] Even if we want to show many measurements at a time, which
does not seem needed, given the UI patterns, this functionality
won't be P0. What is P0 is to bless a new beta and give to
@sarathms binaries for all archs that support a basic `show`.
2019-10-03 11:18:07 +02:00
Simone Basso
f3865d2ec0
Upgrade to ooni/probe-engine@v0.1.1 (#60) 2019-10-03 09:43:25 +02:00
Arturo Filastò
f425d3f007 Implement the show command (#53) 2019-10-02 18:23:14 +02:00
Simone Basso
b9b555ba68 Integrate further with ooni/probe-engine: episode two (#46)
* utils/geoip.go: use github.com/ooni/probe-engine

Let's start using the engine by rewriting utils/geoip.go to
be just a thin wrapper around the engine functionality.

* Ready for review

* Checkpoint: the im tests are converted

Still have some doubts with respect to the variables that
are passed to MK via probe-engine. Will double check.

* fix(i/c/r/run.go): write the correct logic

* nettests: one more comment and also fix a format string

* Tweak previous

* progress

* Fix doofus

* better comment

* XXX => actionable comment

* Add glue to simplify test keys management

Making the concept of measurement more abstract in the engine is
not feasible because, when submitting a measurement, we need to
modify it to update the report ID and the measurement ID. Therefore,
returning a serialized measurement is not a good idea. We will
keep using a model.Measurement in the engine.

Changing model.Measurement.TestKeys's type from a `interface{}`
pointing to a well defined data structure to `map[string]interface{}`
is a regression because means that we are moving from code that
has a clear and defined structure to code that is more complicated
to parse and validate. Since we're already suffering havily from
the lack of a good schema, I'm not going to make the situation
worst by worsening the engine. At least for ndt7 and psiphon, we
now have a good schema and I don't want to lose that.

However, the current code in this repository is expecting the
test keys to be a `map[string]interface{}`. This choice was
dictated by the fact that we receive a JSON from Measurement Kit
and by the fact that there's not a clear schema.

To solve this tension, in this commit I am going to write glue
adapter code that makes sure that the TestKeys of a Measurement
are converted to `map[string]interface{}`. This will be done
using a type cast where possible and JSON serialization and parsing
otherwise. In a perfect world, glue is not a good idea, but in a
real world it may actually be useful.

When all tests in the engine will have a clear Go data structure,
we'll then remove the glue and just cast to the proper data
structure from `interface{}` where required.

* nettests/performance: use probe-engine

* go.{mod,sum}: upgrade to latest probe-engine

* nettests/middlebox: use ooni/probe-engine

* Update to the latest probe-engine

* web_connectivity: rewrite to use probe-engine

* Cosmetic change suggested by @hellais

* nettests/nettests.go: remove unused code

* nettests/nettests.go: fix progress

* nettests/nettests.go: remove go-measurement-kit code

* We don't depend on go-measurement-kit anymore

* Improve non-verbose output where possible

See also: https://github.com/measurement-kit/measurement-kit/issues/1856

* Make web_connectivity output pleasant

* Update to the latest probe-engine

* nettests/nettests.go: honour sharing settings

* Update to the latest probe-engine

* Use log.WithFields for probe-engine

* Update go.mod go.sum

* Revert "Update go.mod go.sum"

This reverts commit 5ecd38d8236f4a4e9b77ddb8e8a0d1e3cdd4b818.

* Revert "Revert "Update go.mod go.sum""

This reverts commit 6114b31eca98826112032776bd0feff02d763ecd.

* Upgrade ooni/probe-engine

* Unset GOPATH before running go build commands

* Dockefile: fix linux build by using latest

* Update to the latest ooni/probe-engine

```
go get -u github.com/ooni/probe-engine
go mod tidy
```

* Repair build
2019-08-15 18:08:43 +02:00
Simone Basso
df629237be
Use ooni/probe-engine: episode 1 (#42) 2019-05-23 16:38:46 +02:00
Arturo Filastò
9ad7c6507a Remove shutil tests 2019-05-15 18:13:34 +02:00
Arturo Filastò
826822df31 Copy and delete instead of rename
Fixes: https://github.com/ooni/probe-cli/issues/21
2019-05-15 18:06:09 +02:00
Arturo Filastò
dbed661357 Vendor shutil from: bcacb06fec 2019-05-15 18:05:51 +02:00
Simone Basso
9992690f8f Use MK v0.10.x, zap legacy GeoIP, build also on Linux (#29)
* Gopkg.lock: use MK v0.10.3

* ooni: stop using legacy GeoIP database files

* Some yak shaving of Makefile

1. remove now broken commands to download deps

2. also define the CXX cross compiler

* chore(dep): migrate from dep to go 1.11+ modules

See https://blog.callr.tech/migrating-from-dep-to-go-1.11-modules/

I need this to simplify my life in building for Travis.

* Introduce build.sh and repair build

In going forward, I believe we don't actually need a Makefile but I
didn't want to make such a radical change now.

* Another strategy wrt gopath

* travis: run regress tests on macOS

Closes #30
2019-05-15 15:48:06 +03:00
Arturo Filastò
34556dcbf1 Add support for running all tests with ooni run 2018-09-27 18:38:37 +02:00
Arturo Filastò
8916ff8398 Add note about the testKeys extraction function 2018-09-27 11:42:55 +02:00
Arturo Filastò
6735c8d617 Strip the trailing slash from the bouncer url 2018-09-26 15:35:17 +02:00
Arturo Filastò
2b01dfaa17 Close the DB before deleting ooni_home 2018-09-26 15:09:59 +02:00
Arturo Filastò
a60f376846 Adjust the progress bars depending on the test type 2018-09-24 15:57:28 +02:00
Arturo Filastò
4fc745172d Update bindata 2018-09-21 18:54:56 +02:00
Arturo Filastò
0d21186492 Add support for custom collectors and bouncers 2018-09-21 18:54:44 +02:00
Arturo Filastò
8402446e47 Use Stdout in CLI logging 2018-09-18 09:55:23 +02:00
Arturo Filastò
47a2fbb88c Add rm command to delete results 2018-09-18 09:54:27 +02:00