summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-07-10 23:00:52 +0200
committerArne Schwabe <arne@rfc2549.org>2012-07-10 23:00:52 +0200
commit951bc8dd9532a772db610aff59af2d96a6ab05db (patch)
treeecf0ef50c1ea21059b2f8480ed0da1717172161d
parentda3d649cfa356873b72e6c25b9c0496268efcf89 (diff)
Fine tune config convert messages
Import tls-auth [inline] dir correctly (closes issue #55)
-rw-r--r--src/de/blinkt/openvpn/ConfigConverter.java11
-rw-r--r--src/de/blinkt/openvpn/ConfigParser.java21
-rw-r--r--src/de/blinkt/openvpn/VpnProfile.java4
3 files changed, 24 insertions, 12 deletions
diff --git a/src/de/blinkt/openvpn/ConfigConverter.java b/src/de/blinkt/openvpn/ConfigConverter.java
index 101c90b0..ed252f7d 100644
--- a/src/de/blinkt/openvpn/ConfigConverter.java
+++ b/src/de/blinkt/openvpn/ConfigConverter.java
@@ -1,3 +1,4 @@
+
package de.blinkt.openvpn;
import java.io.File;
@@ -187,7 +188,7 @@ public class ConfigConverter extends ListActivity {
final android.net.Uri data = intent.getData ();
if (data != null)
{
- log(R.string.import_experimental);
+ //log(R.string.import_experimental);
log(R.string.importing_config,data.toString());
try {
InputStream is = getContentResolver().openInputStream(data);
@@ -232,7 +233,13 @@ public class ConfigConverter extends ListActivity {
private void displayWarnings() {
if(mResult.mUseCustomConfig) {
log(R.string.import_warning_custom_options);
- log(mResult.mCustomConfigOptions);
+ String copt = mResult.mCustomConfigOptions;
+ if(copt.startsWith("#")) {
+ int until = copt.indexOf('\n');
+ copt = copt.substring(until+1);
+ }
+
+ log(copt);
}
if(mResult.mAuthenticationType==VpnProfile.TYPE_KEYSTORE) {
diff --git a/src/de/blinkt/openvpn/ConfigParser.java b/src/de/blinkt/openvpn/ConfigParser.java
index 1b07178e..e1b426fa 100644
--- a/src/de/blinkt/openvpn/ConfigParser.java
+++ b/src/de/blinkt/openvpn/ConfigParser.java
@@ -279,14 +279,19 @@ public class ConfigParser {
}
np.mCustomRoutes=routeopt;
}
-
- Vector<String> tlsauth = getOption("tls-auth", 1, 2);
- if(tlsauth!=null)
- {
- np.mUseTLSAuth=true;
- np.mTLSAuthFilename=tlsauth.get(1);
- if(tlsauth.size()==3)
- np.mTLSAuthDirection=tlsauth.get(2);
+
+ // Also recognize tls-auth [inline] direction ...
+ Vector<Vector<String>> tlsauthoptions = getAllOption("tls-auth", 1, 2);
+ for(Vector<String> tlsauth:tlsauthoptions) {
+ if(tlsauth!=null)
+ {
+ if(!tlsauth.get(1).equals("[inline]")) {
+ np.mTLSAuthFilename=tlsauth.get(1);
+ np.mUseTLSAuth=true;
+ }
+ if(tlsauth.size()==3)
+ np.mTLSAuthDirection=tlsauth.get(2);
+ }
}
Vector<String> direction = getOption("key-direction", 1, 1);
diff --git a/src/de/blinkt/openvpn/VpnProfile.java b/src/de/blinkt/openvpn/VpnProfile.java
index 6886d774..b495cc9e 100644
--- a/src/de/blinkt/openvpn/VpnProfile.java
+++ b/src/de/blinkt/openvpn/VpnProfile.java
@@ -242,13 +242,13 @@ public class VpnProfile implements Serializable{
cfg+=insertFileData("secret",mTLSAuthFilename);
else
cfg+=insertFileData("tls-auth",mTLSAuthFilename);
- cfg+=" ";
if(nonNull(mTLSAuthDirection)) {
cfg+= "key-direction ";
cfg+= mTLSAuthDirection;
+ cfg+="\n";
}
- cfg+="\n";
+
}
if(!mUsePull ) {