Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the status of VPN connection through framework APIs or any other efficient method?

So far:

I found the following solutions

  1. Using Broadcastreceiver

    The broadcast receiver is deprecated from ICS

  2. Using Ping or Traceroute

    It's definitely going to take lots of time and its not efficient

  3. Polling for DNS server changes

    It's definitely going to take lots of time and its not efficient

  4. Using ip-address

    Even though it won't take much time depending on the network connection it may vary

My conclusion:

So far all the solutions I found are either not efficient or not so reliable.

My questions:

If VPN is connected in android device then android OS must be aware of it.

Are there any public android framework APIs to read it because finding it locally is most efficient and reliable solution ?

Are there any other efficient and reliable ways to achieve it (like integrating a C or C plus plus library with NDK)?

Note:

I couldn't find any custom broadcast senders/AIDL from OpenVPN for Android as well

like image 800
Durai Amuthan.H Avatar asked Jul 21 '14 08:07

Durai Amuthan.H


People also ask

What is a VPN status?

A Virtual Private Network (VPN) is used to establish an encrypted connection over a less secure network. VPN ensures the appropriate level of security to the connected systems when the underlying network infrastructure alone cannot provide it.

How do I find my VPN using CMD?

You can run the command "vpncli.exe" from the command prompt, this will tell you whether the VPN is connected or disconnected. Cisco AnyConnect Secure Mobility Client (version 4.7.

How do I test my AWS VPN?

To test the connection from AWS to your on-premises network, you can use SSH or RDP to connect to your instance from your network. You can then run the ping command with the private IP address of another computer in your network, to verify that both sides of the connection can initiate and receive requests.


1 Answers

Have you used - VpnService

As per documentation -

Prepare to establish a VPN connection. This method returns 'null' if the VPN application 
is 'already prepared'.

From here-

http://developer.android.com/reference/android/net/VpnService.html#prepare(android.content.Context)

 Intent intent = VpnService.prepare(getApplicationContext());
  if (intent == null) {
    // this means there is already a prepared VPN connection
  }
like image 191
Ninad Pingale Avatar answered Sep 18 '22 06:09

Ninad Pingale