From 97f7e247c61994ca22f7bc70980ec0b063d59e1c Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Mon, 1 Dec 2014 19:00:31 +0100 Subject: Fix block local LAN on non KK,LP devices --HG-- extra : rebase_source : cdd438f410d402bffbee241e3afa12c0fc319bbe --- main/src/main/AndroidManifest.xml | 1 - main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java | 9 +++++++++ main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/main/src/main/AndroidManifest.xml b/main/src/main/AndroidManifest.xml index 8f478bcc..e226bdfc 100644 --- a/main/src/main/AndroidManifest.xml +++ b/main/src/main/AndroidManifest.xml @@ -42,7 +42,6 @@ diff --git a/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java b/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java index fd3dee92..701909d1 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java +++ b/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java @@ -21,6 +21,8 @@ import de.blinkt.openvpn.BuildConfig; public class NetworkSpace { + + static class ipAddress implements Comparable { private BigInteger netAddress; public int networkMask; @@ -198,6 +200,13 @@ public class NetworkSpace { mIpAddresses.add(new ipAddress(cidrIp, include)); } + public void addIPSplit(CIDRIP cidrIp, boolean include) { + ipAddress newIP = new ipAddress(cidrIp, include); + ipAddress[] splitIps = newIP.split(); + for (ipAddress split: splitIps) + mIpAddresses.add(split); + } + void addIPv6(Inet6Address address, int mask, boolean included) { mIpAddresses.add(new ipAddress(address, mask, included)); } diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java index 29009e5c..3f16248d 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -16,7 +16,6 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.net.ConnectivityManager; -import android.net.NetworkCapabilities; import android.net.NetworkRequest; import android.net.VpnService; import android.os.Binder; @@ -651,7 +650,8 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac continue; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT && !mProfile.mAllowLocalLAN) { - mRoutes.addIP(new CIDRIP(ipAddr,netMask), true); + mRoutes.addIPSplit(new CIDRIP(ipAddr,netMask), true); + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && mProfile.mAllowLocalLAN) mRoutes.addIP(new CIDRIP(ipAddr,netMask), false); } -- cgit v1.2.3