summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2013-01-04 15:03:19 +0100
committerArne Schwabe <arne@rfc2549.org>2013-01-04 15:03:19 +0100
commitc767a06a53230ec3829a6ad76b1201a20fae76fa (patch)
treee28dd531fb47bb39db1187ffa23860e2c35a957b /src/de/blinkt/openvpn
parent39eaf8359cfc9ab1e394a124c4aa900df83d50cd (diff)
remote overrides port and proto options (Closes issue #128)
Diffstat (limited to 'src/de/blinkt/openvpn')
-rw-r--r--src/de/blinkt/openvpn/ConfigParser.java51
1 files changed, 25 insertions, 26 deletions
diff --git a/src/de/blinkt/openvpn/ConfigParser.java b/src/de/blinkt/openvpn/ConfigParser.java
index 37741937..4eeaee86 100644
--- a/src/de/blinkt/openvpn/ConfigParser.java
+++ b/src/de/blinkt/openvpn/ConfigParser.java
@@ -327,19 +327,23 @@ public class ConfigParser {
if(!mode.get(1).equals("p2p"))
throw new ConfigParseError("Invalid mode for --mode specified, need p2p");
}
+
+ Vector<String> port = getOption("port", 1,1);
+ if(port!=null){
+ np.mServerPort = port.get(1);
+ }
+
+ Vector<String> proto = getOption("proto", 1,1);
+ if(proto!=null){
+ np.mUseUdp=isUdpProto(proto.get(1));;
+ }
// Parse remote config
Vector<String> remote = getOption("remote",1,3);
if(remote != null){
switch (remote.size()) {
case 4:
- String proto = remote.get(3);
- if(proto.equals("udp"))
- np.mUseUdp=true;
- else if (proto.equals("tcp"))
- np.mUseUdp=false;
- else
- throw new ConfigParseError("remote protocol must be tcp or udp");
+ np.mUseUdp=isUdpProto(remote.get(3));
case 3:
np.mServerPort = remote.get(2);
case 2:
@@ -347,25 +351,6 @@ public class ConfigParser {
}
}
- Vector<String> port = getOption("port", 1,1);
- if(port!=null){
- np.mServerPort = port.get(1);
- }
-
- Vector<String> proto = getOption("proto", 1,1);
- if(proto!=null){
- if(proto.get(1).equals("udp") || proto.get(1).equals("udp6"))
- np.mUseUdp=true;
- else if (proto.get(1).equals("tcp-client") ||
- proto.get(1).equals("tcp") ||
- proto.get(1).equals("tcp6") ||
- proto.get(1).endsWith("tcp6-client"))
- np.mUseUdp=false;
- else
- throw new ConfigParseError("Unsupported option to --proto " + proto.get(1));
-
- }
-
Vector<Vector<String>> dhcpoptions = getAllOption("dhcp-option", 2, 2);
if(dhcpoptions!=null) {
for(Vector<String> dhcpoption:dhcpoptions) {
@@ -483,6 +468,20 @@ public class ConfigParser {
return np;
}
+
+ private boolean isUdpProto(String proto) throws ConfigParseError {
+ boolean isudp;
+ if(proto.equals("udp") || proto.equals("udp6"))
+ isudp=true;
+ else if (proto.equals("tcp-client") ||
+ proto.equals("tcp") ||
+ proto.equals("tcp6") ||
+ proto.endsWith("tcp6-client"))
+ isudp =false;
+ else
+ throw new ConfigParseError("Unsupported option to --proto " + proto);
+ return isudp;
+ }
static public void useEmbbedUserAuth(VpnProfile np,String inlinedata)
{