summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorntoskrnl <anton.danshin@frtk.ru>2021-07-12 21:43:32 -0400
committerArne Schwabe <arne@rfc2549.org>2021-07-18 14:02:12 +0200
commite7d5155abee039a9000e8b80bed5201520cb6577 (patch)
treef85a7a8db205ad7e7a28b20a572050f5649aa632
parent9048473a350170d120287a76dadd3c8ee04d8483 (diff)
Ability to pass extras when starting VPN via AIDL using inline config.
To preserve backward compatibility, a new method is created: IOpenVPNAPIService#startVPNwithExtras(String, Bundle). Currently only one parameter is supported: de.blinkt.openvpn.api.ALLOW_VPN_BYPASS – boolean.
-rw-r--r--main/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl4
-rw-r--r--main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java14
2 files changed, 17 insertions, 1 deletions
diff --git a/main/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl b/main/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl
index ac731b56..3285432c 100644
--- a/main/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl
+++ b/main/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl
@@ -63,4 +63,8 @@ interface IOpenVPNAPIService {
/** Use a profile with all certificates etc. embedded */
APIVpnProfile addNewVPNProfile (String name, boolean userEditable, String config);
+
+ /** Same as startVPN(String), but also takes a Bundle with extra parameters,
+ * which will be applied to the created VPNProfile (e.g. allow vpn bypass). */
+ void startVPNwithExtras(in String inlineconfig, in Bundle extras);
} \ No newline at end of file
diff --git a/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java b/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java
index 1b8512f9..690c349e 100644
--- a/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java
+++ b/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java
@@ -20,6 +20,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.net.VpnService;
import android.os.Binder;
import android.os.Build;
+import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
@@ -50,6 +51,8 @@ public class ExternalOpenVPNService extends Service implements StateListener {
private static final int SEND_TOALL = 0;
+ private static final String EXTRA_INLINE_PROFILE_ALLOW_VPN_BYPASS = "de.blinkt.openvpn.api.ALLOW_VPN_BYPASS";
+
final RemoteCallbackList<IOpenVPNStatusCallback> mCallbacks =
new RemoteCallbackList<>();
@@ -161,7 +164,8 @@ public class ExternalOpenVPNService extends Service implements StateListener {
startProfile(vp);
}
- public void startVPN(String inlineConfig) throws RemoteException {
+ @Override
+ public void startVPNwithExtras(String inlineConfig, Bundle extras) throws RemoteException {
String callingApp = mExtAppDb.checkOpenVPNPermission(getPackageManager());
ConfigParser cp = new ConfigParser();
@@ -174,6 +178,10 @@ public class ExternalOpenVPNService extends Service implements StateListener {
vp.mProfileCreator = callingApp;
+ if (extras != null) {
+ vp.mAllowAppVpnBypass = extras.getBoolean(EXTRA_INLINE_PROFILE_ALLOW_VPN_BYPASS, false);
+ }
+
/*int needpw = vp.needUserPWInput(false);
if(needpw !=0)
throw new RemoteException("The inline file would require user input: " + getString(needpw));
@@ -188,6 +196,10 @@ public class ExternalOpenVPNService extends Service implements StateListener {
}
}
+ @Override
+ public void startVPN(String inlineConfig) throws RemoteException {
+ startVPNwithExtras(inlineConfig, null);
+ }
@Override
public boolean addVPNProfile(String name, String config) throws RemoteException {