diff options
| -rw-r--r-- | res/values/arrays.xml | 8 | ||||
| -rwxr-xr-x | res/values/strings.xml | 4 | ||||
| -rw-r--r-- | res/values/untranslatable.xml | 10 | ||||
| -rw-r--r-- | res/xml/vpn_obscure.xml | 14 | ||||
| -rw-r--r-- | src/de/blinkt/openvpn/Settings_Obscure.java | 36 | ||||
| -rw-r--r-- | src/de/blinkt/openvpn/VpnProfile.java | 25 | 
6 files changed, 86 insertions, 11 deletions
| diff --git a/res/values/arrays.xml b/res/values/arrays.xml index b88e975e..4af8f90f 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -24,5 +24,11 @@          <item>4</item>          <item>5 - Debug logging</item>      </string-array> - +    <string-array name="crm_entries" translatable="false"> +        <item>No reconnection retries</item> +        <item>One reconnection retry</item> +        <item>Five reconnection retries</item> +        <item>Fifty reconnection retries</item> +        <item>Unlimited reconnection retries</item> +    </string-array>  </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index 74d05fb5..ff0c592c 100755 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -232,5 +232,9 @@      <string name="baterry_consumption">In my personal tests the main reason for high battery consumption of OpenVPN are the keepalive packets. Most OpenVPN servers have a configuration directive like \'keepalive 10 60\' which translates to a keepalive packet from client to server and server to client every ten seconds. <p> While these packets are small and do not use much traffic, they keep the mobile radio network busy and increase the energy consumption. <p> This keepalive setting cannot be changed on the client. Only the system administrator of the OpenVPN can change the setting. <p> Unfortunatly using a keepalive larger than 60 seconds with udp has problems with some NAT gateways which terminate the state for a connnection after a short timeout (60s in my tests). Using TCP with long keepalive timeout works but has the TCP over TCP problem. (See <a href=\"http://sites.inka.de/bigred/devel/tcp-tcp.html\">Why TCP Over TCP Is A Bad Ide</a>)</string>      <string name="faq_tethering">The Android Tethering feature (over WiFi, USB or Bluetooth) and the VPNService API (used by this program) do not work together. For more details see the <a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=34\">issue #34</a></string>      <string name="vpn_tethering_title">VPN and Tethering</string> +    <string name="connection_retries">Connection retries</string> +    <string name="reconnection_settings">Reconnection settings</string> +    <string name="connectretrymessage">Number of seconds to wait between connection attempts.</string> +    <string name="connectretrywait">Seconds between connections</string>  </resources>
\ No newline at end of file diff --git a/res/values/untranslatable.xml b/res/values/untranslatable.xml index cb5bea14..d5a30a03 100644 --- a/res/values/untranslatable.xml +++ b/res/values/untranslatable.xml @@ -31,5 +31,11 @@          <item>4</item>          <item>5</item>      </string-array> - -</resources> +    <string-array name="crm_values" translatable="false"> +        <item>1</item> +        <item>2</item> +        <item>5</item> +        <item>50</item> +        <item>-1</item> +    </string-array> +    </resources> diff --git a/res/xml/vpn_obscure.xml b/res/xml/vpn_obscure.xml index c99e039c..ecdd4e29 100644 --- a/res/xml/vpn_obscure.xml +++ b/res/xml/vpn_obscure.xml @@ -24,6 +24,20 @@          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>      <PreferenceCategory android:title="@string/custom_config_title" >          <CheckBoxPreference              android:key="enableCustomOptions" diff --git a/src/de/blinkt/openvpn/Settings_Obscure.java b/src/de/blinkt/openvpn/Settings_Obscure.java index c93944fa..160dbe0c 100644 --- a/src/de/blinkt/openvpn/Settings_Obscure.java +++ b/src/de/blinkt/openvpn/Settings_Obscure.java @@ -14,13 +14,15 @@ public class Settings_Obscure extends OpenVpnPreferencesFragment implements OnPr  	private EditTextPreference mCustomConfig;  	private ListPreference mLogverbosity;  	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_obscure); -		 +  		mUseRandomHostName = (CheckBoxPreference) findPreference("useRandomHostname");  		mUseFloat = (CheckBoxPreference) findPreference("useFloat"); @@ -28,10 +30,17 @@ public class Settings_Obscure extends OpenVpnPreferencesFragment implements OnPr  		mCustomConfig = (EditTextPreference) findPreference("customOptions");  		mLogverbosity = (ListPreference) findPreference("verblevel");  		mPersistent = (CheckBoxPreference) findPreference("usePersistTun"); -				 +		mConnectretrymax = (ListPreference) findPreference("connectretrymax"); +		mConnectretry = (EditTextPreference) findPreference("connectretry"); +  		mLogverbosity.setOnPreferenceChangeListener(this);  		mLogverbosity.setSummary("%s"); +		mConnectretrymax.setOnPreferenceChangeListener(this); +		mConnectretrymax.setSummary("%s"); +		 +		mConnectretry.setOnPreferenceChangeListener(this); +		  		loadSettings(); @@ -46,6 +55,12 @@ public class Settings_Obscure extends OpenVpnPreferencesFragment implements OnPr  		mLogverbosity.setValue(mProfile.mVerb);  		onPreferenceChange(mLogverbosity, mProfile.mVerb); +		 +		mConnectretrymax.setValue(mProfile.mConnectRetryMax); +		onPreferenceChange(mConnectretrymax, mProfile.mConnectRetryMax); +				 +		mConnectretry.setText(mProfile.mConnectRetry); +		onPreferenceChange(mConnectretry, mProfile.mConnectRetry);  	} @@ -55,7 +70,9 @@ public class Settings_Obscure extends OpenVpnPreferencesFragment implements OnPr  		mProfile.mUseCustomConfig = mUseCustomConfig.isChecked();  		mProfile.mCustomConfigOptions = mCustomConfig.getText();  		mProfile.mVerb = mLogverbosity.getValue(); +		mProfile.mConnectRetryMax = mConnectretrymax.getValue();  		mProfile.mPersistTun = mPersistent.isChecked(); +		mProfile.mConnectRetry = mConnectretry.getText();  	} @@ -75,6 +92,21 @@ public class Settings_Obscure extends OpenVpnPreferencesFragment implements OnPr  				mLogverbosity.setSummary(mLogverbosity.getEntries()[i]);  			else  				mLogverbosity.setSummary(String.format("debug verbosity: %d",i)); +		} else 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; diff --git a/src/de/blinkt/openvpn/VpnProfile.java b/src/de/blinkt/openvpn/VpnProfile.java index a71758d1..98f15044 100644 --- a/src/de/blinkt/openvpn/VpnProfile.java +++ b/src/de/blinkt/openvpn/VpnProfile.java @@ -101,10 +101,15 @@ public class VpnProfile implements  Serializable{  	public boolean mUseDefaultRoutev6=true;  	public String mCustomRoutesv6="";  	public String mKeyPassword=""; +	public boolean mPersistTun = false; +	public String mConnectRetryMax="5"; +	public String mConnectRetry="5";  	static final String MINIVPN = "miniopenvpn"; -	public boolean mPersistTun = false; +	 +	 +  	public void clearDefaults() { @@ -192,11 +197,19 @@ public class VpnProfile implements  Serializable{  		cfg+="verb " + mVerb + "\n"; - - - -		// quit after 5 tries -		cfg+="connect-retry-max 5\n"; +		if(mConnectRetryMax ==null) { +			mConnectRetryMax="5"; +		} +		 +		if(!mConnectRetryMax.equals("-1")) +				cfg+="connect-retry-max " + mConnectRetryMax+ "\n"; +	 +		if(mConnectRetry==null) +			mConnectRetry="5"; +		 +	 +		cfg+="connect-retry " + mConnectRetry + "\n"; +		  		cfg+="resolv-retry 60\n"; | 
