[tbb-commits] [tor-browser-build/maint-10.0-android] Bug 40188: Build and ship snowflake only if it is enabled

sysrqb at torproject.org sysrqb at torproject.org
Fri Feb 19 14:54:59 UTC 2021


commit 6089e1364f2c0d2a50ab1dfc8d88cc31ec27a8f0
Author: Georg Koppen <gk at torproject.org>
Date:   Sat Jan 16 21:05:38 2021 +0000

    Bug 40188: Build and ship snowflake only if it is enabled
---
 ...01-Revert-Bug-30318-Add-snowflake-support.patch | 78 ++++++++++++++++++++++
 projects/tor-android-service/build                 |  4 +-
 projects/tor-android-service/config                |  2 +
 projects/tor-onion-proxy-library/build             | 29 +++++---
 projects/tor-onion-proxy-library/config            |  5 ++
 5 files changed, 108 insertions(+), 10 deletions(-)

diff --git a/projects/tor-android-service/0001-Revert-Bug-30318-Add-snowflake-support.patch b/projects/tor-android-service/0001-Revert-Bug-30318-Add-snowflake-support.patch
new file mode 100644
index 0000000..b7be2ae
--- /dev/null
+++ b/projects/tor-android-service/0001-Revert-Bug-30318-Add-snowflake-support.patch
@@ -0,0 +1,78 @@
+From f3cf622e537a1283b821b3f3ce8e396a01bcb84b Mon Sep 17 00:00:00 2001
+From: Georg Koppen <gk at torproject.org>
+Date: Sat, 16 Jan 2021 20:56:30 +0000
+Subject: [PATCH] Revert "Bug 30318: Add snowflake support"
+
+This reverts commit ecc251d0a73f7e2034a271efd28036a0108b8688.
+
+diff --git a/service/src/main/assets/common/bridges.txt b/service/src/main/assets/common/bridges.txt
+index 1525eba..fe37735 100644
+--- a/service/src/main/assets/common/bridges.txt
++++ b/service/src/main/assets/common/bridges.txt
+@@ -13,5 +13,3 @@ obfs4 45.145.95.6:27015 C5B7CD6946FF10C5B3E89691A7D3F2C122D2117C cert=TD7PbUO0/0
+ obfs4 [2a0c:4d80:42:702::1]:27015 C5B7CD6946FF10C5B3E89691A7D3F2C122D2117C cert=TD7PbUO0/0k6xYHMPW3vJxICfkMZNdkRrb63Zhl5j9dW3iRGiCx0A7mPhe5T2EDzQ35+Zw iat-mode=0
+ obfs4 51.222.13.177:80 5EDAC3B810E12B01F6FD8050D2FD3E277B289A08 cert=2uplIpLQ0q9+0qMFrK5pkaYRDOe460LL9WHBvatgkuRr/SL31wBOEupaMMJ6koRE6Ld0ew iat-mode=0
+ meek_lite 0.0.2.0:2 97700DFE9F483596DDA6264C4D7DF7641E1E39CE url=https://meek.azureedge.net/ front=ajax.aspnetcdn.com
+-
+-snowflake 0.0.3.0:1 2B280B23E1107BB62ABFC40DDCC8824814F80A72
+diff --git a/service/src/main/java/org/torproject/android/service/CustomTorInstaller.java b/service/src/main/java/org/torproject/android/service/CustomTorInstaller.java
+index 52bc4fe..198c981 100644
+--- a/service/src/main/java/org/torproject/android/service/CustomTorInstaller.java
++++ b/service/src/main/java/org/torproject/android/service/CustomTorInstaller.java
+@@ -40,17 +40,14 @@ public class CustomTorInstaller extends TorInstaller {
+     @Override
+     public InputStream openBridgesStream() throws IOException {
+         /*
+-            BridgesList is an overloaded field, which can cause some confusion.
+-            The list can be:
+-              1) a filter like obfs4, meek, or snowflake OR
+-              2) it can be a custom bridge
+-            For (1), we just pass back all bridges, the filter will occur
+-              elsewhere in the library.
+-            For (2) we return the bridge list as a raw stream.
+-            If length is greater than 9, then we know this is a custom bridge
++            BridgesList is an overloaded field, which can cause some confusion. The list can be:
++            1) a filter like obfs4 or meek OR 2) it can be a custom bridge
++            For (1), we just pass back all bridges, the filter will occur elsewhere in the library.
++            For (2) we return the bridge list as a raw stream
++            If length is greater than 5, then we know this is a custom bridge
+          */
+         String userDefinedBridgeList = Prefs.getBridgesList();
+-        byte bridgeType = (byte) (userDefinedBridgeList.length() > 9 ? 1 : 0);
++        byte bridgeType = (byte) (userDefinedBridgeList.length() > 5 ? 1 : 0);
+         // Terrible hack. Must keep in sync with topl::addBridgesFromResources.
+         if (bridgeType == 0) {
+             switch (userDefinedBridgeList) {
+@@ -60,9 +57,6 @@ public class CustomTorInstaller extends TorInstaller {
+                 case "meek":
+                     bridgeType = 3;
+                     break;
+-                case "snowflake":
+-                    bridgeType = 4;
+-                    break;
+             }
+         }
+ 
+diff --git a/service/src/main/java/org/torproject/android/service/TorService.java b/service/src/main/java/org/torproject/android/service/TorService.java
+index f1ddcda..32d7f30 100644
+--- a/service/src/main/java/org/torproject/android/service/TorService.java
++++ b/service/src/main/java/org/torproject/android/service/TorService.java
+@@ -365,12 +365,10 @@ public final class TorService extends Service implements TorServiceConstants, Or
+ 
+             //Check bridges to see if we need this
+             File nativeDir = new File(getApplicationInfo().nativeLibraryDir);
+-            File pluggableTransportObfs = new File(nativeDir, "libObfs4proxy.so");
+-            if(!pluggableTransportObfs.canExecute()) pluggableTransportObfs.setExecutable(true);
+-            File pluggableTransportSnow = new File(nativeDir, "libSnowflake.so");
+-            if(!pluggableTransportSnow.canExecute()) pluggableTransportSnow.setExecutable(true);
++            File pluggableTransport = new File(nativeDir, "libObfs4proxy.so");
++            if(!pluggableTransport.canExecute()) pluggableTransport.setExecutable(true);
+ 
+-            builder.configurePluggableTransportsFromSettings(pluggableTransportObfs, pluggableTransportSnow);
++            builder.configurePluggableTransportsFromSettings(pluggableTransport);
+             mDataService.updateConfigBuilder(builder);
+             onionProxyManager.getTorInstaller().updateTorConfigCustom
+                     (builder.asString());
+-- 
+2.30.0
+
diff --git a/projects/tor-android-service/build b/projects/tor-android-service/build
index 3989001..7efd708 100644
--- a/projects/tor-android-service/build
+++ b/projects/tor-android-service/build
@@ -13,7 +13,9 @@ mkdir -p /var/tmp/build $output_dir
 tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
 
 cd /var/tmp/build/[% project %]-[% c('version') %]
-
+[% IF ! c("var/snowflake") %]
+  patch -p1 < $rootdir/0001-Revert-Bug-30318-Add-snowflake-support.patch
+[% END %]
 # Replace pre-packaged tor library with the latest build
 rm -fR service/src/main/jniLibs/*
 [% FOREACH arch = ['armv7', 'aarch64', 'x86', 'x86_64'] -%]
diff --git a/projects/tor-android-service/config b/projects/tor-android-service/config
index 81a4159..d6d2fed 100644
--- a/projects/tor-android-service/config
+++ b/projects/tor-android-service/config
@@ -22,6 +22,8 @@ input_files:
     exec: '[% INCLUDE "fetch-gradle-dependencies" %]'
   - project: tor-onion-proxy-library
     name: topl
+  - filename: 0001-Revert-Bug-30318-Add-snowflake-support.patch
+    enable: '[% ! c("var/snowflake") %]'
   - project: tor
     name: tor-armv7
     target_prepend:
diff --git a/projects/tor-onion-proxy-library/build b/projects/tor-onion-proxy-library/build
index 7865aa7..c9b1e7a 100644
--- a/projects/tor-onion-proxy-library/build
+++ b/projects/tor-onion-proxy-library/build
@@ -20,31 +20,42 @@ cd /var/tmp/build/[% project %]-[% c('version') %]
 # build will pull down the correct android tool versions
 patch -p1 < $rootdir/gradle.patch
 patch -p1 < $rootdir/0001-Bug-33931-Filter-bridges-in-stream-by-type.patch
-patch -p1 < $rootdir/0001-Bug-30318-Add-snowflake-support.patch
+[% IF c("var/snowflake") %]
+  patch -p1 < $rootdir/0001-Bug-30318-Add-snowflake-support.patch
+[% END %]
 
 [% FOREACH arch = ['armv7', 'aarch64', 'x86', 'x86_64'] -%]
   # Extract obfs4proxy from TorBrowser/Tor/PluggableTransports/obfs4proxy
   tar --strip-components=4 -xf $rootdir/[% c('input_files_by_name/obfs4-' _ arch) %]
 
-  # Extract snowflake from TorBrowser/Tor/PluggableTransports/snowflake
-  tar --strip-components=4 -xf $rootdir/[% c('input_files_by_name/snowflake-' _ arch) %]
-
+  [% IF c("var/snowflake") %]
+    # Extract snowflake from TorBrowser/Tor/PluggableTransports/snowflake
+    tar --strip-components=4 -xf $rootdir/[% c('input_files_by_name/snowflake-' _ arch) %]
+  [% END %]
   # Overwrite the obfs4proxy binary provided by Pluto and add Snowflake
   [% IF arch == "armv7" -%]
     cp obfs4proxy external/pluto/bin/armeabi-v7a/
     cp obfs4proxy external/pluto/bin/armeabi/
-    cp snowflake-client external/pluto/bin/armeabi-v7a/
-    cp snowflake-client external/pluto/bin/armeabi/
+    [% IF c("var/snowflake") %]
+      cp snowflake-client external/pluto/bin/armeabi-v7a/
+      cp snowflake-client external/pluto/bin/armeabi/
+    [% END %]
   [% ELSIF arch == "aarch64" -%]
     cp obfs4proxy external/pluto/bin/arm64-v8a/
-    cp snowflake-client external/pluto/bin/arm64-v8a/
+    [% IF c("var/snowflake") %]
+      cp snowflake-client external/pluto/bin/arm64-v8a/
+    [% END %]
   [% ELSE -%]
     cp obfs4proxy external/pluto/bin/[% arch %]/
-    cp snowflake-client external/pluto/bin/[% arch %]/
+    [% IF c("var/snowflake") %]
+      cp snowflake-client external/pluto/bin/[% arch %]/
+    [% END %]
   [% END -%]
 
   rm obfs4proxy
-  rm snowflake-client
+  [% IF c("var/snowflake") %]
+    rm snowflake-client
+  [% END %]
 [% END -%]
 
 # Build Android Libraries and Apps
diff --git a/projects/tor-onion-proxy-library/config b/projects/tor-onion-proxy-library/config
index 401142c..d07c37b 100644
--- a/projects/tor-onion-proxy-library/config
+++ b/projects/tor-onion-proxy-library/config
@@ -39,21 +39,26 @@ input_files:
     name: snowflake-armv7
     target_prepend:
       - android-armv7
+    enable: '[% c("var/snowflake") %]'
   - project: snowflake
     name: snowflake-aarch64
     target_prepend:
       - android-aarch64
+    enable: '[% c("var/snowflake") %]'
   - project: snowflake
     name: snowflake-x86
     target_prepend:
       - android-x86
+    enable: '[% c("var/snowflake") %]'
   - project: snowflake
     name: snowflake-x86_64
     target_prepend:
       - android-x86_64
+    enable: '[% c("var/snowflake") %]'
   - filename: 'gradle-dependencies-[% c("var/gradle_dependencies_version") %]'
     name: gradle-dependencies
     exec: '[% INCLUDE "fetch-gradle-dependencies" %]'
   - filename: gradle.patch
   - filename: 0001-Bug-33931-Filter-bridges-in-stream-by-type.patch
   - filename: 0001-Bug-30318-Add-snowflake-support.patch
+    enable: '[% c("var/snowflake") %]'





More information about the tbb-commits mailing list