Skip to content

Commit 75fc6ed

Browse files
committed
feat: add beast mode UI toggle, log messages, and lightning bolt icon
1 parent a535f68 commit 75fc6ed

8 files changed

Lines changed: 67 additions & 2 deletions

app/src/main/java/com/psiphon3/OptionsTabFragment.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ private void updateMoreSettingsFromPreferences() {
458458
new SharedPreferencesImport(requireContext(), prefName, getString(R.string.disableTimeoutsPreference), getString(R.string.disableTimeoutsPreference)),
459459
new SharedPreferencesImport(requireContext(), prefName, getString(R.string.nfcBumpPreference), getString(R.string.nfcBumpPreference)),
460460
new SharedPreferencesImport(requireContext(), prefName, getString(R.string.protocolSelectionPreference), getString(R.string.protocolSelectionPreference)),
461+
new SharedPreferencesImport(requireContext(), prefName, getString(R.string.beastModePreference), getString(R.string.beastModePreference)),
461462
new SharedPreferencesImport(requireContext(), prefName, getString(R.string.conduitModePreference), getString(R.string.conduitModePreference)),
462463
new SharedPreferencesImport(requireContext(), prefName, getString(R.string.conduitTimeoutPreference), getString(R.string.conduitTimeoutPreference)),
463464
new SharedPreferencesImport(requireContext(), prefName, getString(R.string.rejectCensoredCountryProxiesPreference), getString(R.string.rejectCensoredCountryProxiesPreference)),

app/src/main/java/com/psiphon3/psiphonlibrary/MoreOptionsPreferenceActivity.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
124124
protocolSelectionList.setValue(protocolValue);
125125
updateProtocolSelectionSummary(protocolSelectionList, protocolValue);
126126

127+
// Beast mode (aggressive establishment)
128+
SwitchPreference beastModeSwitch =
129+
(SwitchPreference) preferences.findPreference(getString(R.string.beastModePreference));
130+
if (beastModeSwitch != null) {
131+
beastModeSwitch.setChecked(
132+
preferenceGetter.getBoolean(getString(R.string.beastModePreference), true));
133+
}
134+
127135
// Set initial conduit category visibility based on current protocol
128136
PreferenceCategory conduitCategory =
129137
(PreferenceCategory) preferences.findPreference("conduitCategory");

app/src/main/java/com/psiphon3/psiphonlibrary/TunnelManager.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ static class Config {
153153
String egressRegion = PsiphonConstants.REGION_CODE_ANY;
154154
boolean disableTimeouts = false;
155155
String protocolSelection = "auto"; // "auto", "conduit", or "direct"
156+
boolean beastMode = true; // aggressive establishment: try all protocols on all servers
156157
String conduitMode = "auto"; // "auto", "shirokhorshid", or "public"
157158
int conduitTimeoutSeconds = 180; // fallback timeout for auto conduit mode
158159
boolean rejectCensoredCountryProxies = true; // block conduits in censored countries
@@ -567,6 +568,9 @@ private Single<Config> getTunnelConfigSingle() {
567568
tunnelConfig.protocolSelection = multiProcessPreferences
568569
.getString(getContext().getString(R.string.protocolSelectionPreference),
569570
"auto");
571+
tunnelConfig.beastMode = multiProcessPreferences
572+
.getBoolean(getContext().getString(R.string.beastModePreference),
573+
true);
570574
tunnelConfig.conduitMode = multiProcessPreferences
571575
.getString(getContext().getString(R.string.conduitModePreference),
572576
"auto");
@@ -1578,6 +1582,12 @@ public static String buildTunnelCoreConfig(
15781582
}
15791583
// For "auto" mode, don't set LimitTunnelProtocols - let Psiphon choose
15801584

1585+
// Beast mode: aggressive establishment, try all protocols on all servers
1586+
if (tunnelConfig.beastMode) {
1587+
json.put("AggressiveEstablishment", true);
1588+
MyLog.i("BeastMode", "enabled", true);
1589+
}
1590+
15811591
json.put("EmitServerAlerts", true);
15821592

15831593
JSONArray clientFeaturesJsonArray = new JSONArray();
@@ -1704,6 +1714,25 @@ else if (message.contains("tunnel connected (protocol:")) {
17041714
}
17051715
}
17061716

1717+
// Beast mode notices
1718+
if (message.contains("beast mode active (workers:")) {
1719+
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("\\(workers: (\\d+)\\)");
1720+
java.util.regex.Matcher matcher = pattern.matcher(message);
1721+
if (matcher.find()) {
1722+
String workers = matcher.group(1);
1723+
MyLog.i(R.string.beast_mode_active, MyLog.Sensitivity.NOT_SENSITIVE, workers);
1724+
}
1725+
}
1726+
else if (message.contains("beast mode connected (attempts:")) {
1727+
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("\\(attempts: (\\d+), servers: (\\d+)\\)");
1728+
java.util.regex.Matcher matcher = pattern.matcher(message);
1729+
if (matcher.find()) {
1730+
String attempts = matcher.group(1);
1731+
String servers = matcher.group(2);
1732+
MyLog.i(R.string.beast_mode_connected, MyLog.Sensitivity.NOT_SENSITIVE, attempts, servers);
1733+
}
1734+
}
1735+
17071736
// Inproxy connection diagnostic messages
17081737
// These show the phase-by-phase progress of each relay attempt.
17091738
// Note: PsiphonTunnel.java dispatches diagnostic notices via two
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="960"
5+
android:viewportHeight="960">
6+
<path
7+
android:fillColor="@android:color/white"
8+
android:pathData="M400,880L480,600L280,600L560,80L480,360L680,360L400,880Z"/>
9+
</vector>

app/src/main/res/values-fa/psiphon_android_library_strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@
186186
<string name="conduit_proxy_connected">تونل از طریق Conduit متصل شد (پروتکل: %1$s، کشور: %2$s)</string>
187187
<string name="conduit_proxy_connected_no_country">تونل از طریق Conduit متصل شد (پروتکل: %s)</string>
188188
<string name="conduit_proxy_trying">در حال تلاش برای اتصال به رله Conduit (کشور: %s)</string>
189+
<string name="beast_mode_active">حالت قدرتمند فعال — آزمایش همه پروتکل‌ها (%s کارگر)</string>
190+
<string name="beast_mode_connected">حالت قدرتمند پس از %1$s تلاش در %2$s سرور متصل شد</string>
189191

190192
<!-- Protocol selection preferences -->
191193
<string name="protocolSelectionPreferenceTitle">پروتکل اتصال</string>
@@ -196,6 +198,9 @@
196198
<string name="protocol_auto">خودکار (پیشنهادی)</string>
197199
<string name="protocol_conduit">رله‌های Conduit</string>
198200
<string name="protocol_direct">اتصال مستقیم</string>
201+
<string name="beastModePreferenceTitle">حالت قدرتمند</string>
202+
<string name="beastModePreferenceSummaryOn">اتصال تهاجمی: همه پروتکل‌ها را روی هر سرور امتحان می‌کند</string>
203+
<string name="beastModePreferenceSummaryOff">اتصال عادی: پروتکل‌ها را به‌صورت تصادفی برای هر سرور انتخاب می‌کند</string>
199204

200205
<!-- Reject censored country proxies -->
201206
<string name="rejectCensoredCountryProxiesPreferenceTitle">رد پروکسی‌های کشورهای سانسورشده</string>

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,15 @@
9898
<string name="protocolSelectionSummaryDirect">Direct - Connect directly to Psiphon servers</string>
9999
<string name="protocol_auto">Auto (Recommended)</string>
100100
<string name="protocol_conduit">Conduit Relays</string>
101-
<string name="protocol_direct">Direct Connection</string>
101+
<string name="protocol_direct">Direct Connection</string>
102+
<string name="beastModePreferenceTitle">Beast Mode</string>
103+
<string name="beastModePreferenceSummaryOn">Aggressive connection: tries all protocols on every server</string>
104+
<string name="beastModePreferenceSummaryOff">Normal connection: randomly selects protocols per server</string>
102105
<string name="rejectCensoredCountryProxiesPreferenceTitle">Reject proxies in censored countries</string>
103106
<string name="rejectCensoredCountryProxiesPreferenceSummary">Block Conduit stations located in Iran, China, Russia, and other censored countries</string>
104-
<string name="conduit_proxy_trying">Trying Conduit relay (country: %s)</string>
107+
<string name="conduit_proxy_trying">Trying Conduit relay (country: %s)</string>
108+
<string name="beast_mode_active">Beast Mode active — testing all protocols (%s workers)</string>
109+
<string name="beast_mode_connected">Beast Mode connected after %1$s attempts across %2$s servers</string>
105110
<string name="conduit_proxy_connected">Tunnel connected via Conduit (protocol: %1$s, country: %2$s)</string>
106111
<string name="conduit_proxy_connected_no_country">Tunnel connected via Conduit (protocol: %s)</string>
107112
<string name="conduit_diag">[Conduit] %s</string>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<string name="disableTimeoutsPreference">disableTimeoutsPreference</string>
3434
<string name="forceConduitPreference" translatable="false">forceConduitPreference</string>
3535
<string name="protocolSelectionPreference" translatable="false">protocolSelectionPreference</string>
36+
<string name="beastModePreference" translatable="false">beastModePreference</string>
3637
<string name="rejectCensoredCountryProxiesPreference" translatable="false">rejectCensoredCountryProxiesPreference</string>
3738
<string name="unsafeTrafficAlertsPreference" translatable="false">unsafeTrafficAlertsPreference</string>
3839
<string name="egressRegionPreference">egressRegionPreference</string>

app/src/main/res/xml/more_options_preferences.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@
6161
android:entries="@array/protocol_selection_entries"
6262
android:entryValues="@array/protocol_selection_values"
6363
android:defaultValue="auto" />
64+
<SwitchPreference
65+
android:icon="@drawable/ic_beast_mode"
66+
android:key="@string/beastModePreference"
67+
android:title="@string/beastModePreferenceTitle"
68+
android:summaryOn="@string/beastModePreferenceSummaryOn"
69+
android:summaryOff="@string/beastModePreferenceSummaryOff"
70+
android:defaultValue="true" />
6471
</PreferenceCategory>
6572
<PreferenceCategory
6673
android:key="conduitCategory"

0 commit comments

Comments
 (0)