Add ability to launch mitm wizard manually

This commit is contained in:
emanuele-f 2022-09-01 23:22:35 +02:00
parent 20b755848c
commit f3bb3543c8
3 changed files with 25 additions and 6 deletions

View File

@ -134,6 +134,7 @@ public class SettingsActivity extends BaseActivity implements PreferenceFragment
private DropDownPreference mIpMode;
private DropDownPreference mCapInterface;
private Preference mVpnExceptions;
private Preference mMitmWizard;
private SwitchPreference mMalwareDetectionEnabled;
private Billing mIab;
private boolean mHasStartedMitmWizard;
@ -157,7 +158,7 @@ public class SettingsActivity extends BaseActivity implements PreferenceFragment
fullPayloadHideShow(mTlsDecryption.isChecked());
socks5ProxyHideShow(mTlsDecryption.isChecked(), mSocks5Enabled.isChecked(), rootCaptureEnabled());
mBlockQuic.setVisible(mTlsDecryption.isChecked());
mBlockQuic.setVisible(mTlsDecryption.isChecked() && !rootCaptureEnabled());
rootCaptureHideShow(rootCaptureEnabled());
Intent intent = requireActivity().getIntent();
@ -288,6 +289,9 @@ public class SettingsActivity extends BaseActivity implements PreferenceFragment
boolean enabled = (boolean) newValue;
Context ctx = requireContext();
if(checkDecrpytionWithRoot(rootCaptureEnabled(), (boolean) newValue))
return false;
if(enabled && MitmAddon.needsSetup(ctx)) {
mHasStartedMitmWizard = true;
Intent intent = new Intent(ctx, MitmSetupWizard.class);
@ -295,16 +299,23 @@ public class SettingsActivity extends BaseActivity implements PreferenceFragment
return false;
}
checkDecrpytionWithRoot(rootCaptureEnabled(), (boolean) newValue);
fullPayloadHideShow((boolean) newValue);
mBlockQuic.setVisible((boolean) newValue);
mBlockQuic.setVisible(((boolean) newValue) && !rootCaptureEnabled());
mMitmWizard.setVisible((boolean) newValue);
socks5ProxyHideShow((boolean) newValue, mSocks5Enabled.isChecked(), rootCaptureEnabled());
return true;
});
mFullPayloadEnabled = requirePreference(Prefs.PREF_FULL_PAYLOAD);
mBlockQuic = requirePreference(Prefs.PREF_BLOCK_QUIC);
mMitmWizard = requirePreference("mitm_setup_wizard");
mMitmWizard.setVisible(mTlsDecryption.isChecked());
mMitmWizard.setOnPreferenceClickListener(preference -> {
mHasStartedMitmWizard = true;
Intent intent = new Intent(requireContext(), MitmSetupWizard.class);
startActivity(intent);
return true;
});
mSocks5Enabled = requirePreference(Prefs.PREF_SOCKS5_ENABLED_KEY);
mSocks5Enabled.setOnPreferenceChangeListener((preference, newValue) -> {
@ -415,9 +426,9 @@ public class SettingsActivity extends BaseActivity implements PreferenceFragment
mVpnExceptions.setVisible(!enabled);
}
private void checkDecrpytionWithRoot(boolean rootEnabled, boolean tlsDecryption) {
private boolean checkDecrpytionWithRoot(boolean rootEnabled, boolean tlsDecryption) {
if(mRootDecryptionNoticeShown || !rootEnabled || !tlsDecryption)
return;
return false;
new AlertDialog.Builder(requireContext())
.setMessage(R.string.tls_decryption_with_root_msg)
@ -425,6 +436,7 @@ public class SettingsActivity extends BaseActivity implements PreferenceFragment
.show();
mRootDecryptionNoticeShown = true;
return true;
}
}
}

View File

@ -411,4 +411,5 @@
<string name="paid_feature">Paid feature</string>
<string name="firewall_purchase_msg">Buy the <i>%1$s</i> feature to start blocking connections</string>
<string name="mitm_skip_notice">The mitm certificate does not seem to be installed. If you proceed, decryption may fail</string>
<string name="mitm_wizard_description">Configure the device for the TLS decryption</string>
</resources>

View File

@ -66,6 +66,12 @@
app:summary="@string/tls_decryption_summary"
app:defaultValue="false" />
<Preference
app:key="mitm_setup_wizard"
app:title="@string/mitm_setup_wizard"
app:summary="@string/mitm_wizard_description"
app:iconSpaceReserved="false" />
<SwitchPreference
app:key="block_quic"
app:title="@string/block_quick"