feat: reintroduce the tproxy functionality (#975)

We originally removed the TProxy in https://github.com/ooni/probe/issues/2224. Nevertheless, in https://github.com/ooni/probe-cli/pull/969, we determined that something like the previous TProxy, with small changes, was required to support https://github.com/ooni/probe/issues/2340. So, this pull request reintroduces a slightly-modified TProxy functionality that better adapts to the `--remote=REMOTE` use case.
This commit is contained in:
Simone Basso 2022-10-12 17:38:33 +02:00 committed by GitHub
commit 86ffd6a0c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 262 additions and 55 deletions

View file

@ -8,13 +8,13 @@
// You should consider checking the tutorial explaining how to use this package
// for network measurements: https://github.com/ooni/probe-cli/tree/master/internal/tutorial/netxlite.
//
// Naming and history
// # Naming and history
//
// Previous versions of this package were called netx. Compared to such
// versions this package is lightweight because it does not contain code
// to perform the measurements, hence its name.
//
// Design
// # Design
//
// We want to potentially be able to observe each low-level operation
// separately, even though this is not done by this package. This is
@ -41,7 +41,19 @@
// See also the design document at docs/design/dd-003-step-by-step.md,
// which provides an overview of netxlite's main concerns.
//
// Operations
// To implement integration testing, we support hijacking the core network
// primitives used by this package, that is:
//
// 1. connecting a new TCP/UDP connection;
//
// 2. creating listening UDP sockets;
//
// 3. resolving domain names with getaddrinfo.
//
// By overriding the TProxy variable, you can control these operations and route
// traffic to, e.g., a wireguard peer where you implement censorship.
//
// # Operations
//
// This package implements the following operations:
//
@ -62,7 +74,7 @@
// Operations 1, 2, 3, and 4 are used when we perform measurements,
// while 5 and 6 are mostly used when speaking with our backend.
//
// Getaddrinfo usage
// # Getaddrinfo usage
//
// When compiled with CGO_ENABLED=1, this package will link with libc
// and call getaddrinfo directly. While this design choice means we will