From f674b4fbd5f17fd8f6b3597caa7e137167acb022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 15 Mar 2023 20:59:45 +0800 Subject: [PATCH] Fix build embed tor for mobile --- go.mod | 1 + go.sum | 2 ++ outbound/tor_embed.go | 2 +- outbound/tor_embed_mobile.go | 15 +++++++++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 outbound/tor_embed_mobile.go diff --git a/go.mod b/go.mod index cc609cfc..be82b7f9 100644 --- a/go.mod +++ b/go.mod @@ -18,6 +18,7 @@ require ( github.com/logrusorgru/aurora v2.0.3+incompatible github.com/mholt/acmez v1.1.0 github.com/miekg/dns v1.1.52 + github.com/ooni/go-libtor v1.1.7 github.com/oschwald/maxminddb-golang v1.10.0 github.com/pires/go-proxyproto v0.6.2 github.com/sagernet/cloudflare-tls v0.0.0-20221031050923-d70792f4c3a0 diff --git a/go.sum b/go.sum index 806a7829..629d6892 100644 --- a/go.sum +++ b/go.sum @@ -77,6 +77,8 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA github.com/onsi/ginkgo/v2 v2.2.0 h1:3ZNA3L1c5FYDFTTxbFeVGGD8jYvjYauHD30YgLxVsNI= github.com/onsi/ginkgo/v2 v2.2.0/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q= +github.com/ooni/go-libtor v1.1.7 h1:ooVcdEPBqDox5OfeXAfXIeQFCbqMLJVfIpO+Irr7N9A= +github.com/ooni/go-libtor v1.1.7/go.mod h1:q1YyLwRD9GeMyeerVvwc0vJ2YgwDLTp2bdVcrh/JXyI= github.com/oschwald/maxminddb-golang v1.10.0 h1:Xp1u0ZhqkSuopaKmk1WwHtjF0H9Hd9181uj2MQ5Vndg= github.com/oschwald/maxminddb-golang v1.10.0/go.mod h1:Y2ELenReaLAZ0b400URyGwvYxHV1dLIxBuyOsyYjHK0= github.com/pierrec/lz4/v4 v4.1.14 h1:+fL8AQEZtz/ijeNnpduH0bROTu0O3NZAlPjQxGn8LwE= diff --git a/outbound/tor_embed.go b/outbound/tor_embed.go index a91e06ee..d80b49ae 100644 --- a/outbound/tor_embed.go +++ b/outbound/tor_embed.go @@ -1,4 +1,4 @@ -//go:build with_embedded_tor +//go:build with_embedded_tor && !(android || ios) package outbound diff --git a/outbound/tor_embed_mobile.go b/outbound/tor_embed_mobile.go new file mode 100644 index 00000000..0900d8c9 --- /dev/null +++ b/outbound/tor_embed_mobile.go @@ -0,0 +1,15 @@ +//go:build with_embedded_tor && (android || ios) + +package outbound + +import ( + "github.com/cretz/bine/tor" + "github.com/ooni/go-libtor" +) + +func newConfig() tor.StartConf { + return tor.StartConf{ + ProcessCreator: libtor.Creator, + UseEmbeddedControlConn: true, + } +}