Skip to content

Commit

Permalink
add experimental snowflake proxy support
Browse files Browse the repository at this point in the history
  • Loading branch information
n8fr8 committed Feb 22, 2021
1 parent 75a6476 commit 63ea5b1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
9 changes: 9 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ private static boolean useIPtSnowflakeProxy() {
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);
Expand All @@ -361,7 +361,8 @@ private void startSnowflakeProxy() {
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.
Expand Down Expand Up @@ -1659,8 +1660,10 @@ public void run() {
IPtProxy.startObfs4Proxy("DEBUG", false, false);

if (useIPtSnowflakeProxy())
startSnowflakeProxy();
startSnowflakeClient();

if (Prefs.beSnowflakeProxy())
runSnowflakeProxy();

startTor();
replyWithStatus(mIntent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -61,6 +62,14 @@ public static String getDefaultLocale() {
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);
}
Expand Down

0 comments on commit 63ea5b1

Please sign in to comment.