From 83a741a917e56f1d6079a95394f72a2c7cf709ed Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Sun, 2 Feb 2014 18:01:03 +0100 Subject: Implement bypassing the VPN when accessing local resources --- res/values/strings.xml | 2 ++ res/xml/vpn_routing.xml | 6 ++++++ src/de/blinkt/openvpn/VpnProfile.java | 22 ++++++++++++++++++++++ src/de/blinkt/openvpn/core/ProfileManager.java | 3 ++- .../blinkt/openvpn/fragments/Settings_Routing.java | 4 ++++ 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 34721515..2998a9a4 100755 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -309,4 +309,6 @@ %3$s: %1$s\n\n%2$s If you have rooted your Android device you can install the <a href=\"http://xposed.info/\">Xposed framework</a> and a the <a href=\"http://repo.xposed.info/module/de.blinkt.vpndialogxposed\">VPN Dialog confirm module</a> at your own risk" Full licenses + Networks directly connected to the local interfaces will not be routed over the VPN. Unchecking this option will redirect all traffic indented for local networks to VPN. + Bypass VPN for local networks diff --git a/res/xml/vpn_routing.xml b/res/xml/vpn_routing.xml index ce19a500..298f488f 100644 --- a/res/xml/vpn_routing.xml +++ b/res/xml/vpn_routing.xml @@ -6,6 +6,12 @@ android:summary="@string/ignore_routes_summary" android:title="@string/ignored_pushed_routes" /> + + = Build.VERSION_CODES.KITKAT && mAllowLocalLAN) + cfg+="redirect-private unblock-local\n"; + if (mUseDefaultRoutev6) cfg += "route-ipv6 ::/0\n"; diff --git a/src/de/blinkt/openvpn/core/ProfileManager.java b/src/de/blinkt/openvpn/core/ProfileManager.java index a1dd8da5..4cfbcc8e 100644 --- a/src/de/blinkt/openvpn/core/ProfileManager.java +++ b/src/de/blinkt/openvpn/core/ProfileManager.java @@ -171,7 +171,8 @@ public class ProfileManager { // Sanity check if(vp==null || vp.mName==null || vp.getUUID()==null) continue; - + + vp.upgradeProfile(); profiles.put(vp.getUUID().toString(), vp); } catch (StreamCorruptedException e) { diff --git a/src/de/blinkt/openvpn/fragments/Settings_Routing.java b/src/de/blinkt/openvpn/fragments/Settings_Routing.java index 63b54bf3..7216e0ff 100644 --- a/src/de/blinkt/openvpn/fragments/Settings_Routing.java +++ b/src/de/blinkt/openvpn/fragments/Settings_Routing.java @@ -13,6 +13,7 @@ public class Settings_Routing extends OpenVpnPreferencesFragment implements OnPr private EditTextPreference mCustomRoutesv6; private CheckBoxPreference mUseDefaultRoutev6; private CheckBoxPreference mRouteNoPull; + private CheckBoxPreference mLocalVPNAccess; @Override public void onCreate(Bundle savedInstanceState) { @@ -25,6 +26,7 @@ public class Settings_Routing extends OpenVpnPreferencesFragment implements OnPr mCustomRoutesv6 = (EditTextPreference) findPreference("customRoutesv6"); mUseDefaultRoutev6 = (CheckBoxPreference) findPreference("useDefaultRoutev6"); mRouteNoPull = (CheckBoxPreference) findPreference("routenopull"); + mLocalVPNAccess = (CheckBoxPreference) findPreference("unblockLocal"); mCustomRoutes.setOnPreferenceChangeListener(this); mCustomRoutesv6.setOnPreferenceChangeListener(this); @@ -42,6 +44,7 @@ public class Settings_Routing extends OpenVpnPreferencesFragment implements OnPr mCustomRoutesv6.setText(mProfile.mCustomRoutesv6); mRouteNoPull.setChecked(mProfile.mRoutenopull); + mLocalVPNAccess.setChecked(mProfile.mAllowLocalLAN); // Sets Summary onPreferenceChange(mCustomRoutes, mCustomRoutes.getText()); @@ -57,6 +60,7 @@ public class Settings_Routing extends OpenVpnPreferencesFragment implements OnPr mProfile.mCustomRoutes = mCustomRoutes.getText(); mProfile.mCustomRoutesv6 = mCustomRoutesv6.getText(); mProfile.mRoutenopull = mRouteNoPull.isChecked(); + mProfile.mAllowLocalLAN =mLocalVPNAccess.isChecked(); } @Override -- cgit v1.2.3