Cake-VPN icon indicating copy to clipboard operation
Cake-VPN copied to clipboard

split tunneling

Open khashayar-k opened this issue 4 years ago • 14 comments

hi @ashraf789 i was looking into adding the split tunneling feature to the app so we could select the apps that are allowed to have vpn (all the apps are selected in default) and i was looking in to openvpn source and i found a class called Settings_Allowed_Apps.kt but the problem is i dont know kotlin so i was wondering if you would like to add this feature its really use full thanks

khashayar-k avatar Apr 27 '20 19:04 khashayar-k

Hello, Thank you for your suggestion. I am sorry to say that I am also not familiar with Kotlin. Although I have the interestest to learn. Currently, I am working on web platform and I do not have much time.

I am sorry this time, I could not full fill your request. If you found the solution please update this source code too. Your contribution could save lots of other developer time. Thanks Ashraf.

ashraf789 avatar Apr 28 '20 01:04 ashraf789

Thats okay i would try to make this feature thanks again 👍

khashayar-k avatar Apr 28 '20 01:04 khashayar-k

Hi guys, did you find any solution for the split tunneling? Can we restrict the app to only allow one app to use the OpenVPN?

Thank you.

ChadiGSfeir avatar Oct 31 '20 10:10 ChadiGSfeir

on OpenVPNService.java after line number

https://github.com/ashraf789/Cake-VPN/blob/5a5b1b26a72eb402fbf7e97b24742f53f6c8c674/vpnLib/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java#L797

add this to your app

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            try {
                builder.addDisallowedApplication("com.android.chrome");
            } catch (Exception e) {

            }
        }

Deepanshusuman avatar Nov 30 '20 12:11 Deepanshusuman

Hello @Deepanshusuman, thank you for your reply, is this work same for builder.addAllowedApplication(appPackage);?

and one more question if possible can we restrict the vpn from google services like google search/ maps ? (specially in pixels devices)

Thank you so much. Have a nice day.

ChadiGSfeir avatar Dec 01 '20 17:12 ChadiGSfeir

addAllowedApplication -> allow apps to use vpn addDisallowedApplication -> disallow apps to use vpn i don't know for pixel but you can use for google apps

PackageManager pm = getPackageManager();
List<ApplicationInfo> apps = pm.getInstalledApplications(PackageManager.GET_META_DATA);

        for (ApplicationInfo app : apps) {
            if(pm.getLaunchIntentForPackage(app.packageName) != null) {
                // apps with launcher intent
                if((app.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
                    // here you you will get google apps 

                } else if ((app.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
                    // system apps

                } else {
                    // user installed apps

                }
                appsList.add(app);
            }

        }

reference -> https://stackoverflow.com/questions/2695746/how-to-get-a-list-of-installed-android-applications-and-pick-one-to-run

Deepanshusuman avatar Dec 01 '20 17:12 Deepanshusuman

or you can remove from arraylist which are google apps

Deepanshusuman avatar Dec 01 '20 18:12 Deepanshusuman

Hi again, is their any way to monito the packages that pass thru the vpn tunnel? ex: monitoring WhatsApp packages passing thru the vpn or WhatsApp call... (i only need to count the number of messages)

Sorry for asking question here. Thank you so much. Have a nice day.

ChadiGSfeir avatar Dec 03 '20 13:12 ChadiGSfeir

I haven't tried yet. But as far as I know the packets are encrypted for whatsapp

On Thu, Dec 3, 2020, 7:22 PM ChadiGSfeir [email protected] wrote:

Hi again, is their any way to monito the packages that pass thru the vpn tunnel? ex: monitoring WhatsApp packages passing thru the vpn or WhatsApp call... (i only need to count the number of messages)

Sorry for asking question here. Thank you so much. Have a nice day.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ashraf789/Cake-VPN/issues/30#issuecomment-738007142, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGCOQP26PUKCG5SGJYOHBGLSS6J3BANCNFSM4MSGYQ6Q .

Deepanshusuman avatar Dec 04 '20 05:12 Deepanshusuman

Hello. I saw your message with how to disallow google chrome, I put your code in OpenVpnService, in function OpenTun but this doesn’t work. Are you using openTun somewhere?

stanandreea09 avatar Apr 15 '21 09:04 stanandreea09

Hello. I saw your message with how to disallow google chrome, I put your code in OpenVpnService, in function OpenTun but this doesn’t work. Are you using openTun somewhere?

I couldn't implement anything for google services, only I can block apps from using VPN as Deepanshusuman suggested.

ChadiGSfeir avatar Apr 15 '21 10:04 ChadiGSfeir

As far as I know it’s very insecure

BinartPhotography avatar Oct 21 '21 21:10 BinartPhotography

Hello, can we do this in ios?

ChadiGSfeir avatar May 17 '22 00:05 ChadiGSfeir

hi @ashraf789 i was looking into adding the split tunneling feature to the app so we could select the apps that are allowed to have vpn (all the apps are selected in default) and i was looking in to openvpn source and i found a class called Settings_Allowed_Apps.kt but the problem is i dont know kotlin so i was wondering if you would like to add this feature its really use full thanks

#------------------------------------------------------------ put this code inside openvpnservice class opentun method,

public ParcelFileDescriptor openTun() { ArrayList<String> appsList = new ArrayList<>(); appsList.add("com.android.chrome");

    //Debug.startMethodTracing(getExternalFilesDir(null).toString() + "/opentun.trace", 40* 1024 * 1024);

    Builder builder = new Builder();

    for (int i=0;i<appsList.size();i++){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            try {
                builder.addDisallowedApplication(appsList.get(i));
            } catch (Exception e) {

            }
        }
    }

CodeWithTamim avatar Nov 27 '23 04:11 CodeWithTamim