Added option to disable HTTP redirecting

pull/214/head
M66B 2 years ago
parent b10ea057aa
commit 0c87e0f9cf

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

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

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

@ -519,6 +519,7 @@
<string name="title_advanced_ssl_harden_strict">Require TLS 1.3</string> <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_cert_strict">Strict certificate checking</string>
<string name="title_advanced_open_safe">Open secure connections only</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_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_fips_mode" translatable="false">FIPS mode</string>
<string name="title_advanced_manage_connectivity">Manage connectivity</string> <string name="title_advanced_manage_connectivity">Manage connectivity</string>

Loading…
Cancel
Save