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

@ -480,3 +480,21 @@ type UDPLikeConn interface {
// which is also instrumental to setting the read buffer.
SyscallConn() (syscall.RawConn, error)
}
// UnderlyingNetwork implements the underlying network APIs on
// top of which we implement network extensions.
type UnderlyingNetwork interface {
// DialContext is equivalent to net.Dialer.DialContext except that
// there is also an explicit timeout for dialing.
DialContext(ctx context.Context, timeout time.Duration, network, address string) (net.Conn, error)
// ListenUDP is equivalent to net.ListenUDP.
ListenUDP(network string, addr *net.UDPAddr) (UDPLikeConn, error)
// GetaddrinfoLookupANY is like net.Resolver.LookupHost except that it
// also returns to the caller the CNAME when it is available.
GetaddrinfoLookupANY(ctx context.Context, domain string) ([]string, string, error)
// GetaddrinfoResolverNetwork returns the resolver network.
GetaddrinfoResolverNetwork() string
}