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
This commit is contained in:
parent
76a50facc3
commit
973501dd11
8 changed files with 234 additions and 4 deletions
|
|
@ -34,6 +34,10 @@ import (
|
|||
// Session is a measurement session. We filter for the only
|
||||
// functionality we're interested to use. That is, fetching the
|
||||
// psiphon configuration from the OONI backend (if possible).
|
||||
//
|
||||
// Depending on how OONI is compiled, the psiphon configuration
|
||||
// may be embedded into the binary. In such a case, we won't
|
||||
// need to download the configuration from the backend.
|
||||
type Session interface {
|
||||
// FetchPsiphonConfig should fetch and return the psiphon config
|
||||
// as a serialized JSON, or fail with an error.
|
||||
|
|
@ -72,14 +76,20 @@ var ErrUnsupportedTunnelName = errors.New("unsupported tunnel name")
|
|||
// The "psiphon" tunnel requires a configuration. Some builds of
|
||||
// ooniprobe embed a configuration into the binary. When this
|
||||
// is the case, the config.Session is a mocked object that just
|
||||
// retuns such configuration.
|
||||
// returns such a configuration.
|
||||
//
|
||||
// Otherwise, If there is no embedded psiphon configuration, the
|
||||
// config.Session will must be an ordinary session. In such a
|
||||
// config.Session must be an ordinary engine.Session. In such a
|
||||
// case, fetching the Psiphon configuration from the backend may
|
||||
// fail when the backend is not reachable.
|
||||
//
|
||||
// The "fake" tunnel is a fake tunnel that just exposes a
|
||||
// SOCKS5 proxy and then connects directly to server. We use
|
||||
// this special kind of tunnel to implement tests.
|
||||
func Start(ctx context.Context, config *Config) (Tunnel, error) {
|
||||
switch config.Name {
|
||||
case "fake":
|
||||
return fakeStart(ctx, config)
|
||||
case "psiphon":
|
||||
return psiphonStart(ctx, config)
|
||||
case "tor":
|
||||
|
|
|
|||
Loading…
Reference in a new issue