refactor(tunnel): remove dependecy from logger (#292)

Part of https://github.com/ooni/probe/issues/985
This commit is contained in:
Simone Basso
2021-04-04 11:23:03 +02:00
committed by GitHub
parent dae53cb2a2
commit 1eb63bc4b6
2 changed files with 8 additions and 7 deletions
-7
View File
@@ -7,8 +7,6 @@ import (
"errors"
"net/url"
"time"
"github.com/ooni/probe-cli/v3/internal/engine/model"
)
// Session is the way in which this package sees a Session.
@@ -17,7 +15,6 @@ type Session interface {
TempDir() string
TorArgs() []string
TorBinary() string
Logger() model.Logger
}
// Tunnel is a tunnel used by the session
@@ -30,17 +27,13 @@ type Tunnel interface {
// 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) {
logger := config.Session.Logger()
switch config.Name {
case "":
logger.Debugf("no tunnel has been requested")
return enforceNilContract(nil, nil)
case "psiphon":
logger.Infof("starting %s tunnel; please be patient...", config.Name)
tun, err := psiphonStart(ctx, config)
return enforceNilContract(tun, err)
case "tor":
logger.Infof("starting %s tunnel; please be patient...", config.Name)
tun, err := torStart(ctx, config)
return enforceNilContract(tun, err)
default: