summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2014-08-06 00:00:45 +0200
committerArne Schwabe <arne@rfc2549.org>2014-08-06 00:00:45 +0200
commit67e09d168a5ffaf98e3e72edd9001573c3d65db3 (patch)
treed1d80e987b3b14cf64d10f54a83332a80f74727a
parentde97cf5b801f2fda1d85563b14bd1e4956fec215 (diff)
Resort VPN preferences add mss fix
--HG-- rename : main/src/main/java/de/blinkt/openvpn/fragments/Settings_Obscure.java => main/src/main/java/de/blinkt/openvpn/fragments/Settings_Behaviour.java
-rw-r--r--main/src/main/java/de/blinkt/openvpn/VpnProfile.java12
-rw-r--r--main/src/main/java/de/blinkt/openvpn/activities/VPNPreferences.java4
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java13
-rw-r--r--main/src/main/java/de/blinkt/openvpn/fragments/Settings_Behaviour.java77
-rw-r--r--main/src/main/java/de/blinkt/openvpn/fragments/Settings_Obscure.java99
-rw-r--r--main/src/main/res/layout/viewconfig.xml1
-rwxr-xr-xmain/src/main/res/values/strings.xml6
-rw-r--r--main/src/main/res/xml/vpn_behaviour.xml24
-rw-r--r--main/src/main/res/xml/vpn_headers.xml5
-rw-r--r--main/src/main/res/xml/vpn_obscure.xml26
10 files changed, 198 insertions, 69 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/VpnProfile.java b/main/src/main/java/de/blinkt/openvpn/VpnProfile.java
index 14f0627b..679aa2fa 100644
--- a/main/src/main/java/de/blinkt/openvpn/VpnProfile.java
+++ b/main/src/main/java/de/blinkt/openvpn/VpnProfile.java
@@ -65,6 +65,7 @@ public class VpnProfile implements Serializable {
private static final String OVPNCONFIGFILE = "android.conf";
public static final int MAXLOGLEVEL = 4;
public static final int CURRENT_PROFILE_VERSION = 2;
+ public static final int DEFAULT_MSSFIX_SIZE = 1450;
public static String DEFAULT_DNS1 = "8.8.8.8";
public static String DEFAULT_DNS2 = "8.8.4.4";
@@ -143,6 +144,9 @@ public class VpnProfile implements Serializable {
private int mProfileVersion;
public String mExcludedRoutes;
public String mExcludedRoutesv6;
+ public int mMssFix =0; // -1 is default,
+
+
public VpnProfile(String name) {
mUuid = UUID.randomUUID();
@@ -182,6 +186,7 @@ public class VpnProfile implements Serializable {
mCheckRemoteCN = false;
mPersistTun = false;
mAllowLocalLAN = true;
+ mMssFix = 0;
}
public UUID getUUID() {
@@ -385,6 +390,13 @@ public class VpnProfile implements Serializable {
}
+ if (mMssFix !=0){
+ if (mMssFix!=1450)
+ cfg+=String.format("mssfix %d\n", mMssFix, Locale.US);
+ else
+ cfg+="mssfix\n";
+ }
+
if (mNobind)
cfg += "nobind\n";
diff --git a/main/src/main/java/de/blinkt/openvpn/activities/VPNPreferences.java b/main/src/main/java/de/blinkt/openvpn/activities/VPNPreferences.java
index 1ebb16b2..22b02c66 100644
--- a/main/src/main/java/de/blinkt/openvpn/activities/VPNPreferences.java
+++ b/main/src/main/java/de/blinkt/openvpn/activities/VPNPreferences.java
@@ -19,6 +19,7 @@ import de.blinkt.openvpn.VpnProfile;
import de.blinkt.openvpn.core.ProfileManager;
import de.blinkt.openvpn.fragments.Settings_Authentication;
import de.blinkt.openvpn.fragments.Settings_Basic;
+import de.blinkt.openvpn.fragments.Settings_Behaviour;
import de.blinkt.openvpn.fragments.Settings_IP;
import de.blinkt.openvpn.fragments.Settings_Obscure;
import de.blinkt.openvpn.fragments.Settings_Routing;
@@ -30,7 +31,8 @@ public class VPNPreferences extends PreferenceActivity {
static final Class validFragments[] = new Class[] {
Settings_Authentication.class, Settings_Basic.class, Settings_IP.class,
- Settings_Obscure.class, Settings_Routing.class, ShowConfigFragment.class
+ Settings_Obscure.class, Settings_Routing.class, ShowConfigFragment.class,
+ Settings_Behaviour.class
};
private String mProfileUUID;
diff --git a/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java b/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java
index d23b521f..9c3621e0 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java
@@ -432,6 +432,19 @@ public class ConfigParser {
throw new ConfigParseError("Sorry. Only tun mode is supported. See the FAQ for more detail");
}
+ Vector<String> mssfix = getOption("mssfix",0,1);
+
+ if (mssfix!=null) {
+ if (mssfix.size()>=2) {
+ try {
+ np.mMssFix=Integer.parseInt(mssfix.get(1));
+ } catch(NumberFormatException e) {
+ throw new ConfigParseError("Argument to --mssfix has to be an integer");
+ }
+ } else {
+ np.mMssFix = VpnProfile.DEFAULT_MSSFIX_SIZE;
+ }
+ }
Vector<String> mode =getOption("mode",1,1);
diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Behaviour.java b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Behaviour.java
new file mode 100644
index 00000000..73343037
--- /dev/null
+++ b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Behaviour.java
@@ -0,0 +1,77 @@
+package de.blinkt.openvpn.fragments;
+
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.EditTextPreference;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+
+import de.blinkt.openvpn.R;
+
+public class Settings_Behaviour extends OpenVpnPreferencesFragment implements OnPreferenceChangeListener {
+ private CheckBoxPreference mPersistent;
+ private ListPreference mConnectretrymax;
+ private EditTextPreference mConnectretry;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // Load the preferences from an XML resource
+ addPreferencesFromResource(R.xml.vpn_behaviour);
+
+ mPersistent = (CheckBoxPreference) findPreference("usePersistTun");
+ mConnectretrymax = (ListPreference) findPreference("connectretrymax");
+ mConnectretry = (EditTextPreference) findPreference("connectretry");
+
+ mConnectretrymax.setOnPreferenceChangeListener(this);
+ mConnectretrymax.setSummary("%s");
+
+ mConnectretry.setOnPreferenceChangeListener(this);
+
+
+ loadSettings();
+
+ }
+
+ protected void loadSettings() {
+ mPersistent.setChecked(mProfile.mPersistTun);
+
+ mConnectretrymax.setValue(mProfile.mConnectRetryMax);
+ onPreferenceChange(mConnectretrymax, mProfile.mConnectRetryMax);
+
+ mConnectretry.setText(mProfile.mConnectRetry);
+ onPreferenceChange(mConnectretry, mProfile.mConnectRetry);
+ }
+
+
+ protected void saveSettings() {
+ mProfile.mConnectRetryMax = mConnectretrymax.getValue();
+ mProfile.mPersistTun = mPersistent.isChecked();
+ mProfile.mConnectRetry = mConnectretry.getText();
+ }
+
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (preference == mConnectretrymax) {
+ if(newValue==null) {
+ newValue="5";
+ }
+ mConnectretrymax.setDefaultValue(newValue);
+
+ for(int i=0;i<mConnectretrymax.getEntryValues().length;i++){
+ if(mConnectretrymax.getEntryValues().equals(newValue))
+ mConnectretrymax.setSummary(mConnectretrymax.getEntries()[i]);
+ }
+
+ } else if (preference == mConnectretry) {
+ if(newValue==null || newValue=="")
+ newValue="5";
+ mConnectretry.setSummary(String.format("%s s" , newValue));
+ }
+
+ return true;
+ }
+
+} \ No newline at end of file
diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Obscure.java b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Obscure.java
index 0e8f1a02..4ea8f00c 100644
--- a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Obscure.java
+++ b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Obscure.java
@@ -3,22 +3,22 @@ package de.blinkt.openvpn.fragments;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
-import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
+import android.widget.Toast;
+
import de.blinkt.openvpn.R;
+import de.blinkt.openvpn.VpnProfile;
public class Settings_Obscure extends OpenVpnPreferencesFragment implements OnPreferenceChangeListener {
private CheckBoxPreference mUseRandomHostName;
private CheckBoxPreference mUseFloat;
private CheckBoxPreference mUseCustomConfig;
private EditTextPreference mCustomConfig;
- private ListPreference mLogverbosity;
- private CheckBoxPreference mPersistent;
- private ListPreference mConnectretrymax;
- private EditTextPreference mConnectretry;
+ private EditTextPreference mMssFixValue;
+ private CheckBoxPreference mMssFixCheckBox;
- @Override
+ @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
@@ -28,66 +28,63 @@ public class Settings_Obscure extends OpenVpnPreferencesFragment implements OnPr
mUseFloat = (CheckBoxPreference) findPreference("useFloat");
mUseCustomConfig = (CheckBoxPreference) findPreference("enableCustomOptions");
mCustomConfig = (EditTextPreference) findPreference("customOptions");
- mPersistent = (CheckBoxPreference) findPreference("usePersistTun");
- mConnectretrymax = (ListPreference) findPreference("connectretrymax");
- mConnectretry = (EditTextPreference) findPreference("connectretry");
-
- mConnectretrymax.setOnPreferenceChangeListener(this);
- mConnectretrymax.setSummary("%s");
-
- mConnectretry.setOnPreferenceChangeListener(this);
-
+ mMssFixCheckBox = (CheckBoxPreference) findPreference("mssFix");
+ mMssFixValue = (EditTextPreference) findPreference("mssFixValue");
+ mMssFixValue.setOnPreferenceChangeListener(this);
loadSettings();
}
-
- protected void loadSettings() {
- mUseRandomHostName.setChecked(mProfile.mUseRandomHostname);
- mUseFloat.setChecked(mProfile.mUseFloat);
- mUseCustomConfig.setChecked(mProfile.mUseCustomConfig);
- mCustomConfig.setText(mProfile.mCustomConfigOptions);
- mPersistent.setChecked(mProfile.mPersistTun);
-
- mConnectretrymax.setValue(mProfile.mConnectRetryMax);
- onPreferenceChange(mConnectretrymax, mProfile.mConnectRetryMax);
-
- mConnectretry.setText(mProfile.mConnectRetry);
- onPreferenceChange(mConnectretry, mProfile.mConnectRetry);
- }
+ protected void loadSettings() {
+ mUseRandomHostName.setChecked(mProfile.mUseRandomHostname);
+ mUseFloat.setChecked(mProfile.mUseFloat);
+ mUseCustomConfig.setChecked(mProfile.mUseCustomConfig);
+ mCustomConfig.setText(mProfile.mCustomConfigOptions);
+
+ if (mProfile.mMssFix == 0) {
+ mMssFixValue.setText(String.valueOf(VpnProfile.DEFAULT_MSSFIX_SIZE));
+ mMssFixCheckBox.setChecked(false);
+ setMssSummary(VpnProfile.DEFAULT_MSSFIX_SIZE);
+ } else {
+ mMssFixValue.setText(String.valueOf(mProfile.mMssFix));
+ mMssFixCheckBox.setChecked(true);
+ setMssSummary(mProfile.mMssFix);
+ }
+
+ }
- protected void saveSettings() {
+ private void setMssSummary(int value) {
+ mMssFixValue.setSummary(String.format("Configured MSS value: %d", value));
+ }
+
+ protected void saveSettings() {
mProfile.mUseRandomHostname = mUseRandomHostName.isChecked();
mProfile.mUseFloat = mUseFloat.isChecked();
mProfile.mUseCustomConfig = mUseCustomConfig.isChecked();
mProfile.mCustomConfigOptions = mCustomConfig.getText();
- mProfile.mConnectRetryMax = mConnectretrymax.getValue();
- mProfile.mPersistTun = mPersistent.isChecked();
- mProfile.mConnectRetry = mConnectretry.getText();
+ if (mMssFixCheckBox.isChecked())
+ mProfile.mMssFix=Integer.parseInt(mMssFixValue.getText());
+ else
+ mProfile.mMssFix=0;
+
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
- if (preference == mConnectretrymax) {
- if(newValue==null) {
- newValue="5";
- }
- mConnectretrymax.setDefaultValue(newValue);
-
- for(int i=0;i<mConnectretrymax.getEntryValues().length;i++){
- if(mConnectretrymax.getEntryValues().equals(newValue))
- mConnectretrymax.setSummary(mConnectretrymax.getEntries()[i]);
- }
-
- } else if (preference == mConnectretry) {
- if(newValue==null || newValue=="")
- newValue="5";
- mConnectretry.setSummary(String.format("%s s" , newValue));
- }
-
- return true;
+ if (preference.getKey().equals("mssFixValue"))
+ try {
+ int v = Integer.parseInt((String) newValue);
+ if (v < 0 || v > 9000)
+ throw new NumberFormatException("mssfix value");
+ setMssSummary(v);
+
+ } catch(NumberFormatException e) {
+ Toast.makeText(getActivity(), R.string.mssfix_invalid_value, Toast.LENGTH_LONG).show();
+ return false;
+ }
+ return true;
}
} \ No newline at end of file
diff --git a/main/src/main/res/layout/viewconfig.xml b/main/src/main/res/layout/viewconfig.xml
index 5ae34ef0..68107972 100644
--- a/main/src/main/res/layout/viewconfig.xml
+++ b/main/src/main/res/layout/viewconfig.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:padding="@dimen/stdpadding"
android:layout_width="match_parent"
android:layout_height="match_parent" >
diff --git a/main/src/main/res/values/strings.xml b/main/src/main/res/values/strings.xml
index a054d16b..ad46dd97 100755
--- a/main/src/main/res/values/strings.xml
+++ b/main/src/main/res/values/strings.xml
@@ -254,7 +254,7 @@
<string name="start_vpn_ticker">Connecting to VPN %s</string>
<string name="jelly_keystore_alphanumeric_bug">Some versions of Android 4.1 have problems if the name of the keystore certificate contains non alphanumeric characters (like spaces, underscores or dashes). Try to reimport the certificate without special characters</string>
<string name="encryption_cipher">Encryption cipher</string>
- <string name="packet_auth">Packets authentication</string>
+ <string name="packet_auth">Packet authentication</string>
<string name="auth_dialog_title">Enter packet authentication method</string>
<string name="mobile_info_extended">Running on %1$s (%2$s) %3$s, Android API %4$d, version %5$s, %6$s</string>
<string name="built_by">built by %s</string>
@@ -319,4 +319,8 @@
<string name="openvpn_is_no_free_vpn">To use this app you need a VPN provider/VPN gateway supporting OpenVPN (often provided by your employer). Check out http://community.openvpn.net/ for more information on OpenVPN and how to setup your own OpenVPN server.</string>
<string name="import_log">Import log:</string>
<string name="ip_looks_like_subnet">Vpn topology \"%3$s\" specified but ifconfig %1$s %2$s looks more like an IP address with a network mask. Assuming \"subnet\" topology.</string>
+ <string name="mssfix_invalid_value">mssfix value has to be a integer between 0 and 9000</string>
+ <string name="mssfix_value_dialog">Announce to TCP sessions running over the tunnel that they should limit their send packet sizes such that after OpenVPN has encapsulated them, the resulting UDP packet size that OpenVPN sends to its peer will not exceed this number of bytes. (default is 1450)</string>
+ <string name="mssfix_checkbox">Override MSS value of TCP payload</string>
+ <string name="mssfix_dialogtitle">Set MSS of TCP payload</string>
</resources>
diff --git a/main/src/main/res/xml/vpn_behaviour.xml b/main/src/main/res/xml/vpn_behaviour.xml
new file mode 100644
index 00000000..106e90da
--- /dev/null
+++ b/main/src/main/res/xml/vpn_behaviour.xml
@@ -0,0 +1,24 @@
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ android:title="Client behaviour">
+
+ <CheckBoxPreference
+ android:key="usePersistTun"
+ android:summary="@string/persisttun_summary"
+ android:title="@string/persistent_tun_title" />
+
+
+ <PreferenceCategory android:title="@string/reconnection_settings">
+ <ListPreference
+ android:entries="@array/crm_entries"
+ android:entryValues="@array/crm_values"
+ android:key="connectretrymax"
+ android:persistent="false"
+ android:title="@string/connection_retries" />
+
+ <EditTextPreference
+ android:dialogMessage="@string/connectretrymessage"
+ android:key="connectretry"
+ android:persistent="false"
+ android:title="@string/connectretrywait" />
+ </PreferenceCategory>
+</PreferenceScreen> \ No newline at end of file
diff --git a/main/src/main/res/xml/vpn_headers.xml b/main/src/main/res/xml/vpn_headers.xml
index 7f2a97d9..3877306f 100644
--- a/main/src/main/res/xml/vpn_headers.xml
+++ b/main/src/main/res/xml/vpn_headers.xml
@@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <header
+ android:fragment="de.blinkt.openvpn.fragments.Settings_Behaviour"
+ android:title="Client Behaviour"
+ />
<header
android:id="@+id/basicsettingsid"
android:fragment="de.blinkt.openvpn.fragments.Settings_Basic"
diff --git a/main/src/main/res/xml/vpn_obscure.xml b/main/src/main/res/xml/vpn_obscure.xml
index 6172dacb..10436aa6 100644
--- a/main/src/main/res/xml/vpn_obscure.xml
+++ b/main/src/main/res/xml/vpn_obscure.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="Obscure Settings" >
+ android:title="Obscure Settings">
<CheckBoxPreference
@@ -13,26 +13,20 @@
android:persistent="false"
android:summary="@string/float_summary"
android:title="@string/float_title" />
- <CheckBoxPreference
- android:key="usePersistTun"
- android:summary="@string/persisttun_summary"
- android:title="@string/persistent_tun_title" />
- <PreferenceCategory android:title="@string/reconnection_settings" >
- <ListPreference
- android:entries="@array/crm_entries"
- android:entryValues="@array/crm_values"
- android:key="connectretrymax"
+ <PreferenceCategory android:title="Payload options">
+ <CheckBoxPreference
+ android:key="mssFix"
android:persistent="false"
- android:title="@string/connection_retries" />
-
+ android:title="@string/mssfix_checkbox" />
<EditTextPreference
- android:dialogMessage="@string/connectretrymessage"
- android:key="connectretry"
+ android:dependency="mssFix"
+ android:dialogMessage="@string/mssfix_value_dialog"
+ android:key="mssFixValue"
android:persistent="false"
- android:title="@string/connectretrywait" />
+ android:title="@string/mssfix_dialogtitle" />
</PreferenceCategory>
- <PreferenceCategory android:title="@string/custom_config_title" >
+ <PreferenceCategory android:title="@string/custom_config_title">
<CheckBoxPreference
android:key="enableCustomOptions"
android:persistent="false"