From f00cd03f5aa1f8042b55ebee5050d297cef6bb8a Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Sat, 2 Feb 2013 16:37:43 +0100 Subject: Add the --auth option to the auth/enc dialog --- res/values/strings.xml | 9 +++++++-- res/xml/vpn_authentification.xml | 8 +++++++- src/de/blinkt/openvpn/ConfigParser.java | 5 +++++ src/de/blinkt/openvpn/Settings_Authentication.java | 13 ++++++++++++- src/de/blinkt/openvpn/VpnProfile.java | 4 ++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index ff9db139..f1bd9bd9 100755 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -126,7 +126,8 @@ Your image does not support the VPNService API, sorry :( Encryption Enter encryption method - Enter the cipher key for OpenVPN. Leave empty to use default cipher + Enter the encryption cipher alogithm used by OpenVPN. Leave empty to use default cipher. + Enter the authentication digest used for OpenVPN. Leave empty to use default digest. Authentication/Encryption File Explorer Inline File @@ -256,4 +257,8 @@ In: %8$1s %8$2s/s Out: %8$3s %8$4s/s Not connected Some versions of Android 4.1 have problem if the name of the keystore certificate contains non alphanumeric character (like spaces or dashes) - + Encryption cipher + Packets authentication + Enter packet authentication method + + \ No newline at end of file diff --git a/res/xml/vpn_authentification.xml b/res/xml/vpn_authentification.xml index 99e0f3e8..619890c7 100644 --- a/res/xml/vpn_authentification.xml +++ b/res/xml/vpn_authentification.xml @@ -41,7 +41,13 @@ android:dialogTitle="@string/cipher_dialog_title" android:key="cipher" android:persistent="false" - android:title="Encryption cipher" /> + android:title="@string/encryption_cipher" /> + \ No newline at end of file diff --git a/src/de/blinkt/openvpn/ConfigParser.java b/src/de/blinkt/openvpn/ConfigParser.java index dc605bbc..99e7ec93 100644 --- a/src/de/blinkt/openvpn/ConfigParser.java +++ b/src/de/blinkt/openvpn/ConfigParser.java @@ -388,6 +388,11 @@ public class ConfigParser { if(cipher!=null) np.mCipher= cipher.get(1); + Vector auth = getOption("auth", 1, 1); + if(auth!=null) + np.mAuth = auth.get(1); + + Vector ca = getOption("ca",1,1); if(ca!=null){ np.mCaFilename = ca.get(1); diff --git a/src/de/blinkt/openvpn/Settings_Authentication.java b/src/de/blinkt/openvpn/Settings_Authentication.java index 6733ed0c..4e3f1e6f 100644 --- a/src/de/blinkt/openvpn/Settings_Authentication.java +++ b/src/de/blinkt/openvpn/Settings_Authentication.java @@ -23,6 +23,7 @@ public class Settings_Authentication extends OpenVpnPreferencesFragment implemen private SwitchPreference mUseTLSAuth; private EditTextPreference mCipher; private String mTlsAuthFileData; + private EditTextPreference mAuth; @Override public void onCreate(Bundle savedInstanceState) { @@ -46,6 +47,9 @@ public class Settings_Authentication extends OpenVpnPreferencesFragment implemen mCipher =(EditTextPreference) findPreference("cipher"); mCipher.setOnPreferenceChangeListener(this); + mAuth =(EditTextPreference) findPreference("auth"); + mAuth.setOnPreferenceChangeListener(this); + loadSettings(); } @@ -64,6 +68,8 @@ public class Settings_Authentication extends OpenVpnPreferencesFragment implemen mTLSAuthDirection.setValue(mProfile.mTLSAuthDirection); mCipher.setText(mProfile.mCipher); onPreferenceChange(mCipher, mProfile.mCipher); + mAuth.setText(mProfile.mAuth); + onPreferenceChange(mAuth, mProfile.mAuth); } @Override @@ -85,6 +91,11 @@ public class Settings_Authentication extends OpenVpnPreferencesFragment implemen else mProfile.mCipher = mCipher.getText(); + if(mAuth.getText()==null) + mProfile.mAuth = null; + else + mProfile.mAuth = mAuth.getText(); + } @@ -96,7 +107,7 @@ public class Settings_Authentication extends OpenVpnPreferencesFragment implemen preference.setSummary(mProfile.mServerName); else preference.setSummary((String)newValue); - } else if (preference == mCipher) { + } else if (preference == mCipher || preference == mAuth) { preference.setSummary((CharSequence) newValue); } return true; diff --git a/src/de/blinkt/openvpn/VpnProfile.java b/src/de/blinkt/openvpn/VpnProfile.java index 74f01a3b..6f21397e 100644 --- a/src/de/blinkt/openvpn/VpnProfile.java +++ b/src/de/blinkt/openvpn/VpnProfile.java @@ -106,6 +106,7 @@ public class VpnProfile implements Serializable{ public String mConnectRetryMax="5"; public String mConnectRetry="5"; public boolean mUserEditable=true; + public String mAuth=""; static final String MINIVPN = "miniopenvpn"; @@ -349,6 +350,9 @@ public class VpnProfile implements Serializable{ cfg += "cipher " + mCipher + "\n"; } + if(nonNull(mAuth)) { + cfg += "auth " + mAuth + "\n"; + } // Obscure Settings dialog if(mUseRandomHostname) -- cgit v1.2.3