ooni-probe-cli/internal
Simone Basso 39cb5959c9
fix(datafmt): sync measurexlite and v0.5 with previous code (#942)
* fix(model/archival.go): more optional keys

Basically, `t0` and `transaction_id` should be optional. Version 0.4.x
of web_connectivity should not include them, version 0.5.x should.

There is a technical reason why v0.4.x should not include them. The code
it is based on, tracex, does not record these two fields.

Whereas, v0.5.x, uses measurexlite, which records these two fields.

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

* fix(webconnectivity@v0.5): add more fields

This diff adds the following fields to webconnectivity@v0.5:

1. agent, always set to "redirect" (legacy field);

2. client_resolver, properly initialized w/ the resolver's IPv4 address;

3. retries, legacy field always set to null;

4. socksproxy, legacy field always set to null.

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

* fix(webconnectivity@v0.5): register extensions

The general idea behind this field is that we would be able
in the future to tweak the data model for some fields, by declaring
we're using a later version, so it seems useful to add it.

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

* fix(measurexlite): use tcp or quic for tls handshake network

This diff fixes a bug where measurexlite was using "tls" as the
protocol for the TLS handshake when using TCP.

While this choice _could_ make sense, the rest of the code we have
written so far uses "tcp" instead.

Using "tcp" makes more sense because it allows you to search for
the same endpoint across different events by checking for the same
network and for the same endpoint rather than special casing TLS
handshakes for using "tls" when the endpoint is "tcp".

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

* chore: run alltests.yml for "alltestsbuild" branches

Part of https://github.com/ooni/probe/issues/2238
2022-09-08 10:02:47 +02:00
..
atomicx doc: cleanup and improve for recently moved pkgs (#354) 2021-06-04 11:39:00 +02:00
bytecounter refactor(netx): move construction logic outside package (#798) 2022-06-05 21:22:27 +02:00
cmd feat(miniooni): optionally log using emojis (#932) 2022-09-05 10:06:44 +02:00
engine fix(probeservices): use api.ooni.io (#926) 2022-09-02 16:48:14 +02:00
experiment/webconnectivity fix(datafmt): sync measurexlite and v0.5 with previous code (#942) 2022-09-08 10:02:47 +02:00
fsx refactor: merge dnsx and errorsx into netxlite (#517) 2021-09-28 12:42:01 +02:00
geoipx refactor: spin geoipx off geolocate (#893) 2022-08-28 20:00:25 +02:00
httpx feat(oonirun): add support for OONIRun v2 links (#844) 2022-07-08 16:53:59 +02:00
humanize fix(all): introduce and use iox.CopyContext (#380) 2021-06-15 13:44:28 +02:00
kvstore refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
legacy/assetsdir cleanup: move legacy from internal/engine to internal (#759) 2022-05-25 10:19:03 +02:00
logx fix(webconnectivity@v0.5): fetch HTTP only using system-resolver addrs (#935) 2022-09-05 13:33:59 +02:00
measurex refactor: make measurex depend on measurexlite (#892) 2022-08-28 21:41:58 +02:00
measurexlite fix(datafmt): sync measurexlite and v0.5 with previous code (#942) 2022-09-08 10:02:47 +02:00
mlablocate cleanup: remove redundant HTTPClient definition (#643) 2022-01-03 16:47:54 +01:00
mlablocatev2 cleanup: remove redundant HTTPClient definition (#643) 2022-01-03 16:47:54 +01:00
model fix(datafmt): sync measurexlite and v0.5 with previous code (#942) 2022-09-08 10:02:47 +02:00
multierror doc: cleanup and improve for recently moved pkgs (#354) 2021-06-04 11:39:00 +02:00
netxlite chore: run go generate ./... (#929) 2022-09-04 17:33:22 +02:00
oonirun doc: document the minioonirunv2 functionality (#916) 2022-08-31 19:51:31 +02:00
platform feat: add support for OpenBSD (#703) 2022-03-08 12:25:33 +01:00
ptx refactor(netx): move construction logic outside package (#798) 2022-06-05 21:22:27 +02:00
randx doc: improve and reference existing bug in the code (#356) 2021-06-04 12:50:23 +02:00
registry feat(miniooni): make CLI much more user friendly (#913) 2022-08-31 12:44:46 +02:00
runtimex feat(oonirun): improve tests (#915) 2022-08-31 18:40:27 +02:00
scrubber refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
shellx refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
stuninput refactor: create common package for holding STUN input (#631) 2021-12-03 14:45:25 +01:00
testingx feat: tlsping and tcpping using step-by-step (#815) 2022-07-01 12:22:22 +02:00
torlogs feat: re-implement the vanilla_tor experiment (#718) 2022-05-10 15:43:28 +02:00
tracex fix(tracex): use HTTP transaction end time for t (#925) 2022-09-02 15:10:57 +02:00
tunnel fix: disable psiphon when building with go1.19 (#871) 2022-08-22 11:50:58 +02:00
tutorial feat: clearly indicate which resolver we're using (#885) 2022-08-27 15:47:48 +02:00
version chore: set version to 3.17.0-alpha (#939) 2022-09-07 15:12:06 +02:00
README.md doc: mention step-by-step design document 2022-06-17 11:02:54 +02:00

Directory github.com/ooni/probe-cli/internal

This directory contains private Go packages.

Useful commands

You can read the Go documentation of a package by using go doc -all.

For example:

go doc -all ./internal/netxlite

You can get a graph of the dependencies using kisielk/godepgraph.

For example:

godepgraph -s -novendor -p golang.org,gitlab.com ./internal/engine | dot -Tpng -o deps.png

You can further tweak which packages to exclude by appending prefixes to the list passed to the -p flag.

Tutorials

The tutorial package contains tutorials on writing new experiments, using measurements libraries, and networking code.

Network extensions

This section briefly describes the overall design of the network extensions (aka netx) inside ooni/probe-cli. In OONI, we have two distinct but complementary needs:

  1. speaking with our backends or accessing other services useful to bootstrap OONI probe and perform measurements;

  2. implementing network experiments.

We originally implemented these functionality into a separate repository: ooni/netx. The original design document still provides a good overview of the problems we wanted to solve. The newer dd-002-step-by-step.md design document describes the current architecture (as of 2022-06-17) and the future trajectory for netx.

The general idea of netx has always been to provide interfaces replacing standard library objects that we could further wrap to perform network measurements without deviating from the normal APIs expected by Go programmers.

For example,

type Dialer interface {
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

is a generic dialer that could be a &net.Dialer{} but could also be a saving dialer that saves the results of dial events. So, you could write something like:

saver := &Saver{}
var dialer Dialer = NewDialer()
dialer = saver.WrapDialer(dialer)
conn, err := dialer.DialContext(ctx, network, address)
events := saver.ExtractEvents()

In short, with the original netx you could write measurement code resembling ordinary Go code but you could also save network events from which to derive whether there was censorship.

Since then, the architecture itself has evolved and netx has been merged into ooni/probe-engine and later ooni/probe-cli. As of 2022-06-06, these are the fundamental netx packages:

  • model/netx.go: contains the interfaces and structs patterned after the Go standard library used by netx;

  • netxlite: implements error wrapping (i.e., mapping Go errors to OONI errors), enforces timeouts, and generally ensures that we're using a stdlib-like network API that meet all our constraints and requirements (e.g., logging);

  • bytecounter: provides support for counting the number of bytes consumed by network interactions;

  • multierror: defines an error type that contains a list of errors for representing the results of operations where multiple sub-operations may fail (e.g., TCP connect fails for all the IP addresses associated with a domain name);

  • tracex: support for collecting events during operations such as TCP connect, QUIC handshake, HTTP round trip. Collecting events allows us to analyze such events and determine whether there was blocking. This measurement strategy is called tracing because we wrap fundamental types (e.g., a dialer or an HTTP transport) to save the result of each operation into a "list of events" type called `Saver;

  • engine/netx: code surviving from the original netx implementation that we're still using for measuring. Issue ooni/probe#2121 describes a slow refactoring process where we'll move code outside of netx and inside netxlite or other packages. We are currently experimenting with step-by-step measurements, an alternative measurement approach where we break down operations in simpler building blocks. This alternative approach may eventually make netx obsolete.