fix(tunnel/tor): keep tunneldir clean (#300)

* fix(tunnel/tor): keep tunneldir clean

This diff ensures that we don't keep the log file growing and
we also remove the temporary files created by the library we
are currently using for running tor from golang.

Part of https://github.com/ooni/probe/issues/985

* fix(session.go): tell use we're using a tunnel
This commit is contained in:
Simone Basso 2021-04-05 19:18:00 +02:00 committed by GitHub
commit 8b92037ae3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 76 additions and 3 deletions

View file

@ -168,6 +168,8 @@ func NewSession(ctx context.Context, config SessionConfig) (*Session, error) {
if proxyURL != nil {
switch proxyURL.Scheme {
case "psiphon", "tor", "fake":
config.Logger.Infof(
"starting '%s' tunnel; please be patient...", proxyURL.Scheme)
tunnel, err := tunnel.Start(ctx, &tunnel.Config{
Name: proxyURL.Scheme,
Session: &sessionTunnelEarlySession{},
@ -178,6 +180,7 @@ func NewSession(ctx context.Context, config SessionConfig) (*Session, error) {
if err != nil {
return nil, err
}
config.Logger.Infof("tunnel '%s' running...", proxyURL.Scheme)
sess.tunnel = tunnel
proxyURL = tunnel.SOCKS5ProxyURL()
}