refactor(tunnel): pass the config as a pointer (#288)

Part of https://github.com/ooni/probe/issues/985
This commit is contained in:
Simone Basso 2021-04-03 20:12:56 +02:00 committed by GitHub
commit b53290cbfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 11 deletions

View file

@ -27,16 +27,23 @@ type Tunnel interface {
Stop()
}
// Config contains config for the session tunnel.
// Config contains the configuration for creating a Tunnel instance.
type Config struct {
Name string
// 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) {
func Start(ctx context.Context, config *Config) (Tunnel, error) {
logger := config.Session.Logger()
switch config.Name {
case "":