Added option to disable HTTP redirecting

This commit is contained in:
M66B 2023-12-10 09:24:24 +01:00
parent b10ea057aa
commit 0c87e0f9cf
4 changed files with 27 additions and 3 deletions

View File

@ -723,6 +723,7 @@ public class ConnectionHelper {
// https://support.google.com/faqs/answer/7188426
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean open_safe = prefs.getBoolean("open_safe", false);
boolean http_redirect = prefs.getBoolean("http_redirect", true);
int redirects = 0;
while (true) {
@ -752,7 +753,7 @@ public class ConnectionHelper {
try {
int status = urlConnection.getResponseCode();
if (!open_safe &&
if (http_redirect &&
(status == HttpURLConnection.HTTP_MOVED_PERM ||
status == HttpURLConnection.HTTP_MOVED_TEMP ||
status == HttpURLConnection.HTTP_SEE_OTHER ||

View File

@ -99,6 +99,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
private SwitchCompat swSslHardenStrict;
private SwitchCompat swCertStrict;
private SwitchCompat swOpenSafe;
private SwitchCompat swHttpRedirect;
private SwitchCompat swBouncyCastle;
private SwitchCompat swFipsMode;
private ImageButton ibBouncyCastle;
@ -120,7 +121,8 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
"download_headers", "download_eml", "download_plain",
"require_validated", "require_validated_captive", "vpn_only",
"timeout", "prefer_ip4", "bind_socket", "standalone_vpn", "tcp_keep_alive",
"ssl_harden", "ssl_harden_strict", "cert_strict", "open_safe", "bouncy_castle", "bc_fips"
"ssl_harden", "ssl_harden_strict", "cert_strict", "open_safe", "http_redirect",
"bouncy_castle", "bc_fips"
};
@Override
@ -154,6 +156,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
swSslHardenStrict = view.findViewById(R.id.swSslHardenStrict);
swCertStrict = view.findViewById(R.id.swCertStrict);
swOpenSafe = view.findViewById(R.id.swOpenSafe);
swHttpRedirect = view.findViewById(R.id.swHttpRedirect);
swBouncyCastle = view.findViewById(R.id.swBouncyCastle);
swFipsMode = view.findViewById(R.id.swFipsMode);
ibBouncyCastle = view.findViewById(R.id.ibBouncyCastle);
@ -361,6 +364,13 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
}
});
swHttpRedirect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("http_redirect", checked).apply();
}
});
swBouncyCastle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -660,6 +670,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
swSslHardenStrict.setEnabled(swSslHarden.isChecked());
swCertStrict.setChecked(prefs.getBoolean("cert_strict", true));
swOpenSafe.setChecked(prefs.getBoolean("open_safe", false));
swHttpRedirect.setChecked(prefs.getBoolean("http_redirect", true));
swBouncyCastle.setChecked(prefs.getBoolean("bouncy_castle", false));
swFipsMode.setChecked(prefs.getBoolean("bc_fips", false));
swFipsMode.setEnabled(swBouncyCastle.isChecked());

View File

@ -519,6 +519,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swOpenSafe" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swHttpRedirect"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_http_redirect"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOpenSafeHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swBouncyCastle"
android:layout_width="0dp"
@ -527,7 +538,7 @@
android:text="@string/title_advanced_bouncy_castle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOpenSafeHint"
app:layout_constraintTop_toBottomOf="@id/swHttpRedirect"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

View File

@ -519,6 +519,7 @@
<string name="title_advanced_ssl_harden_strict">Require TLS 1.3</string>
<string name="title_advanced_cert_strict">Strict certificate checking</string>
<string name="title_advanced_open_safe">Open secure connections only</string>
<string name="title_advanced_http_redirect">Allow redirecting HTTP connections</string>
<string name="title_advanced_bouncy_castle">Use Bouncy Castle\'s secure socket provider (JSSE)</string>
<string name="title_advanced_fips_mode" translatable="false">FIPS mode</string>
<string name="title_advanced_manage_connectivity">Manage connectivity</string>