diff options
author | Arne Schwabe <arne@rfc2549.org> | 2017-05-18 00:32:38 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2017-05-18 00:32:38 +0200 |
commit | 997b8b2072d9ca3b2c3bd7f6d67fe52065e2eecd (patch) | |
tree | 9bc8f54e6204042450381d8f621bae7bf37b7596 /main/src | |
parent | 9042eca960f21f9da0bf8c2052af9376dc0d44e0 (diff) |
Parser ipv6 and !noipv4 parameters of redirect-gateway (closes #675)
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java | 19 |
1 files changed, 14 insertions, 5 deletions
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<Vector<String>> defgw = getAllOption("redirect-gateway", 0, 5); + Vector<Vector<String>> defgw = getAllOption("redirect-gateway", 0, 7); if (defgw != null) { - np.mUseDefaultRoute = true; - checkRedirectParameters(np, defgw); + checkRedirectParameters(np, defgw, true); } Vector<Vector<String>> redirectPrivate = getAllOption("redirect-private", 0, 5); if (redirectPrivate != null) { - checkRedirectParameters(np, redirectPrivate); + checkRedirectParameters(np, redirectPrivate, false); } Vector<String> dev = getOption("dev", 1, 1); Vector<String> devtype = getOption("dev-type", 1, 1); @@ -799,14 +798,24 @@ public class ConfigParser { } - private void checkRedirectParameters(VpnProfile np, Vector<Vector<String>> defgw) { + private void checkRedirectParameters(VpnProfile np, Vector<Vector<String>> defgw, boolean defaultRoute) { + + boolean noIpv4 = false; + if (defaultRoute) + for (Vector<String> 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 { |