Android VpnService 'protect' method not working

shashank

I am using [VpnService] (http://developer.android.com/reference/android/net/VpnService.html)! and able to create VPN connection. I could see (tracert) all the internet traffic going through VPN.

Now, my requirement is to bypass VPN for certain URLs (eg. www.google.com). To achieve this, I have written the following code:

if (vpnService.protect(new Socket(InetAddress.getByName("74.125.225.241"), 80))) {
    Log.d("TAG", "Socket protection for google.com is successfull");
}

But on visiting www.google.com, I could still see VPN server ip on tracert. So, with this code it seems VpnService is not protecting this request from going to VPN server.

Can anyone point me where I am going wrong and suggest the correct way of doing it?

Robert

From my understanding you only exclude (protect) one specific socket from the VPN tunnel.

Therefore every other socket you open with the same target is still going through the VPN tunnel. You have to call protect prepare(...) on every socket that is established from your device towards Google.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Android VpnService protect socket that's stored in native code?

Android VpnService start on Device ACTION_BOOT_COMPLETED not working

Android VpnService - How to check VpnService if it was started?

Android Management API and VpnService

Android firewall with VpnService

Android VpnService with multiple addresses and routes?

Android onCreate()-Method not working

Xamarin Android - VpnService is blocking all apps

what is Android VpnService.Builder setBlocking

Issue about Android understanding VpnService code

Regex not working in method replaceAll() - Android

drawCircle method not working properly (Android)

Post method not working in AsyncHttpClient in Android

onClick method not working in android studio

Android setTextOn not working in onCheckChanged method

Firebase Android setValue method not working

Foreground method is not working in Jellybean in Android

Put method of Retrofit is not working in Android

Replace method of String is not working in android

Android getSharedPreferences is not working inside a method

Android password protect sqlite

A firewall for Android with VpnService. Responses are delivered, but a SocketTimeoutException is thrown

Android VpnService to capture packets won't capture packets

Protect a dangerous static method in PHP

Method endsWith() not working in android java coding

File mkdirs() method not working in android/java

Android Studio rename attribute or method not always working

Android Studio onClick for a display method not working at all

Get method with header parameter not working android