Commit Graph

749 Commits

Author SHA1 Message Date
Simone Basso
1c057d322d
cleanup: merge legacy errorsx in netxlite and hide classifiers (#655)
This diff implements the first two cleanups defined at https://github.com/ooni/probe/issues/1956:

> - [ ] observe that `netxlite` and `netx` differ in error wrapping only in the way in which we set `ErrWrapper.Operation`. Observe that the code using `netxlite` does not care about such a field. Therefore, we can modify `netxlite` to set such a field using the code of `netx` and we can remove `netx` specific code for errors (which currently lives inside of the `./internal/engine/legacy/errorsx` package
>
> - [ ] after we've done the previous cleanup, we can make all the classifiers code private, since there's no code outside `netxlite` that needs them

A subsequent diff will address the remaining cleanup.

While there, notice that there are failing, unrelated obfs4 tests, so disable them in short mode. (I am confident these tests are unrelated because they fail for me when running test locally from the `master` branch.)
2022-01-07 17:31:21 +01:00
Simone Basso
99ec7ffca9
fix: ensure experiments return nil when we want to submit (#654)
Since https://github.com/ooni/probe-cli/pull/527, if an experiment
returns an error, the corresponding measurement is not submitted since
the semantics of returning an error is that something fundamental
went wrong (e.g., we could not parse the input URL).

This diff ensures that all experiments only return and error when
something fundamental was wrong and return nil otherwise.

Reference issue: https://github.com/ooni/probe/issues/1808.
2022-01-07 13:17:20 +01:00
Simone Basso
60a3c372f5
cleanup: remove the original netx implementation (#653)
This commit completely removes the original netx implementation,
which was only used by `tor`, since this has changed in
https://github.com/ooni/probe-cli/pull/652.

The original netx implementation was my first attempt at performing
network measurements using Go. It started its life inside of the
https://github.com/ooni/netx repository. It was later merged into
the https://github.com/ooni/probe-engine repository. It finally
ended up into this repository when we merged probe-engine with it.

The main issue with the original implementation is that it was
a bit too complex and used channels where they were probably not
necessary. Because of that, later I introduced a second netx
implementation, which currently lives in ./internal/engine/netx.

The current netx implementation, the third one, lives in the
./internal/netxlite package. We are currently working to replace
the second implementation with the third one, but this is happening
at a slow pace. Also, the second implementation does not have big
maintenance concerns but it's just a bit too bureaucratic to use
since it involves creating lots of `Config` structures.

The reference issue is probably https://github.com/ooni/probe/issues/1688,
since this diff has been enabled by rewriting Tor to use `measurex`
(a library living on top of `netxlite`).
2022-01-05 19:00:50 +01:00
Simone Basso
dfa5e708fe
refactor(tor): rewrite using measurex (#652)
This diff rewrites the tor experiment to use measurex "easy" API.

To this end, we need to introduce an "easy" measurex API, which basically
performs easy measurements returning two pieces of data:

1. the resulting measurement, which is already using the OONI
archival data format and is always non-nil

2. a failure (i.e., the pointer to an error string), which
is nil on success and points to a string on failure

With this change, we should now be able to completely dispose of
the original netx API, which was only used by tor.

Reference issue: https://github.com/ooni/probe/issues/1688.
2022-01-05 18:41:11 +01:00
Simone Basso
f0181c432f
refactor: move httpx into the internal package (#646)
This concludes the TODO list at https://github.com/ooni/probe/issues/1951
2022-01-05 17:17:20 +01:00
Simone Basso
dba861d262
feat(httpx): implement optional body logging also on http error (#651)
1. we want optionally to log the body (we don't want to log the body
when we're fetching psiphon secrets or tor targets)

2. we want body logging to _also_ happen on error since this is quite
useful to debug possible errors when accessing the API

This diff adds the above functionality, which were previously
described in https://github.com/ooni/probe/issues/1951.

This diff also adds comprehensive testing.
2022-01-05 16:26:51 +01:00
Simone Basso
ee0aa18616
refactor(httpx): use mocks to implement tests (#650)
* refactor(httpx): use mocks to implement tests

While there, make sure no test depends on external services by
replacing such tests with httptest.

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

* fix(httpx): ensure we honour the context
2022-01-05 16:13:42 +01:00
Simone Basso
93f084598e
feat(httpx): improve testing using the fakefiller (#649)
This diff extracts the fakefiller inside of internal/ooapi (a
currently unused package) into its own package.

The fakefiller knows how to fill many fields that are typically
shared as data structures across processes.

It is not perfect in that it cannot fill logger or http client
fields, but still helps with better filling and testing.

So, here we're using the fakefiller to improve testing of httpx
and, nicely enough, we've already catched a bug in the way in
which APIClientTemplate.Build misses to forward Authorization from
the original template. Yay!

Work part of https://github.com/ooni/probe/issues/1951
2022-01-05 14:49:31 +01:00
Simone Basso
eed51978ca
refactor(httpx): hide the real APIClient (#648)
As mentioned in https://github.com/ooni/probe/issues/1951, one of
the main issues I did see with httpx.APIClient is that in some cases
it's used in a very fragile way by probeservices.Client.

This happens in psiphon.go and tor.go, where we create a copy of
the APIClient and then modify it's Authorization field.

If we ever refactor probeservices.Client to take a pointer to
httpx.Client, we are now mutating the httpx.Client.

Of course, we don't want that to happen.

This diff attempts to address such a problem as follows:

1. we create a new APIClientTemplate type that holds the same
fields of an APIClient and allows to build an APIClient

2. we modify every user of APIClient to use APIClientTemplate

3. when we need an APIClient, we build it from the corresponding
template and, when we need to use a specific Authorization, we
use a build factory that sets APIClient.Authorization

4. we hide APIClient by renaming it apiClient and by defining
an interface called APIClient that allows to use it

So, now the codebase always uses the opaque APIClient interface to
issue API calls and always uses the APIClientTemplate to build an
opaque APIClient.

Boom! We have separated construction from usage and we are not
mutating in weird ways the APIClient anymore.
2022-01-05 14:15:42 +01:00
Simone Basso
7b7df2c6af
refactor(httpx): improve and modernize (1/n) (#647)
This PR starts to implement the refactoring described at https://github.com/ooni/probe/issues/1951. I originally wrote more patches than the ones in this PR, but overall they were not readable. Since I want to squash and merge, here's a reasonable subset of the original patches that will still be readable and understandable in the future.
2022-01-05 12:48:32 +01:00
Simone Basso
0a630c1716
refactor(measurex): allow to configure timeouts and max-snapshot-size (#645)
This diff lightly refactors the code in measurex to allow a user
to configure all possible timeouts and the max-snapshot-size.

There is currently a little bit of tension between setting timeouts
inside of measurex and the watchdog timeouts inside of netxlite.

This tension has been documented.

Let us repeat the issue also in this commit message. If you are
using a masurex.Measurer configured with very large timeouts and
the underlying netxlite implementation uses shorter whatchdog
timeouts, then you are going to see shorter than expected timeouts.

Ideally, we would like to have just a single timeout but there is
no way to ask the context "hey, can you tell me if you already have
a configured timeout?".

It may be that the right solution is to modify netxlite to have
some sort of root/library object with this configuration.

If that's the case, then a Measurer could be refactored as follows:

- create the underlying netxlite "library"

- initialize the timeouts desired by the Measurer

- create a Dialer, of whatever is needed

- use it

Now this is not possible because netxlite timeouts are internal
static settings rather than attributes of a structure.

Anyway, for now I'm happy with this just being documented.

(I suspect this issue will need to be addresses when we'll write
unit tests for measurex; at that time a proper solution should
come out naturally due to the unit tests constraints.)

I'm working on this refactoring, BTW, to facilitate rewriting `tor`
using measurex (see https://github.com/ooni/probe/issues/1688).
2022-01-04 13:20:48 +01:00
Simone Basso
8afb3ee0d5
cleanup(ptx): remove redundant dialer definition (#644)
We can just use model.SimpleDialer here.

See https://github.com/ooni/probe/issues/1885.
2022-01-04 12:46:55 +01:00
Simone Basso
43161a8138
cleanup: remove redundant HTTPClient definition (#643)
This counts as a follow-up cleanup as part of doing
https://github.com/ooni/probe/issues/1885.
2022-01-03 16:47:54 +01:00
Simone Basso
273b70bacc
refactor: interfaces and data types into the model package (#642)
## Checklist

- [x] I have read the [contribution guidelines](https://github.com/ooni/probe-cli/blob/master/CONTRIBUTING.md)
- [x] reference issue for this pull request: https://github.com/ooni/probe/issues/1885
- [x] related ooni/spec pull request: N/A

Location of the issue tracker: https://github.com/ooni/probe

## Description

This PR contains a set of changes to move important interfaces and data types into the `./internal/model` package.

The criteria for including an interface or data type in here is roughly that the type should be important and used by several packages. We are especially interested to move more interfaces here to increase modularity.

An additional side effect is that, by reading this package, one should be able to understand more quickly how different parts of the codebase interact with each other.

This is what I want to move in `internal/model`:

- [x] most important interfaces from `internal/netxlite`
- [x] everything that was previously part of `internal/engine/model`
- [x] mocks from `internal/netxlite/mocks` should also be moved in here as a subpackage
2022-01-03 13:53:23 +01:00
Arturo Filastò
41cf4a8671
feature: use go-libtor on mobile, OONI_TOR_BINARY env on desktop (#614)
This branch adds support for running:

1. `go-libtor` on mobile.

2. the tor provided by the desktop app via the `OONI_TOR_BINARY` environment variable.

See https://github.com/ooni/ooni.org/issues/761.

Co-authored-by: Simone Basso <bassosimone@gmail.com>
2021-12-15 14:16:22 +01:00
Simone Basso
6cb8e3d785
chore: set master's version to 3.14.0-alpha (#638)
As mentioned in https://github.com/ooni/probe/issues/1845#issuecomment-986540868,
I did a mistake and published an `-alpha` debian package, so I need to
bump master's version to 3.14 and create a 3.13 release train.

やれやれだぜ
2021-12-06 17:54:58 +01:00
Simone Basso
611fed05f4
[forwardport] release 3.11: update all the dependencies (#636) (#637)
* [forwardport] release 3.11: update all the dependencies (#636)

This diff forward ports e291e436b3c332300f5567796f9c48bb9bc1e652.

* chore: use go1.17.4 everywhere

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

* chore: update to the latest ooni/oohttp

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

* chore: update the dependencies

Note: I did an update and not an upgrade (i.e., I didn't check
whether we have next-major-versions of dependencies).

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

* chore: update the user-agent we use

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

* chore: update ooni/oohttp and ooni/probe-assets

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

* chore: run go generate again

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

* fix(jafar): skip currently broken test

Created issue for it here: https://github.com/ooni/probe/issues/1913
2021-12-06 17:46:13 +01:00
Simone Basso
dc9fbe9c64
fix(oonimkall): run tests with InputOrStaticDefault policy (#634)
Previous work to make https://github.com/ooni/probe/issues/1814
possible has broken running stunreachability on mobile.

This diff repairs the blunder and allows to run any experiment
using InputOrStaticDefault with oonimkall.

Diff extracted from https://github.com/ooni/probe-cli/pull/539.
2021-12-03 17:43:09 +01:00
Simone Basso
2044b78a5a
refactor: introduce and use InputOrStaticDefault (#632)
This commit introduces a new `InputLoader` policy by which, if no
input is provided, we use a static default input list.

We also modify the code to use this policy for dnscheck and
stunreachability, with proper input.

We also modify `miniooni` to pass the new `ExperimentName` field to
the `InputLoader` to indicate which default input list to use.

This diff is part of a set of diffs aiming at fixing
https://github.com/ooni/probe/issues/1814 and has been
extracted from https://github.com/ooni/probe-cli/pull/539.

What remains to be done, after this diff has landed is to ensure
things also work for ooniprobe and oonimkall.
2021-12-03 15:30:56 +01:00
Simone Basso
13414e0abc
refactor: create common package for holding STUN input (#631)
We want stunreachability to use the same STUN servers used by
snowflake, so let's start by making a common package holding the
servers. Let's also use this new package in Snowflake.

We're currently not using this package in stunreachability, but
I am going to apply this as a subsequent diff.

Reference issue: https://github.com/ooni/probe/issues/1814. This
issue is a bit complex to address in a single PR, so we are going
to proceed incremntally.

This diff was extracted from https://github.com/ooni/probe-cli/pull/539.
2021-12-03 14:45:25 +01:00
Simone Basso
cba72d1ca3
refactor(stunreachability): input required and must be an URL (#630)
Here we're refactoring stunreachability to not provide internally a
default input and to take in input an URL rather than a string.

The related ooni/spec change is https://github.com/ooni/spec/pull/227.

This diff has been extracted from https://github.com/ooni/probe-cli/pull/539.

Because the original diff was large, I'm splitting it in a set of
more easily manageable diffs.

The reference issue is https://github.com/ooni/probe/issues/1814, which
is complex enough to require us to proceed incrementally.

This diff WILL need to be backported to release/3.11.
2021-12-03 14:27:04 +01:00
Simone Basso
9cdca4137d
forwardport: pull the patches mentioned in ooni/probe#1908 (#629)
* [forwardport] fix(oonimkall): make logger used by tasks unit testable (#623)

This diff forward ports e4b04642c51e7461728b25941624e1b97ef0ec83.

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

* [forwardport] feat(oonimkall): improve taskEmitter testability (#624)

This diff forward ports 3e0f01a389c1f4cdd7878ec151aff91870a0bdff.

1. rename eventemitter{,_test}.go => taskemitter{,_test}.go because
the new name is more proper after we merged the internal/task package
inside of the oonimkall package;

2. rename runner.go's `run` function to `runTask`;

3. modify `runTask` to use the new `taskEmitterUsingChan` abstraction
on which we will spend more works in a later point of this list;

4. introduce `runTaskWithEmitter` factory that is called by `runTask`
and allows us to more easily write unit tests;

5. acknowledge that `runner` was not using its `out` field;

6. use the new `taskEmitterWrapper` in `newRunner`;

7. acknowledge that `runnerCallbacks` could use a generic
`taskEmitter` as field type rather than a specific type;

8. rewrite tests to use `runTaskWithEmitter` which leads to
simpler code that does not require a goroutine;

9. acknowledge that the code has been ignoring the `DisabledEvents`
settings for quite some time, so stop supporting it;

10. refactor the `taskEmitter` implementation to be like:

    1. we still have the `taskEmitter` interface;

    2. `taskEmitterUsingChan` wraps the channel and allows for
    emitting events using the channel;

    3. `taskEmitterUsingChan` owns an `eof` channel that is
    closed by `Close` (which is idempotent) and signals we
    should be stop emitting;

    4. make sure `runTask` creates a `taskEmitterUsingChan`
    and calls its `Close` method when done;

    5. completely remove the code for disabling events
    since the code was actually ignoring the stting;

    6. add a `taskEmitterWrapper` that adds common functions
    for emitting events to _any_ `taskWrapper`;

    7. write unit tests for `taskEmitterUsingChan` and
    for `taskEmitterWrapper`;

11. acknowledge that the abstraction we need for testing is
actually a thread-safe thing that collects events into a
vector containing events and refactor all tests accordingly.

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

* [forwardport] refactor(oonimkall): make the runner unit-testable (#625)

This diff forward ports 9423947faf6980d92d2fe67efe3829e8fef76586.

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

* [forwardport] feat(oonimkall): write unit tests for the runner component (#626)

This diff forward ports 35dd0e3788b8fa99c541452bbb5e0ae4871239e1.

Forward porting note: compared to 35dd0e3788b8fa99c541452bbb5e0ae4871239e1,
the diff I'm committing here is slightly different. In `master` we do not
have the case where a measurement fails and a measurement is returned, thus
I needed to adapt the test to become like this:

```diff
diff --git a/pkg/oonimkall/runner_internal_test.go b/pkg/oonimkall/runner_internal_test.go
index 334b574..84c7436 100644
--- a/pkg/oonimkall/runner_internal_test.go
+++ b/pkg/oonimkall/runner_internal_test.go
@@ -568,15 +568,6 @@ func TestTaskRunnerRun(t *testing.T) {
                }, {
                        Key:   failureMeasurement,
                        Count: 1,
-               }, {
-                       Key:   measurement,
-                       Count: 1,
-               }, {
-                       Key:   statusMeasurementSubmission,
-                       Count: 1,
-               }, {
-                       Key:   statusMeasurementDone,
-                       Count: 1,
                }, {
                        Key:   statusEnd,
                        Count: 1,
```

I still need to write more assertions for each emitted event
but the code we've here is already a great starting point.

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

* [forwardport] refactor(oonimkall): merge files, use proper names, zap unneeded integration tests (#627)

This diff forward ports f894427d24edc9a03fc78306d0093e7b51c46c25.

Forward porting note: this diff is slightly different from the original
mentioned above because it carries forward changes mentioned in the
previous diff caused by a different way of handling a failed measurement
in the master branch compared to the release/3.11 branch.

Move everything that looked like "task's model" inside of the
taskmodel.go file, for consistency.

Make sure it's clear some variables are event types.

Rename the concrete `runner` as `runnerForTask`.

Also, remove now-unnecessary (and flaky!) integration tests
for the `runnerForTask` type.

While there, notice there were wrong URLs that were generated
during the probe-engine => probe-cli move and fix them.

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

* [forwardport] refactor(oonimkall): we can simplify StartTask tests (#628)

This diff forward ports dcf2986c2032d8185d58d24130a7f2c2d61ef2fb.

* refactor(oonimkall): we can simplify StartTask tests

We have enough checks for runnerForTask. So we do not need to
duplicate them when checking for StartTask.

While there, refactor how we start tasks to remove the need for
extra runner functions.

This is the objective I wanted to achieve for oonimkall:

1. less duplicate tests, and

2. more unit tests (which are less flaky)

At this point, we're basically done (pending forwardporting to
master) with https://github.com/ooni/probe/issues/1903.

* fix(oonimkall): TestStartTaskGood shouldn't cancel the test

This creates a race condition where the test may fail if we cannot
complete the whole "Example" test in less than one second.

This should explain the build failures I've seen so far and why
I didn't see those failures when running locally.
2021-12-02 12:47:07 +01:00
Simone Basso
ece6f3d48d
fix(websteps, webconnectivity): send the correct user agent (#616)
* [forwardport] fix(webconnectivity): send specific user agent (#615)

This forward ports b8c530388e66b2cc86abad26d077202782e4a823 to `master`.

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

* fix(websteps): send the correct user agent

Also related to https://github.com/ooni/probe/issues/1902: let's just
ensure that also websteps behaves in the correct way.
2021-11-26 19:20:24 +01:00
Simone Basso
56440bec43
chore: set dev version to v3.12.0-alpha.4 (#612) 2021-11-23 16:16:30 +01:00
Simone Basso
fdbf871103
[forwardport] ci/cd: publish binaries onto a release when we create a tag (#609) (#611)
This diff forwardports 856e436e20d511a4f0d618546da7921fa9f8c5f6 to the master branch

Original commit message:

- - -

This pull request changes `mk` and github workflows to build and publish binaries on tag. We also update the documentation to explain this new branching model. Basically, we have release branches where we produce binary packages and we add extra code, on tag, to publish such packages inside a release.

We discussed removing most secrets from builds in this repository and having a different tool/repository that takes in input also secrets for doing follow-up actions after publishing. As a consequence, this pull request also removes all pieces of code that require secrets. The next step is to reinstate this code in this new repository/tool.

The existing code in `mk` also implemented caching. This feature was useful when doing local builds because it reduced the time required to obtain binary releases. With builds running as part of GitHub actions, we don't need caching because we spawn parallel machines to build binaries. Therefore, let us also remove caching, which makes the code simpler. (Caching in itself is hard and in https://github.com/ooni/probe/issues/1875 I noted that, for example, caching of the `ooni/go` repository was leading to some unwanted behaviour when changing the branch. Without caching, this behaviour is gone and we always generally use fresh information to produce builds.) Of course, this means that local builds are now slower, but I do not think this is a problem _because_ we want to use GitHub actions for building in the common case.

Reference issues: https://github.com/ooni/probe/issues/1879 and https://github.com/ooni/probe/issues/1875.

The final aspect to mention to conclude this description is an implementation one:

```
          gh release create -p $tag --target $GITHUB_SHA || true
```

The code above uses `|| true` because there could already be a release. So, basically, it means that, if a release does not already exist, then we're going to create one. Otherwise, it does not matter because there's already a release.
2021-11-23 15:56:25 +01:00
Simone Basso
5b9f701317
fix(measurex): handle case where TH is nil (#610)
This case happens when the TH fails.

See https://github.com/ooni/probe/issues/1895.
2021-11-22 20:16:38 +01:00
Simone Basso
264e30f016
[forwardport] fix(mk): do nothing if we already have psiphon config (#605) (#606)
This diff forward ports ea44e99451f345474738b9010ff791759a1f1367.

Original commit message:

- - -

This change allows for producing cloud builds using the psiphon
config files. We will add those files as build secrets. Only people
in the organization and collaborators with at least "write"
access could trigger builds containing such secrets.

Before this change, `./mk` unconditionally attempted to clone
github.com/ooni/probe-private. Now, it only checks whether
we need to clone _if_ files are not already there.

This allows us to use GitHub actions and secrets to copy the
files in there _without_ needing to clone a private repo.

Cloning a private repo would require us to include as repository
secret an access token with full `repo` scope, which is a very
broad scope. Instead, by using secrets to include psiphon config,
we are narrowing down the secrets required to make a release build.

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

This diff WILL require forward porting to the master branch.
2021-11-19 12:40:10 +01:00
Simone Basso
0cb535b022
[forwardport] fix(signal): use the correct string to score a measurement (#602) (#603)
This diff forwardports 3b1cc1b6afbc29fbc9ff8221d2cd84f34032df60.

Original commit message:

- - -

See https://github.com/ooni/probe/issues/1858#issuecomment-970322363

This diff will need forward porting to master.
2021-11-16 15:57:16 +01:00
Simone Basso
56d179d88a
chore: set version to v3.12.0-alpha.3 (#601) 2021-11-16 13:17:30 +01:00
Simone Basso
50576daec8
[forwardport] fix(ios): make sure we can build an iOS release (#598) (#599)
This diff forward ports f47b0c6c16e0cd417e3591358eb85b45962f307d to master.

Original commit message:

- - -

1. we now need to name the framework `.xcframework` otherwise
gomobile refuses to build a new framework for us ¯\_(ツ)_/¯

2. remove duplicate errno definition for iOS (iOS and darwin
are considered the same, therefore we don't need iOS defs)

Reference issue for this PR: https://github.com/ooni/probe/issues/1876

This diff WILL need to be forwardported to master.
2021-11-15 14:24:20 +01:00
Simone Basso
c527ca1f61
fix(psiphon): increase the maximum runtime to 300s (#596)
See: https://github.com/ooni/probe/issues/1856.

This diff will need to be backported to release/3.11.
2021-11-15 12:43:19 +01:00
Simone Basso
5a481b395a
fix(geolocate): use powerdns.org whoami service (#592)
This diff needs to be backported to the release/3.11 branch.

Reference issue https://github.com/ooni/probe/issues/1865.
2021-11-12 14:53:15 +01:00
Simone Basso
0a322ebab0
[forwardport] fix: avoid http3 for dns.google and www.google.com (#593) (#594)
This commit forward ports dedd84fa7ecb09f718f6b1a9c83999cb37b34dfa.

Original commit message:

- - -

This diff changes code the release/3.11 branch to ensure we're not using dns.google and www.google.com over HTTP3. As documented in https://github.com/ooni/probe/issues/1873, since this morning (approx) these services do not support HTTP3 anymore. (I didn't bother with checking whether this issue affects _other_ Google services; I just limited my analysis to the services that we were using as part of testing.)

This patch WILL require forward porting to the master branch.
2021-11-12 14:43:28 +01:00
Simone Basso
0d65438ea1
[forwardport] fix(netxlite): remove android-specific errno (#586) (#587)
This commit forward ports 74947dbbd12266c12a38fad51a70fc78a21720fd from
the `release/3.11` branch to `master`. Here's the original commit message:

- - -

Android is also Linux. The Android build fails because both
errno_linux.go and errno_android.go are compiled.

There's no difference between the files except into a comment
that mentions "linux" or "android".

Therefore, it's safe to remove the android-specific file
and just keep and use the linux-specific one.

Part of https://github.com/ooni/probe/issues/1863, where we're
forward porting ooni/go patches to go1.17.

I'm still trying to figure out whether I can build oonimkall
using the forward ported patches and this error prevents me
from building, because the build fails.

"やれやれだぜ"

Note that this patch WILL need to be forward ported to master.

This bug was previosuly reported to me by @hellais.

Because I did run `go generate ./internal/netxlite/...` we also
get for free updated certificates, which is OK.
2021-11-10 13:00:41 +01:00
Simone Basso
6a935d5407
fix(netxlite): ensure HTTP errors are always wrapped (#584)
1. introduce implementations of HTTPTransport and HTTPClient
that apply an error wrapping policy using the constructor
for a generic top-level error wrapper

2. make sure we use the implementations in point 1 when we
are constructing HTTPTransport and HTTPClient

3. make sure we apply error wrapping using the constructor for
a generic top-level error wrapper when reading bodies

4. acknowledge that error wrapping would be broken if we do
not return the same classification _and_ operation when we wrap
an already wrapped error, so fix the to code to do that

5. acknowledge that the classifiers already deal with preserving
the error string and explain why this is a quirk and why we
cannot remove it right now and what needs to happen to safely
remove this quirk from the codebase

Closes https://github.com/ooni/probe/issues/1860
2021-11-06 17:49:58 +01:00
Simone Basso
be89878dd4
doc(tutorial): explain the big picture (#582)
Each tutorial provides you a piece of knowledge. Add some text in
the main readme file explaining the big picture to the reader.

Closes https://github.com/ooni/probe/issues/1819
2021-11-05 14:51:14 +01:00
Simone Basso
ba7b981fcb
fix(measurex): allow API user to choose parallelism (#581)
Closes https://github.com/ooni/probe/issues/1818
2021-11-05 14:37:03 +01:00
Simone Basso
3b27780836
fix(webconnectivity): ignore any status code <= 0 (#579)
This diff changes the algorithm used by webconnectivity's
httpanalysis.go to ignore any status code <= 0 rather
than just ignoring the == 0 case.

Make sure we add test cases for when the control's status
code is negative rather than being zero.

While there, simplify code where boolean checks could be
more compact according to staticcheck.

Closes https://github.com/ooni/probe/issues/1825
2021-11-05 13:51:22 +01:00
Simone Basso
fab7909281
chore: version is now 3.12.0-alpha.2 (#576) 2021-11-05 11:54:19 +01:00
Simone Basso
1f348803dc
fix(websteps): use a single Do53 resolver (#575)
Closes https://github.com/ooni/probe/issues/1807

While there, bump the experiment version number, because we have
applied changes since the last alpha release.
2021-11-05 11:40:58 +01:00
Simone Basso
dad8db4a36
fix(httpheader): use same Accept-Language as Brave (#574)
Closes https://github.com/ooni/probe/issues/1792
2021-11-05 11:31:10 +01:00
Simone Basso
60cfa68b5a
fix(measurex): avoid data race with HTTP request headers (#573)
Closes https://github.com/ooni/probe/issues/1859
2021-11-05 11:11:43 +01:00
Simone Basso
aa27bbe33f
fix(measurex): use same keys of the OONI data format (#572)
This change should simplify the pipeline's job.

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

I previously dismissed this possibility, but now it seems clear it
is simpler to have a very tabular data format internally and to
convert such a format to OONI's data format when serializing.

The OONI data format is what the pipeline expects, but processing
is easier with a more linear/tabular format.
2021-11-05 10:46:45 +01:00
Simone Basso
6f90d29bfa
feat(miniooni): add the --censor flag (#571)
This flag is similar to the previous --self-censor-spec and tells
miniooni what censorship to implement for itself.

This concludes the design at https://github.com/ooni/probe/issues/1803#issuecomment-957323297
2021-11-03 14:23:47 +01:00
Simone Basso
100cc559a2
Revert "feat(filtering): implement the divert policy (#569)" (#570)
This reverts commit 851b9913fa because
it seems it's not enough to allow us to see certificate errors with
quic, plus it's complex code. So, we'd rather develop a better approach,
and perhaps a simpler one, that works with QUIC as well.
2021-11-03 14:01:32 +01:00
Simone Basso
851b9913fa
feat(filtering): implement the divert policy (#569)
This is the policy we need to provoke certificate errors. We'll divert
from, say, `8.8.8.8:443/udp` to, say, `1.1.1.1:443/udp`.

We'll do something similar for `443/tcp`.

This will cause certificate validation errors.

With this change, we have now implemented the simple design described
by https://github.com/ooni/probe/issues/1803#issuecomment-957323297.
2021-11-03 00:29:14 +01:00
Simone Basso
675e3a5ba5
feat(filtering): introduce DNS cache (#568)
When we're testing multiple endpoints, it's quite important to control
the order with which they are returned to the code.

This feature is especially relevant to Web Connectivity, which will
check the endpoints to connect to in order.

Therefore, we need to force deterministic results to ensure that we can
have deterministic tests when doing Web Connectivity QA.

This diff gives us the guarantee that we can have determinism.

Part of https://github.com/ooni/probe/issues/1803#issuecomment-957323297.
2021-11-02 23:35:09 +01:00
Simone Basso
11ccd16a0c
feat(filtering): add transparent proxy with censorship policies (#566)
This PR implements the core concept described at
https://github.com/ooni/probe/issues/1803#issuecomment-957323297
2021-11-02 21:52:32 +01:00
Simone Basso
560b1a9a97
fix(filtering): avoid the if err == nil pattern (#567)
1. in normal code is better to always do if err != nil so that
the ifs only contain error code (this is ~coding policy)

2. in tests we want to ensure we narrow down the error to the
real error that happened, to have greater confidence

Written while working on https://github.com/ooni/probe/issues/1803#issuecomment-957323297
2021-11-02 19:48:10 +01:00
Simone Basso
374577f5a8
feat(filtering): implement HTTP filtering proxy (#565)
Needed to finish the design at https://github.com/ooni/probe/issues/1803#issuecomment-957323297
2021-11-02 14:13:54 +01:00
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