From f3c853bad6b3070e11374bea3b157e214b0be237 Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Fri, 3 Feb 2023 18:18:14 +0100 Subject: [PATCH] fix(torembed): use embedded control conn (#1074) See https://github.com/ooni/probe/issues/2405#issuecomment-1416088377 --- internal/tunnel/torembed.go | 9 +++++---- internal/tunnel/tormobile.go | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/tunnel/torembed.go b/internal/tunnel/torembed.go index a55a6183c4..df7bf67991 100644 --- a/internal/tunnel/torembed.go +++ b/internal/tunnel/torembed.go @@ -29,9 +29,10 @@ func getTorStartConf(config *Config, dataDir string, extraArgs []string) (*tor.S config.logger().Infof("tunnel: tor: exec: %s %s", dataDir, strings.Join(extraArgs, " ")) return &tor.StartConf{ - ProcessCreator: creator, - DataDir: dataDir, - ExtraArgs: extraArgs, - NoHush: true, + ProcessCreator: creator, + UseEmbeddedControlConn: true, + DataDir: dataDir, + ExtraArgs: extraArgs, + NoHush: true, }, nil } diff --git a/internal/tunnel/tormobile.go b/internal/tunnel/tormobile.go index c67f513824..651ed325d8 100644 --- a/internal/tunnel/tormobile.go +++ b/internal/tunnel/tormobile.go @@ -20,6 +20,13 @@ func getTorStartConf(config *Config, dataDir string, extraArgs []string) (*tor.S config.logger().Infof("tunnel: tor: exec: %s %s", dataDir, strings.Join(extraArgs, " ")) return &tor.StartConf{ + // Implementation note: go-libtor leaks a file descriptor when you set + // UseEmbeddedControlConn, as documented by + // + // https://github.com/ooni/probe/issues/2405 + // + // This is why we're not using this field for now. The above mentioned + // issue also refers to what a possible fix would look like. ProcessCreator: libtor.Creator, DataDir: dataDir, ExtraArgs: extraArgs,