refactor(tunnel): simplify psiphon implementation (#289)
Simplify interaction within the package by avoiding to have a psiphon specific config. Use a Config instead. Part of https://github.com/ooni/probe/issues/985.
This commit is contained in:
parent
b53290cbfe
commit
f739450370
4 changed files with 88 additions and 99 deletions
|
|
@ -27,20 +27,6 @@ type Tunnel interface {
|
|||
Stop()
|
||||
}
|
||||
|
||||
// Config contains the configuration for creating a Tunnel instance.
|
||||
type Config struct {
|
||||
// Name is the mandatory name of the tunnel. We support
|
||||
// "tor" and "psiphon" tunnels.
|
||||
Name string
|
||||
|
||||
// Session is the current measurement session.
|
||||
Session Session
|
||||
|
||||
// WorkDir is the directory in which the tunnel SHOULD
|
||||
// store its state, if any.
|
||||
WorkDir string
|
||||
}
|
||||
|
||||
// Start starts a new tunnel by name or returns an error. Note that if you
|
||||
// pass to this function the "" tunnel, you get back nil, nil.
|
||||
func Start(ctx context.Context, config *Config) (Tunnel, error) {
|
||||
|
|
@ -51,9 +37,7 @@ func Start(ctx context.Context, config *Config) (Tunnel, error) {
|
|||
return enforceNilContract(nil, nil)
|
||||
case "psiphon":
|
||||
logger.Infof("starting %s tunnel; please be patient...", config.Name)
|
||||
tun, err := psiphonStart(ctx, config.Session, psiphonConfig{
|
||||
WorkDir: config.WorkDir,
|
||||
})
|
||||
tun, err := psiphonStart(ctx, config)
|
||||
return enforceNilContract(tun, err)
|
||||
case "tor":
|
||||
logger.Infof("starting %s tunnel; please be patient...", config.Name)
|
||||
|
|
|
|||
Loading…
Reference in a new issue