From 1705a3d66d5c2bc8b0c59b2e53c56ed7f6003f56 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Tue, 4 Feb 2014 10:03:13 +0100 Subject: Add UI/config parsing for excluded routes --- src/de/blinkt/openvpn/core/ConfigParser.java | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'src/de/blinkt/openvpn/core/ConfigParser.java') diff --git a/src/de/blinkt/openvpn/core/ConfigParser.java b/src/de/blinkt/openvpn/core/ConfigParser.java index 895f048e..6ce7467f 100644 --- a/src/de/blinkt/openvpn/core/ConfigParser.java +++ b/src/de/blinkt/openvpn/core/ConfigParser.java @@ -322,14 +322,23 @@ public class ConfigParser { Vector> routes = getAllOption("route", 1, 4); if(routes!=null) { String routeopt = ""; - for(Vector route:routes){ + String routeExcluded = ""; + for(Vector route:routes){ String netmask = "255.255.255.255"; - if(route.size() >= 3) + String gateway = "vpn_gateway"; + + if(route.size() >= 3) netmask = route.get(2); + if (route.size() >= 4) + gateway = route.get(3); + String net = route.get(1); try { CIDRIP cidr = new CIDRIP(net, netmask); - routeopt+=cidr.toString() + " "; + if (gateway.equals("net_gateway")) + routeExcluded += cidr.toString() + " "; + else + routeopt+=cidr.toString() + " "; } catch (ArrayIndexOutOfBoundsException aioob) { throw new ConfigParseError("Could not parse netmask of route " + netmask); } catch (NumberFormatException ne) { @@ -338,9 +347,20 @@ public class ConfigParser { } np.mCustomRoutes=routeopt; + np.mExcludedRoutes=routeExcluded; } - // Also recognize tls-auth [inline] direction ... + Vector> routesV6 = getAllOption("route-ipv6", 1, 4); + if (routesV6!=null) { + String customIPv6Routes = ""; + for (Vector route:routesV6){ + customIPv6Routes += route.get(1) + " "; + } + + np.mCustomRoutesv6 = customIPv6Routes; + } + + // Also recognize tls-auth [inline] direction ... Vector> tlsauthoptions = getAllOption("tls-auth", 1, 2); if(tlsauthoptions!=null) { for(Vector tlsauth:tlsauthoptions) { -- cgit v1.2.3