commit 63ea5b12f3b24bab739515de1eac87caae7a9090 Author: n8fr8 nathan@guardianproject.info Date: Mon Feb 22 15:07:04 2021 -0500
add experimental snowflake proxy support --- app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/preferences.xml | 9 +++++++++ .../main/java/org/torproject/android/service/OrbotService.java | 9 ++++++--- .../src/main/java/org/torproject/android/service/util/Prefs.java | 9 +++++++++ 4 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a624ccc4..71e5b004 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -263,4 +263,6 @@ <string name="paste_bridges">Paste Bridges</string> <string name="use_qr_code">Use QR Code</string> <string name="bridge_snowflake">Connect through other Tor peers (experimental)</string> + <string name="be_a_snowflake_title">Run Snowflake Proxy</string> + <string name="be_a_snowflake_desc">Allow other Tor users to connect to Tor through your device</string> </resources> diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 506e9d9b..f273f318 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -291,4 +291,13 @@ android:title="@string/pref_disable_network_title" />
</PreferenceCategory> + <PreferenceCategory android:title="Experimental"> + <CheckBoxPreference + android:defaultValue="false" + android:key="pref_be_a_snowflake" + android:summary="@string/be_a_snowflake_title" + android:title="@string/be_a_snowflake_desc" /> + + </PreferenceCategory> + </PreferenceScreen> diff --git a/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java b/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java index 4aae0cef..2807a2c0 100644 --- a/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java +++ b/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java @@ -351,7 +351,7 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb return bridgeList.contains("snowflake"); }
- private void startSnowflakeProxy() { + private void startSnowflakeClient() { //this is using the current, default Tor snowflake infrastructure IPtProxy.startSnowflake("stun:stun.l.google.com:19302", "https://snowflake-broker.azureedge.net/", "ajax.aspnetcdn.com", null, true, false, true, 3); @@ -361,7 +361,8 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb This is to host a snowflake entrance node / bridge */ private void runSnowflakeProxy () { - + + // @param capacity Maximum concurrent clients. OPTIONAL. Defaults to 10, if 0. // @param broker Broker URL. OPTIONAL. Defaults to https://snowflake-broker.bamsoftware.com/, if empty. // @param relay WebSocket relay URL. OPTIONAL. Defaults to wss://snowflake.bamsoftware.com/, if empty. @@ -1659,8 +1660,10 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb IPtProxy.startObfs4Proxy("DEBUG", false, false);
if (useIPtSnowflakeProxy()) - startSnowflakeProxy(); + startSnowflakeClient();
+ if (Prefs.beSnowflakeProxy()) + runSnowflakeProxy();
startTor(); replyWithStatus(mIntent); diff --git a/orbotservice/src/main/java/org/torproject/android/service/util/Prefs.java b/orbotservice/src/main/java/org/torproject/android/service/util/Prefs.java index cc4c9b98..1b2922a7 100644 --- a/orbotservice/src/main/java/org/torproject/android/service/util/Prefs.java +++ b/orbotservice/src/main/java/org/torproject/android/service/util/Prefs.java @@ -20,6 +20,7 @@ public class Prefs { private final static String PREF_OPEN_PROXY_ON_ALL_INTERFACES = "pref_open_proxy_on_all_interfaces"; private final static String PREF_USE_VPN = "pref_vpn"; private final static String PREF_EXIT_NODES = "pref_exit_nodes"; + private final static String PREF_BE_A_SNOWFLAKE = "pref_be_a_snowflake";
private static SharedPreferences prefs;
@@ -61,6 +62,14 @@ public class Prefs { return prefs.getString(PREF_DEFAULT_LOCALE, Locale.getDefault().getLanguage()); }
+ public static boolean beSnowflakeProxy () { + return prefs.getBoolean(PREF_BE_A_SNOWFLAKE,false); + } + + public static void setBeSnowflakeProxy (boolean beSnowflakeProxy) { + putBoolean(PREF_BE_A_SNOWFLAKE,beSnowflakeProxy); + } + public static void setDefaultLocale(String value) { putString(PREF_DEFAULT_LOCALE, value); }
tor-commits@lists.torproject.org