Skip to content

Commit ef26de9

Browse files
authored
Merge pull request guardianproject#750 from syphyr/snowflake_logging
Add preference for snowflake logging
2 parents 9ed3960 + 45e21ea commit ef26de9

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<string name="ports_reachable_behind_a_restrictive_firewall">Ports reachable behind a restrictive firewall</string>
7070
<string name="enter_ports">Enter ports</string>
7171
<string name="enable_debug_log_to_output_must_use_adb_or_alogcat_to_view_">Enable debug log to output (must use adb or aLogcat to view)</string>
72+
<string name="enable_snowflake_log_to_output_must_use_adb_or_alogcat_to_view_">Enable snowflake log to output (must use adb or aLogcat to view)</string>
7273
<string name="project_home">Project Home:</string>
7374
<string name="orbot_url" translatable="false">https://orbot.app/</string>
7475
<string name="tor_url" translatable="false">Tor: https://www.torproject.org</string>
@@ -227,4 +228,4 @@
227228
<string name="btn_use_custom_bridge">Use Custom Bridge</string>
228229
<string name="msg_taking_too_long">This seems to be taking long</string>
229230
<string name="msg_try_something_else">Try something else</string>
230-
</resources>
231+
</resources>

app/src/main/res/xml/preferences.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@
230230
android:summary="@string/enable_debug_log_to_output_must_use_adb_or_alogcat_to_view_"
231231
android:title="Debug Log" />
232232

233-
234233
<CheckBoxPreference
235234
android:defaultValue="true"
236235
android:enabled="true"
@@ -257,6 +256,14 @@
257256
<!-- android:key="pref_be_a_snowflake_limit"-->
258257
<!-- android:title="@string/be_a_snowflake_title_limit"-->
259258
<!-- android:summary="@string/be_a_snowflake_desc_limit" />-->
259+
260+
<CheckBoxPreference
261+
android:defaultValue="false"
262+
android:enabled="true"
263+
android:key="pref_enable_snowflake_logging"
264+
android:summary="@string/enable_snowflake_log_to_output_must_use_adb_or_alogcat_to_view_"
265+
android:title="Snowflake Log" />
266+
260267
</PreferenceCategory>
261268

262269
</PreferenceScreen>

orbotservice/src/main/java/org/torproject/android/service/OrbotService.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,12 @@ private void startSnowflakeClientDomainFronting() {
339339
var stunServers = getCdnFront("snowflake-stun");
340340

341341
String logFile = null;
342-
File fileLog = new File(appCacheHome, LOG_SNOWFLAKE);
343-
if (fileLog.exists())
344-
fileLog.delete();
345-
logFile = fileLog.getAbsolutePath();
342+
if (Prefs.useSnowflakeLogging()) {
343+
File fileLog = new File(appCacheHome, LOG_SNOWFLAKE);
344+
if (fileLog.exists())
345+
fileLog.delete();
346+
logFile = fileLog.getAbsolutePath();
347+
}
346348

347349
var logToStateDir = false;
348350
var keepLocalAddresses = true;
@@ -360,10 +362,12 @@ private void startSnowflakeClientAmpRendezvous() {
360362
var ampCache =getCdnFront("snowflake-amp-cache");//"https://cdn.ampproject.org/";
361363

362364
String logFile = null;
363-
File fileLog = new File(appCacheHome, LOG_SNOWFLAKE);
364-
if (fileLog.exists())
365-
fileLog.delete();
366-
logFile = fileLog.getAbsolutePath();
365+
if (Prefs.useSnowflakeLogging()) {
366+
File fileLog = new File(appCacheHome, LOG_SNOWFLAKE);
367+
if (fileLog.exists())
368+
fileLog.delete();
369+
logFile = fileLog.getAbsolutePath();
370+
}
367371

368372
var logToStateDir = false;
369373
var keepLocalAddresses = true;

orbotservice/src/main/java/org/torproject/android/service/util/Prefs.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class Prefs {
1515
private final static String PREF_BRIDGES_LIST = "pref_bridges_list";
1616
private final static String PREF_DEFAULT_LOCALE = "pref_default_locale";
1717
private final static String PREF_ENABLE_LOGGING = "pref_enable_logging";
18+
private final static String PREF_ENABLE_SNOWFLAKE_LOGGING = "pref_enable_snowflake_logging";
1819
private final static String PREF_EXPANDED_NOTIFICATIONS = "pref_expanded_notifications";
1920
private final static String PREF_PERSIST_NOTIFICATIONS = "pref_persistent_notifications";
2021
private final static String PREF_START_ON_BOOT = "pref_start_boot";
@@ -111,6 +112,10 @@ public static boolean useDebugLogging() {
111112
return prefs.getBoolean(PREF_ENABLE_LOGGING, false);
112113
}
113114

115+
public static boolean useSnowflakeLogging() {
116+
return prefs.getBoolean(PREF_ENABLE_SNOWFLAKE_LOGGING, false);
117+
}
118+
114119
public static boolean allowBackgroundStarts() {
115120
return prefs.getBoolean(PREF_ALLOW_BACKGROUND_STARTS, true);
116121
}

0 commit comments

Comments
 (0)