From b3ed4adfc3c4088ca525cf8a994995699648d71d Mon Sep 17 00:00:00 2001 From: Jared Stafford Date: Thu, 25 Oct 2018 15:57:25 -0500 Subject: Add option to allow apps to bypass VPN --- .../main/java/de/blinkt/openvpn/VpnProfile.java | 1 + .../de/blinkt/openvpn/core/OpenVPNService.java | 5 ++++ .../openvpn/fragments/Settings_Allowed_Apps.java | 15 ++++++++++++ main/src/main/res/layout/allowed_vpn_apps.xml | 27 ++++++++++++++++++++++ main/src/main/res/values/strings.xml | 1 + 5 files changed, 49 insertions(+) diff --git a/main/src/main/java/de/blinkt/openvpn/VpnProfile.java b/main/src/main/java/de/blinkt/openvpn/VpnProfile.java index a9b76bda..a715805d 100644 --- a/main/src/main/java/de/blinkt/openvpn/VpnProfile.java +++ b/main/src/main/java/de/blinkt/openvpn/VpnProfile.java @@ -142,6 +142,7 @@ public class VpnProfile implements Serializable, Cloneable { public boolean mRemoteRandom = false; public HashSet mAllowedAppsVpn = new HashSet<>(); public boolean mAllowedAppsVpnAreDisallowed = true; + public boolean mAllowAppVpnBypass = false; public String mCrlFilename; public String mProfileCreator; public String mExternalAuthenticator; 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 8ee8b8a6..5612b55f 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -979,6 +979,11 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac } else { VpnStatus.logDebug(R.string.allowed_vpn_apps_info, TextUtils.join(", ", mProfile.mAllowedAppsVpn)); } + + if (mProfile.mAllowAppVpnBypass) { + builder.allowBypass(); + VpnStatus.logDebug("Apps may bypass VPN"); + } } public void addDNS(String dns) { diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Allowed_Apps.java b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Allowed_Apps.java index e6e161b7..24bb28ae 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Allowed_Apps.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Allowed_Apps.java @@ -46,6 +46,7 @@ public class Settings_Allowed_Apps extends Fragment implements AdapterView.OnIte private ListView mListView; private VpnProfile mProfile; private TextView mDefaultAllowTextView; + private TextView mAllowBypassTextView; private PackageAdapter mListAdapter; @Override @@ -304,6 +305,7 @@ public class Settings_Allowed_Apps extends Fragment implements AdapterView.OnIte View v = inflater.inflate(R.layout.allowed_vpn_apps, container, false); mDefaultAllowTextView = (TextView) v.findViewById(R.id.default_allow_text); + mAllowBypassTextView = (TextView) v.findViewById(R.id.allow_bypass_text); Switch vpnOnDefaultSwitch = (Switch) v.findViewById(R.id.default_allow); @@ -318,6 +320,17 @@ public class Settings_Allowed_Apps extends Fragment implements AdapterView.OnIte vpnOnDefaultSwitch.setChecked(mProfile.mAllowedAppsVpnAreDisallowed); + Switch vpnAllowBypassSwitch = (Switch) v.findViewById(R.id.allow_bypass); + + vpnAllowBypassSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mProfile.mAllowAppVpnBypass = isChecked; + } + }); + + vpnAllowBypassSwitch.setChecked(mProfile.mAllowAppVpnBypass); + mListView = (ListView) v.findViewById(android.R.id.list); mListAdapter = new PackageAdapter(getActivity(), mProfile); @@ -341,5 +354,7 @@ public class Settings_Allowed_Apps extends Fragment implements AdapterView.OnIte mDefaultAllowTextView.setText(R.string.vpn_disallow_radio); else mDefaultAllowTextView.setText(R.string.vpn_allow_radio); + + mAllowBypassTextView.setText(R.string.vpn_allow_bypass); } } diff --git a/main/src/main/res/layout/allowed_vpn_apps.xml b/main/src/main/res/layout/allowed_vpn_apps.xml index 0883f4b8..4219e13d 100644 --- a/main/src/main/res/layout/allowed_vpn_apps.xml +++ b/main/src/main/res/layout/allowed_vpn_apps.xml @@ -37,6 +37,33 @@ android:layout_height="wrap_content" /> + + + + + + Package %s is no longer installed, removing it from app allow/disallow list VPN is used for all apps but exclude selected VPN is used for only for selected apps + Allow apps to bypass the VPN Remove remote server entry? Keep Delete -- cgit v1.2.3