From 062d57b2752ee66537bda74d87cc4c533a08b9ac Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Thu, 6 Feb 2014 16:36:55 +0100 Subject: Fix bugs with the ocnfig parser --- .../blinkt/openvpn/activities/ConfigConverter.java | 9 +++- src/de/blinkt/openvpn/core/ConfigParser.java | 63 ++++++++++++++++++---- 2 files changed, 60 insertions(+), 12 deletions(-) (limited to 'src/de/blinkt/openvpn') diff --git a/src/de/blinkt/openvpn/activities/ConfigConverter.java b/src/de/blinkt/openvpn/activities/ConfigConverter.java index 2e24f94f..50253915 100644 --- a/src/de/blinkt/openvpn/activities/ConfigConverter.java +++ b/src/de/blinkt/openvpn/activities/ConfigConverter.java @@ -315,15 +315,20 @@ public class ConfigConverter extends ListActivity implements FileSelectCallback if (mResult!=null) value = mResult.mPKCS12Filename; break; + + case USERPW_FILE: + titleRes = R.string.userpw_file; + return; + } boolean isCert = type == Utils.FileType.CA_CERTIFICATE || type == Utils.FileType.CLIENT_CERTIFICATE; FileSelectLayout fl = new FileSelectLayout(this,getString(titleRes), isCert); - fl.setData(value,this); - fileSelectMap.put(type,fl); + fileSelectMap.put(type, fl); fl.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); ((LinearLayout) findViewById(R.id.config_convert_root)).addView(fl, 1); + fl.setData(value,this); int i = getFileLayoutOffset(type); fl.setCaller(this, i, type); diff --git a/src/de/blinkt/openvpn/core/ConfigParser.java b/src/de/blinkt/openvpn/core/ConfigParser.java index 6ce7467f..06acdf98 100644 --- a/src/de/blinkt/openvpn/core/ConfigParser.java +++ b/src/de/blinkt/openvpn/core/ConfigParser.java @@ -245,8 +245,19 @@ public class ConfigParser { "ip-win32", "management-hold", "management", + "management-client", + "management-query-remote", "management-query-passwords", + "management-query-proxy", + "management-external-key", + "management-forget-disconnect", + "management-signal", + "management-log-cache", + "management-up-down", + "management-client-user", + "management-client-group", "pause-exit", + "plugin", "machine-readable-output", "persist-key", "register-dns", @@ -263,6 +274,13 @@ public class ConfigParser { "topology", "user", "win-sys", + + }; + + final String[][] ignoreOptionsWithArg = + { + {"setenv", "IV_GUI_VER"}, + {"setenv", "IV_OPENVPN_GUI_VERSION"} }; final String[] connectionOptions = { @@ -640,10 +658,14 @@ public class ConfigParser { // removing an item which is not in the map is no error options.remove(option); + + + if(options.size()> 0) { np.mCustomConfigOptions += "# These Options were found in the config file do not map to config settings:\n"; for(Vector> option:options.values()) { + np.mCustomConfigOptions += getOptionStrings(option); } @@ -652,18 +674,39 @@ public class ConfigParser { } } - private String getOptionStrings( Vector> option) { - String custom=""; - for(Vector optionsline: option) { - for (String arg : optionsline) - custom+= VpnProfile.openVpnEscape(arg) + " "; - custom+="\n"; - } - return custom; - } + + boolean ignoreThisOption(Vector option) { + for (String[] ignoreOption : ignoreOptionsWithArg) { + + if (option.size() < ignoreOption.length) + continue; + + boolean ignore = true; + for (int i = 0; i < ignoreOption.length; i++) { + if (!ignoreOption[i].equals(option.get(i))) + ignore = false; + } + if (ignore) + return true; + + } + return false; + } + + private String getOptionStrings(Vector> option) { + String custom = ""; + for (Vector optionsline : option) { + if (!ignoreThisOption(optionsline)) { + for (String arg : optionsline) + custom += VpnProfile.openVpnEscape(arg) + " "; + custom += "\n"; + } + } + return custom; + } - private void fixup(VpnProfile np) { + private void fixup(VpnProfile np) { if(np.mRemoteCN.equals(np.mServerName)) { np.mRemoteCN=""; } -- cgit v1.2.3