From 23e8fb57210159ad2ea89f30a31dbdb4fed040d5 Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Thu, 12 Oct 2023 20:08:39 +0200 Subject: [PATCH] feat(ios): replace go-libtor with ./internal/libtor (#1366) This diff replaces go-libtor with ./internal/libtor. Closes https://github.com/ooni/probe/issues/2564 --- go.mod | 1 - go.sum | 4 ---- internal/libtor/enabled.go | 5 +++++ internal/tunnel/tordesktop.go | 4 ++-- internal/tunnel/torembed.go | 9 ++++----- internal/tunnel/tormobile.go | 35 ----------------------------------- 6 files changed, 11 insertions(+), 47 deletions(-) delete mode 100644 internal/tunnel/tormobile.go diff --git a/go.mod b/go.mod index d7f6a5eafc..eeb76c6da5 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,6 @@ require ( github.com/miekg/dns v1.1.56 github.com/mitchellh/go-wordwrap v1.0.1 github.com/montanaflynn/stats v0.7.1 - github.com/ooni/go-libtor v1.1.8 github.com/ooni/netem v0.0.0-20230920215742-15f3ffec0107 github.com/ooni/oocrypto v0.5.5 github.com/ooni/oohttp v0.6.5 diff --git a/go.sum b/go.sum index a47a76309a..02f515d0ef 100644 --- a/go.sum +++ b/go.sum @@ -74,7 +74,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI= github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= -github.com/cretz/bine v0.1.0/go.mod h1:6PF6fWAvYtwjRGkAuDEJeWNOv3a2hUouSP/yRYXmvHw= github.com/cretz/bine v0.2.0 h1:8GiDRGlTgz+o8H9DSnsl+5MeBK4HsExxgl6WgzOCuZo= github.com/cretz/bine v0.2.0/go.mod h1:WU4o9QR9wWp8AVKtTM1XD5vUHkEqnf2vVSo6dBqbetI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -322,8 +321,6 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/ooni/go-libtor v1.1.8 h1:Wo3V3DVTxl5vZdxtQakqYP+DAHx7pPtAFSl1bnAa08w= -github.com/ooni/go-libtor v1.1.8/go.mod h1:q1YyLwRD9GeMyeerVvwc0vJ2YgwDLTp2bdVcrh/JXyI= github.com/ooni/netem v0.0.0-20230920215742-15f3ffec0107 h1:PktaCPQ1NYZOaK+J8pQGYiPCYFkGR5H3ZURg9zPkQsI= github.com/ooni/netem v0.0.0-20230920215742-15f3ffec0107/go.mod h1:5X3Lk4+cnrwrQiYgRlCWXgV33IMDgLaO5s1x0DD/fO0= github.com/ooni/oocrypto v0.5.5 h1:x0wIgtBfghVu8Ok0tR/xVyfHlo646hN1LB/5bzuXcIg= @@ -550,7 +547,6 @@ go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= diff --git a/internal/libtor/enabled.go b/internal/libtor/enabled.go index 64daa7ef44..f29619fd20 100644 --- a/internal/libtor/enabled.go +++ b/internal/libtor/enabled.go @@ -18,6 +18,11 @@ package libtor // #cgo android,amd64 CFLAGS: -I${SRCDIR}/android/amd64/include // #cgo android,amd64 LDFLAGS: -L${SRCDIR}/android/amd64/lib -ltor -levent -lssl -lcrypto -lz -lm // +// #cgo ios,arm64 CFLAGS: -I${SRCDIR}/ios/arm64/include +// #cgo ios,arm64 LDFLAGS: -L${SRCDIR}/ios/arm64/lib -ltor -levent -lssl -lcrypto -lz -lm +// #cgo ios,amd64 CFLAGS: -I${SRCDIR}/ios/amd64/include +// #cgo ios,amd64 LDFLAGS: -L${SRCDIR}/ios/amd64/lib -ltor -levent -lssl -lcrypto -lz -lm +// // #include // #include // #include diff --git a/internal/tunnel/tordesktop.go b/internal/tunnel/tordesktop.go index bda2bb74dc..a517ffc3a3 100644 --- a/internal/tunnel/tordesktop.go +++ b/internal/tunnel/tordesktop.go @@ -1,4 +1,4 @@ -//go:build !android && !ios && !ooni_libtor +//go:build !ooni_libtor package tunnel @@ -6,7 +6,7 @@ package tunnel // This file implements our strategy for running tor on desktop in most // configurations except for the ooni_libtor case, where we build tor and // its dependencies for Linux. The purpuse of this special case it that -// of testing the otherwise untested code that would run on Android. +// of testing the otherwise untested code that would run on mobile. // import ( diff --git a/internal/tunnel/torembed.go b/internal/tunnel/torembed.go index df7bf67991..92b04dd39c 100644 --- a/internal/tunnel/torembed.go +++ b/internal/tunnel/torembed.go @@ -1,14 +1,13 @@ -//go:build ooni_libtor && android +//go:build ooni_libtor package tunnel // // This file implements the ooni_libtor strategy of embedding tor. We manually -// compile tor and its dependencies and link against it. We currently only adopt -// this technique for Android. We may possibly migrate also iOS in the future, -// provided that this functionality proves to be stable in the 3.17 cycle. +// compile tor and its dependencies and link against it. // -// See https://github.com/ooni/probe/issues/2365. +// See https://github.com/ooni/probe/issues/2365 and +// https://github.com/ooni/probe/issues/2564. // import ( diff --git a/internal/tunnel/tormobile.go b/internal/tunnel/tormobile.go deleted file mode 100644 index 651ed325d8..0000000000 --- a/internal/tunnel/tormobile.go +++ /dev/null @@ -1,35 +0,0 @@ -//go:build ios || (android && !ooni_libtor) - -package tunnel - -// -// This file implements our old strategy for running tor on mobile, which -// is based on integrating github.com/ooni/go-libtor. We currently only use -// this stategy on iOS. See https://github.com/ooni/probe/issues/2365. -// - -import ( - "strings" - - "github.com/cretz/bine/tor" - "github.com/ooni/go-libtor" -) - -// getTorStartConf in this configuration uses github.com/ooni/go-libtor. -func getTorStartConf(config *Config, dataDir string, extraArgs []string) (*tor.StartConf, error) { - 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, - NoHush: true, - }, nil -}