Skip to content

Commit 343c058

Browse files
committed
✨ feat(android): support configure allowed apps, close #9
1 parent ad7686f commit 343c058

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

android/src/main/java/com/norcod/rnovpn/RNSimpleOpenvpnModule.java

+8
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ private void startVpn(Promise promise) {
251251
boolean useLegacyProvider = (boolean)ovpnOptions.getOrDefault("useLegacyProvider", false);
252252
boolean useCustomConfig = (boolean)ovpnOptions.getOrDefault("useCustomConfig", false);
253253
String customConfigOptions = ovpnOptions.getOrDefault("customConfigOptions", "").toString();
254+
ArrayList<String> allowedAppsVpn =
255+
(ArrayList<String>)ovpnOptions.getOrDefault("allowedAppsVpn", new ArrayList<>());
256+
boolean allowedAppsVpnAreDisallowed = (boolean)ovpnOptions.getOrDefault("allowedAppsVpnAreDisallowed", true);
254257

255258
cp.parseConfig(new StringReader(config));
256259
vpnProfile = cp.convertProfile();
@@ -261,6 +264,11 @@ private void startVpn(Promise promise) {
261264
vpnProfile.mUseLegacyProvider = useLegacyProvider;
262265
vpnProfile.mUseCustomConfig = useCustomConfig;
263266
vpnProfile.mCustomConfigOptions = customConfigOptions;
267+
vpnProfile.mAllowedAppsVpnAreDisallowed = allowedAppsVpnAreDisallowed;
268+
269+
for (String pkgNames : allowedAppsVpn) {
270+
vpnProfile.mAllowedAppsVpn.add(pkgNames);
271+
}
264272

265273
if (vpnProfile.checkProfile(reactContext) != R.string.no_error_found) {
266274
throw new RemoteException(reactContext.getString(vpnProfile.checkProfile(reactContext)));

index.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ interface VpnOptions {
2929
useLegacyProvider?: boolean;
3030
useCustomConfig?: boolean;
3131
customConfigOptions?: string;
32+
allowedAppsVpn?: Array<string>;
33+
allowedAppsVpnAreDisallowed?: boolean;
3234
providerBundleIdentifier: string;
3335
localizedDescription?: string;
3436
}

0 commit comments

Comments
 (0)