Skip to content

Commit

Permalink
Add preference for snowflake logging
Browse files Browse the repository at this point in the history
  • Loading branch information
syphyr committed Oct 23, 2022
1 parent 2f341f0 commit 45e21ea
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<string name="ports_reachable_behind_a_restrictive_firewall">Ports reachable behind a restrictive firewall</string>
<string name="enter_ports">Enter ports</string>
<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>
<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>
<string name="project_home">Project Home:</string>
<string name="orbot_url" translatable="false">https://orbot.app/</string>
<string name="tor_url" translatable="false">Tor: https://www.torproject.org</string>
Expand Down Expand Up @@ -227,4 +228,4 @@
<string name="btn_use_custom_bridge">Use Custom Bridge</string>
<string name="msg_taking_too_long">This seems to be taking long</string>
<string name="msg_try_something_else">Try something else</string>
</resources>
</resources>
9 changes: 8 additions & 1 deletion app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@
android:summary="@string/enable_debug_log_to_output_must_use_adb_or_alogcat_to_view_"
android:title="Debug Log" />


<CheckBoxPreference
android:defaultValue="true"
android:enabled="true"
Expand All @@ -257,6 +256,14 @@
<!-- android:key="pref_be_a_snowflake_limit"-->
<!-- android:title="@string/be_a_snowflake_title_limit"-->
<!-- android:summary="@string/be_a_snowflake_desc_limit" />-->

<CheckBoxPreference
android:defaultValue="false"
android:enabled="true"
android:key="pref_enable_snowflake_logging"
android:summary="@string/enable_snowflake_log_to_output_must_use_adb_or_alogcat_to_view_"
android:title="Snowflake Log" />

</PreferenceCategory>

</PreferenceScreen>
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,12 @@ private void startSnowflakeClientDomainFronting() {
var stunServers = getCdnFront("snowflake-stun");

String logFile = null;
File fileLog = new File(appCacheHome, LOG_SNOWFLAKE);
if (fileLog.exists())
fileLog.delete();
logFile = fileLog.getAbsolutePath();
if (Prefs.useSnowflakeLogging()) {
File fileLog = new File(appCacheHome, LOG_SNOWFLAKE);
if (fileLog.exists())
fileLog.delete();
logFile = fileLog.getAbsolutePath();
}

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

String logFile = null;
File fileLog = new File(appCacheHome, LOG_SNOWFLAKE);
if (fileLog.exists())
fileLog.delete();
logFile = fileLog.getAbsolutePath();
if (Prefs.useSnowflakeLogging()) {
File fileLog = new File(appCacheHome, LOG_SNOWFLAKE);
if (fileLog.exists())
fileLog.delete();
logFile = fileLog.getAbsolutePath();
}

var logToStateDir = false;
var keepLocalAddresses = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class Prefs {
private final static String PREF_BRIDGES_LIST = "pref_bridges_list";
private final static String PREF_DEFAULT_LOCALE = "pref_default_locale";
private final static String PREF_ENABLE_LOGGING = "pref_enable_logging";
private final static String PREF_ENABLE_SNOWFLAKE_LOGGING = "pref_enable_snowflake_logging";
private final static String PREF_EXPANDED_NOTIFICATIONS = "pref_expanded_notifications";
private final static String PREF_PERSIST_NOTIFICATIONS = "pref_persistent_notifications";
private final static String PREF_START_ON_BOOT = "pref_start_boot";
Expand Down Expand Up @@ -104,6 +105,10 @@ public static boolean useDebugLogging() {
return prefs.getBoolean(PREF_ENABLE_LOGGING, false);
}

public static boolean useSnowflakeLogging() {
return prefs.getBoolean(PREF_ENABLE_SNOWFLAKE_LOGGING, false);
}

public static boolean allowBackgroundStarts() {
return prefs.getBoolean(PREF_ALLOW_BACKGROUND_STARTS, true);
}
Expand Down

0 comments on commit 45e21ea

Please sign in to comment.