[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [orbot/master] Experimental show snowflake toast when client connects to proxy...
commit 798ef6eb5d00007f8d0b7b147841061821d8a091
Author: b <dsnake@xxxxxxxxxxxxxx>
Date: Tue Dec 14 18:39:18 2021 -0500
Experimental show snowflake toast when client connects to proxy...
---
app/src/main/res/values/strings.xml | 3 +++
app/src/main/res/xml/preferences.xml | 7 +++++++
.../android/core/ui/SettingsPreferencesActivity.kt | 1 +
.../java/org/torproject/android/service/OrbotService.java | 13 ++++++++++---
.../java/org/torproject/android/service/util/Prefs.java | 5 +++++
orbotservice/src/main/res/values/strings.xml | 3 +++
6 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c3a43f01..9ba83a26 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -259,6 +259,9 @@
<string name="be_a_snowflake_title_limit">Snowflake Proxy Limits</string>
<string name="be_a_snowflake_desc_limit">Only when device is plugged in and on wifi</string>
<string name="snowflake_proxy_enabled">SNOWFLAKE PROXY MODE ENABLED</string>
+ <string name="snowflake_proxy_msg_title">Show Connection Notification</string>
+ <string name="snowflake_proxy_msg_description">Show a message when your snowflake helps someone circumvent censorship</string>
+
</resources>
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index a05bce87..60619894 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -297,6 +297,13 @@
android:key="pref_be_a_snowflake"
android:title="@string/be_a_snowflake_title"
android:summary="@string/be_a_snowflake_desc" />
+
+ <CheckBoxPreference
+ android:defaultValue="false"
+ android:key="pref_show_snowflake_proxy_msg"
+ android:title="@string/snowflake_proxy_msg_title"
+ android:summary="@string/snowflake_proxy_msg_description"/>
+
<!-- <CheckBoxPreference-->
<!-- android:defaultValue="false"-->
<!-- android:key="pref_be_a_snowflake_limit"-->
diff --git a/appcore/src/main/java/org/torproject/android/core/ui/SettingsPreferencesActivity.kt b/appcore/src/main/java/org/torproject/android/core/ui/SettingsPreferencesActivity.kt
index 79f00544..5fe575ad 100644
--- a/appcore/src/main/java/org/torproject/android/core/ui/SettingsPreferencesActivity.kt
+++ b/appcore/src/main/java/org/torproject/android/core/ui/SettingsPreferencesActivity.kt
@@ -35,6 +35,7 @@ class SettingsPreferencesActivity : PreferenceActivity() {
val bridgesEnabled = getSharedPreferences("org.torproject.android_preferences", MODE_MULTI_PROCESS).getBoolean("pref_bridges_enabled", false)
findPreference("pref_be_a_snowflake")?.isEnabled = !bridgesEnabled
findPreference("pref_be_a_snowflake_limit")?.isEnabled = !bridgesEnabled
+ findPreference("pref_show_snowflake_proxy_msg")?.isEnabled = !bridgesEnabled
}
override fun attachBaseContext(newBase: Context) = super.attachBaseContext(LocaleHelper.onAttach(newBase))
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 495e2739..8520a815 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java
@@ -36,6 +36,7 @@ import android.os.IBinder;
import android.provider.BaseColumns;
import android.text.TextUtils;
import android.util.Log;
+import android.widget.Toast;
import net.freehaven.tor.control.TorControlCommands;
import net.freehaven.tor.control.TorControlConnection;
@@ -74,7 +75,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeoutException;
import IPtProxy.IPtProxy;
-
+import IPtProxy.SnowflakeClientConnected;
import androidx.annotation.ChecksSdkIntAtLeast;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
@@ -372,8 +373,14 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
String logFile = null;
boolean keepLocalAddresses = true;
boolean unsafeLogging = false;
- IPtProxy.startSnowflakeProxy(capacity, broker, relay, stun, natProbe, logFile, keepLocalAddresses, unsafeLogging, null);
-
+ SnowflakeClientConnected callback = null;
+ if (Prefs.showSnowflakeProxyMessage()) {
+ callback = (SnowflakeClientConnected) () -> {
+ String message = String.format(getString(R.string.snowflake_proxy_client_connected_msg), "â??ï¸?", "â??ï¸?");
+ Toast.makeText(this, message, Toast.LENGTH_LONG).show();
+ };
+ }
+ IPtProxy.startSnowflakeProxy(capacity, broker, relay, stun, natProbe, logFile, keepLocalAddresses, unsafeLogging, callback);
logNotice("Snowflake Proxy mode ENABLED");
}
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 eaec24e5..d12cc6a6 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
@@ -21,6 +21,7 @@ public class Prefs {
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 final static String PREF_SHOW_SNOWFLAKE_MSG = "pref_show_snowflake_proxy_msg";
private final static String PREF_BE_A_SNOWFLAKE_LIMIT = "pref_be_a_snowflake_limit";
private final static String PREF_HOST_ONION_SERVICES = "pref_host_onionservices";
@@ -78,6 +79,10 @@ public class Prefs {
return prefs.getBoolean(PREF_BE_A_SNOWFLAKE,false);
}
+ public static boolean showSnowflakeProxyMessage() {
+ return prefs.getBoolean(PREF_SHOW_SNOWFLAKE_MSG, false);
+ }
+
public static void setBeSnowflakeProxy (boolean beSnowflakeProxy) {
putBoolean(PREF_BE_A_SNOWFLAKE,beSnowflakeProxy);
}
diff --git a/orbotservice/src/main/res/values/strings.xml b/orbotservice/src/main/res/values/strings.xml
index 80f80ca3..78e527d4 100644
--- a/orbotservice/src/main/res/values/strings.xml
+++ b/orbotservice/src/main/res/values/strings.xml
@@ -25,5 +25,8 @@
<string name="kibibyte_per_second">KiB/s</string>
<string name="mebibyte_per_second">MiB/s</string>
+ <string name="snowflake_proxy_client_connected_msg">%s Your snowflake proxy helped someone circumvent censorship %s</string>
+
+
</resources>
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits