diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 8a57a05ac8..fbcffd885e 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -35,9 +35,6 @@ jobs: PSIPHON_CONFIG_KEY: ${{ secrets.PSIPHON_CONFIG_KEY }} PSIPHON_CONFIG_JSON_AGE_BASE64: ${{ secrets.PSIPHON_CONFIG_JSON_AGE_BASE64 }} - # we need coreutils for sha256 plus a bunch of GNU build tools - - run: brew install autoconf automake coreutils libtool - - run: make EXPECTED_XCODE_VERSION=14.2 MOBILE/ios - uses: actions/upload-artifact@v3 diff --git a/Makefile b/Makefile index 43ddb7b580..a1dcd72886 100644 --- a/Makefile +++ b/Makefile @@ -98,7 +98,6 @@ android: search/for/java #help: The `make MOBILE/ios` command builds the oonimkall library for iOS. .PHONY: MOBILE/ios MOBILE/ios: search/for/zip search/for/xcode - go run ./internal/cmd/buildtool ios cdeps zlib openssl libevent tor go run ./internal/cmd/buildtool ios gomobile ./MOBILE/ios/zipframework ./MOBILE/ios/createpodspec diff --git a/go.mod b/go.mod index eeb76c6da5..cb036df062 100644 --- a/go.mod +++ b/go.mod @@ -22,6 +22,7 @@ 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 @@ -144,9 +145,9 @@ require ( github.com/xtaci/kcp-go/v5 v5.6.2 // indirect github.com/xtaci/smux v1.5.24 // indirect gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect - golang.org/x/mod v0.13.0 // indirect + golang.org/x/mod v0.12.0 // indirect golang.org/x/term v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect - golang.org/x/tools v0.14.0 // indirect + golang.org/x/tools v0.13.0 // indirect google.golang.org/protobuf v1.31.0 // indirect ) diff --git a/go.sum b/go.sum index 02f515d0ef..0f3aaf7ff2 100644 --- a/go.sum +++ b/go.sum @@ -74,6 +74,7 @@ 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= @@ -321,6 +322,8 @@ 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= @@ -547,6 +550,7 @@ 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= @@ -584,8 +588,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= -golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -622,7 +626,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -714,8 +718,8 @@ golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= -golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/cmd/buildtool/builddeps.go b/internal/cmd/buildtool/builddeps.go index 32349f0089..b499b45a48 100644 --- a/internal/cmd/buildtool/builddeps.go +++ b/internal/cmd/buildtool/builddeps.go @@ -82,7 +82,3 @@ func (*buildDeps) GOOS() string { func (*buildDeps) VerifySHA256(expectedSHA256 string, tarball string) { cdepsMustVerifySHA256(expectedSHA256, tarball) } - -func (*buildDeps) XCRun(args ...string) string { - return iosXCRun(args...) -} diff --git a/internal/cmd/buildtool/cdepsopenssl.go b/internal/cmd/buildtool/cdepsopenssl.go index 9ad149860e..d9ffa46e74 100644 --- a/internal/cmd/buildtool/cdepsopenssl.go +++ b/internal/cmd/buildtool/cdepsopenssl.go @@ -83,6 +83,7 @@ func cdepsOpenSSLBuildMain(globalEnv *cBuildEnv, deps buildtoolmodel.Dependencie must.Run(log.Log, "make", "DESTDIR="+globalEnv.DESTDIR, "install_dev") - // FIXME: we need to explain this change + // We used to delete the pkgconfig but it turns out this is import for iOS builds, which + // means now we need to keep it. See https://github.com/ooni/probe-cli/pull/1366 for details. //must.Run(log.Log, "rm", "-rf", filepath.Join(globalEnv.DESTDIR, "lib", "pkgconfig")) } diff --git a/internal/cmd/buildtool/internal/buildtooltest/buildtooltest.go b/internal/cmd/buildtool/internal/buildtooltest/buildtooltest.go index 6ef3d9e171..17bffeeca3 100644 --- a/internal/cmd/buildtool/internal/buildtooltest/buildtooltest.go +++ b/internal/cmd/buildtool/internal/buildtooltest/buildtooltest.go @@ -245,8 +245,3 @@ func (cc *DependenciesCallCounter) increment(name string) { } cc.Counter[name]++ } - -// XCRun implements buildtoolmodel.Dependencies. -func (*DependenciesCallCounter) XCRun(args ...string) string { - panic("unimplemented") // TODO(bassosimone): implement this function -} diff --git a/internal/cmd/buildtool/ios.go b/internal/cmd/buildtool/ios.go index e12b0a9532..9208b8c00d 100644 --- a/internal/cmd/buildtool/ios.go +++ b/internal/cmd/buildtool/ios.go @@ -5,15 +5,10 @@ package main // import ( - "errors" - "fmt" "path/filepath" - "runtime" "github.com/apex/log" "github.com/ooni/probe-cli/v3/internal/cmd/buildtool/internal/buildtoolmodel" - "github.com/ooni/probe-cli/v3/internal/must" - "github.com/ooni/probe-cli/v3/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/shellx" "github.com/spf13/cobra" ) @@ -24,7 +19,6 @@ func iosSubcommand() *cobra.Command { Use: "ios", Short: "Builds oonimkall and its dependencies for iOS", } - cmd.AddCommand(&cobra.Command{ Use: "gomobile", Short: "Builds oonimkall for iOS using gomobile", @@ -32,18 +26,6 @@ func iosSubcommand() *cobra.Command { iosBuildGomobile(&buildDeps{}) }, }) - - cmd.AddCommand(&cobra.Command{ - Use: "cdeps {zlib|openssl|libevent|tor} [zlib|openssl|libevent|tor...]", - Short: "Cross compiles C dependencies for iOS", - Run: func(cmd *cobra.Command, args []string) { - for _, arg := range args { - iosCdepsBuildMain(arg, &buildDeps{}) - } - }, - Args: cobra.MinimumNArgs(1), - }) - return cmd } @@ -59,165 +41,6 @@ func iosBuildGomobile(deps buildtoolmodel.Dependencies) { output: filepath.Join("MOBILE", "ios", "oonimkall.xcframework"), target: "ios", } - log.Info("building the mobile library using gomobile") gomobileBuild(config) } - -// iosCdepsBuildMain builds C dependencies for ios. -func iosCdepsBuildMain(name string, deps buildtoolmodel.Dependencies) { - runtimex.Assert( - runtime.GOOS == "darwin", - "this command requires darwin or linux", - ) - - // The assembly of the arm version is broken for unknown reasons - //archs := []string{"arm", "arm64", "386", "amd64"} - // It seems there's no support for 386? - //archs := []string{"arm64", "386", "amd64"} - archs := []string{"arm64", "amd64"} - for _, arch := range archs { - iosCdepsBuildArch(deps, arch, name) - } -} - -// iosPlatformForOONIArch maps the ooniArch to the iOS platform -var iosPlatformForOONIArch = map[string]string{ - "386": "iphonesimulator", - "amd64": "iphonesimulator", - "arm": "iphoneos", - "arm64": "iphoneos", -} - -// iosAppleArchForOONIArch maps the ooniArch to the corresponding apple arch -var iosAppleArchForOONIArch = map[string]string{ - "386": "i386", - "amd64": "x86_64", - "arm": "armv7s", - "arm64": "arm64", -} - -// iosMinVersionFlagForOONIArch maps the ooniArch to the corresponding compiler flag -// to set the minimum version of either iphoneos or iphonesimulator. -// -// TODO(bassosimone): the OpenSSL build sets -mios-version-min to a very low value -// and I *think* (but I don't *know* whether) these two flags are aliasing each other. -var iosMinVersionFlagForOONIArch = map[string]string{ - "386": "-mios-simulator-version-min=", - "amd64": "-mios-simulator-version-min=", - "arm": "-miphoneos-version-min=", - "arm64": "-miphoneos-version-min=", -} - -// iosCdepsBuildArch builds the given dependency for the given arch -func iosCdepsBuildArch(deps buildtoolmodel.Dependencies, ooniArch string, name string) { - cdenv := iosNewCBuildEnv(deps, ooniArch) - switch name { - case "libevent": - cdepsLibeventBuildMain(cdenv, deps) - case "openssl": - cdepsOpenSSLBuildMain(cdenv, deps) - case "tor": - cdepsTorBuildMain(cdenv, deps) - case "zlib": - cdepsZlibBuildMain(cdenv, deps) - default: - panic(fmt.Errorf("unknown dependency: %s", name)) - } -} - -// iosMinVersion is the minimum version that we support. -// -// Note: "iOS 10 is the maximum deployment target for 32-bit targets". -// -// See https://stackoverflow.com/questions/47772435. -const iosMinVersion = "10.0" - -// iosNewCBuildEnv creates a new [cBuildEnv] for the given ooniArch ("arm", "arm64", "386", "amd64"). -func iosNewCBuildEnv(deps buildtoolmodel.Dependencies, ooniArch string) *cBuildEnv { - destdir := runtimex.Try1(filepath.Abs(filepath.Join( // must be absolute - "internal", "libtor", "ios", ooniArch, - ))) - - var ( - appleArch = iosAppleArchForOONIArch[ooniArch] - minVersionFlag = iosMinVersionFlagForOONIArch[ooniArch] - platform = iosPlatformForOONIArch[ooniArch] - ) - runtimex.Assert(appleArch != "", "empty appleArch") - runtimex.Assert(minVersionFlag != "", "empty minVersionFlag") - runtimex.Assert(platform != "", "empty platform") - - isysroot := deps.XCRun("-sdk", platform, "--show-sdk-path") - - out := &cBuildEnv{ - ANDROID_HOME: "", // not needed - ANDROID_NDK_ROOT: "", // not needed - AS: deps.XCRun("-find", "-sdk", platform, "as"), - AR: deps.XCRun("-find", "-sdk", platform, "ar"), - BINPATH: "", // not needed - CC: deps.XCRun("-find", "-sdk", platform, "cc"), - CFLAGS: []string{ - "-isysroot", isysroot, - minVersionFlag + iosMinVersion, // tricky: they must be concatenated - "-O2", - "-arch", appleArch, - "-fembed-bitcode", - }, - CONFIGURE_HOST: "", // later - DESTDIR: destdir, - CXX: deps.XCRun("-find", "-sdk", platform, "c++"), - CXXFLAGS: []string{ - "-isysroot", isysroot, - minVersionFlag + iosMinVersion, // tricky: they must be concatenated - "-arch", appleArch, - "-fembed-bitcode", - "-O2", - }, - GOARCH: ooniArch, - GOARM: "", // maybe later - LD: deps.XCRun("-find", "-sdk", platform, "ld"), - LDFLAGS: []string{ - "-isysroot", isysroot, - minVersionFlag + iosMinVersion, // tricky: they must be concatenated - "-arch", appleArch, - "-fembed-bitcode", - }, - OPENSSL_COMPILER: "", // later - OPENSSL_POST_COMPILER_FLAGS: []string{ - minVersionFlag + iosMinVersion, // tricky: they must be concatenated - "-fembed-bitcode", - }, - RANLIB: deps.XCRun("-find", "-sdk", platform, "ranlib"), - STRIP: deps.XCRun("-find", "-sdk", platform, "strip"), - } - - switch ooniArch { - case "arm": - out.CONFIGURE_HOST = "arm-apple-darwin" - out.GOARM = "7" - out.OPENSSL_COMPILER = "ios-xcrun" - case "arm64": - out.CONFIGURE_HOST = "arm-apple-darwin" - out.GOARM = "" - out.OPENSSL_COMPILER = "ios64-xcrun" - case "386": - out.CONFIGURE_HOST = "i386-apple-darwin" - out.GOARM = "" - out.OPENSSL_COMPILER = "iossimulator-i386-xcrun" - case "amd64": - out.CONFIGURE_HOST = "x86_64-apple-darwin" - out.GOARM = "" - out.OPENSSL_COMPILER = "iossimulator-xcrun" - default: - panic(errors.New("unsupported ooniArch")) - } - - return out -} - -// iosXCRun invokes `xcrun [args]` and returns its result of panics. This function -// is called indirectly by the iOS build through [buildtoolmodel.Dependencies]. -func iosXCRun(args ...string) string { - return string(must.FirstLineBytes(must.RunOutput(log.Log, "xcrun", args...))) -} diff --git a/internal/libtor/enabled.go b/internal/libtor/enabled.go index f29619fd20..64daa7ef44 100644 --- a/internal/libtor/enabled.go +++ b/internal/libtor/enabled.go @@ -18,11 +18,6 @@ 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/libtor/ios/amd64/.gitignore b/internal/libtor/ios/amd64/.gitignore deleted file mode 100644 index f32e7dc720..0000000000 --- a/internal/libtor/ios/amd64/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/include -/lib diff --git a/internal/libtor/ios/arm64/.gitignore b/internal/libtor/ios/arm64/.gitignore deleted file mode 100644 index f32e7dc720..0000000000 --- a/internal/libtor/ios/arm64/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/include -/lib diff --git a/internal/tunnel/tordesktop.go b/internal/tunnel/tordesktop.go index c228b87298..bda2bb74dc 100644 --- a/internal/tunnel/tordesktop.go +++ b/internal/tunnel/tordesktop.go @@ -1,4 +1,4 @@ -//go:build !ooni_libtor +//go:build !android && !ios && !ooni_libtor package tunnel diff --git a/internal/tunnel/torembed.go b/internal/tunnel/torembed.go index f915ed385e..df7bf67991 100644 --- a/internal/tunnel/torembed.go +++ b/internal/tunnel/torembed.go @@ -1,4 +1,4 @@ -//go:build ooni_libtor +//go:build ooni_libtor && android package tunnel diff --git a/internal/tunnel/tormobile.go b/internal/tunnel/tormobile.go new file mode 100644 index 0000000000..651ed325d8 --- /dev/null +++ b/internal/tunnel/tormobile.go @@ -0,0 +1,35 @@ +//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 +}