feat(torsf): collect tor logs, select rendezvous method, count bytes (#683)
This diff contains significant improvements over the previous implementation of the torsf experiment. We add support for configuring different rendezvous methods after the convo at https://github.com/ooni/probe/issues/2004. In doing that, I've tried to use a terminology that is consistent with the names being actually used by tor developers. In terms of what to do next, this diff basically instruments torsf to always rendezvous using domain fronting. Yet, it's also possible to change the rendezvous method from the command line, when using miniooni, which allows to experiment a bit more. In the same vein, by default we use a persistent tor datadir, but it's also possible to use a temporary datadir using the cmdline. Here's how a generic invocation of `torsf` looks like: ```bash ./miniooni -O DisablePersistentDatadir=true \ -O RendezvousMethod=amp \ -O DisableProgress=true \ torsf ``` (The default is `DisablePersistentDatadir=false` and `RendezvousMethod=domain_fronting`.) With this implementation, we can start measuring whether snowflake and tor together can boostrap, which seems the most important thing to focus on at the beginning. Understanding why the bootstrap most often does not converge with a temporary datadir on Android devices remains instead an open problem for now. (I'll also update the relevant issues or create new issues after commit this.) We also address some methodology improvements that were proposed in https://github.com/ooni/probe/issues/1686. Namely: 1. we record the tor version; 2. we include the bootstrap percentage by reading the logs; 3. we set the anomaly key correctly; 4. we measure the bytes send and received (by `tor` not by `snowflake`, since doing it for snowflake seems more complex at this stage). What remains to be done is the possibility of including Snowflake events into the measurement, which is not possible until the new improvements at common/event in snowflake.git are included into a tagged version of snowflake itself. (I'll make sure to mention this aspect to @cohosh in https://github.com/ooni/probe/issues/2004.)
This commit is contained in:
parent
4e5f9bd254
commit
85664f1e31
40 changed files with 1124 additions and 308 deletions
|
|
@ -2,6 +2,7 @@ package tunnel
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net"
|
||||
"os"
|
||||
|
||||
|
|
@ -66,6 +67,9 @@ type Config struct {
|
|||
// testTorStart allows us to mock tor.Start.
|
||||
testTorStart func(ctx context.Context, conf *tor.StartConf) (*tor.Tor, error)
|
||||
|
||||
// testTorProtocolInfo allows us to mock getting protocol info.
|
||||
testTorProtocolInfo func(tor *tor.Tor) (*control.ProtocolInfo, error)
|
||||
|
||||
// testTorEnableNetwork allows us to fake a failure when
|
||||
// telling to the tor daemon to enable the network.
|
||||
testTorEnableNetwork func(ctx context.Context, tor *tor.Tor, wait bool) error
|
||||
|
|
@ -163,6 +167,21 @@ func (c *Config) torStart(ctx context.Context, conf *tor.StartConf) (*tor.Tor, e
|
|||
return tor.Start(ctx, conf)
|
||||
}
|
||||
|
||||
// errNoTorControl indicate you passed us a tor with a nil control field.
|
||||
var errNoTorControl = errors.New("tunnel: no tor control")
|
||||
|
||||
// torProtocolInfo calls either testTorProtocolInfo or the
|
||||
// proper function to get back protocol information.
|
||||
func (c *Config) torProtocolInfo(tor *tor.Tor) (*control.ProtocolInfo, error) {
|
||||
if c.testTorProtocolInfo != nil {
|
||||
return c.testTorProtocolInfo(tor)
|
||||
}
|
||||
if tor.Control == nil {
|
||||
return nil, errNoTorControl
|
||||
}
|
||||
return tor.Control.ProtocolInfo()
|
||||
}
|
||||
|
||||
// torEnableNetwork calls either testTorEnableNetwork or tor.EnableNetwork.
|
||||
func (c *Config) torEnableNetwork(ctx context.Context, tor *tor.Tor, wait bool) error {
|
||||
if c.testTorEnableNetwork != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue