From 997b8b2072d9ca3b2c3bd7f6d67fe52065e2eecd Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Thu, 18 May 2017 00:32:38 +0200 Subject: Parser ipv6 and !noipv4 parameters of redirect-gateway (closes #675) --- .../java/de/blinkt/openvpn/core/ConfigParser.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'main/src') diff --git a/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java b/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java index 93ebedbd..42217e52 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java +++ b/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java @@ -430,15 +430,14 @@ public class ConfigParser { np.mTLSAuthDirection = "tls-crypt"; } - Vector> defgw = getAllOption("redirect-gateway", 0, 5); + Vector> defgw = getAllOption("redirect-gateway", 0, 7); if (defgw != null) { - np.mUseDefaultRoute = true; - checkRedirectParameters(np, defgw); + checkRedirectParameters(np, defgw, true); } Vector> redirectPrivate = getAllOption("redirect-private", 0, 5); if (redirectPrivate != null) { - checkRedirectParameters(np, redirectPrivate); + checkRedirectParameters(np, redirectPrivate, false); } Vector dev = getOption("dev", 1, 1); Vector devtype = getOption("dev-type", 1, 1); @@ -799,14 +798,24 @@ public class ConfigParser { } - private void checkRedirectParameters(VpnProfile np, Vector> defgw) { + private void checkRedirectParameters(VpnProfile np, Vector> defgw, boolean defaultRoute) { + + boolean noIpv4 = false; + if (defaultRoute) + for (Vector redirect : defgw) for (int i = 1; i < redirect.size(); i++) { if (redirect.get(i).equals("block-local")) np.mAllowLocalLAN = false; else if (redirect.get(i).equals("unblock-local")) np.mAllowLocalLAN = true; + else if (redirect.get(i).equals("!ipv4")) + noIpv4=true; + else if (redirect.get(i).equals("ipv6")) + np.mUseDefaultRoutev6=true; } + if (defaultRoute && !noIpv4) + np.mUseDefaultRoute=true; } private boolean isUdpProto(String proto) throws ConfigParseError { -- cgit v1.2.3