27

I'm trying to write an application that could connect to my VPN server with pptp protocol , as i was researching I found out that with android.net.vpnservice I could connect, but as I read some of documentation it was not clear how to connect to VPN (there were no API to set username or password, and also no API to set my VPN type(l2tp,pptp); I also tested example application Google provided(toyvpn) and there were none of what I mentioned earlier there too.

Here is some code I found :

// Create a new interface using the builder and save the parameters.
mInterface = builder.setSession(mServerAddress)
                .setConfigureIntent(mConfigureIntent)
                .establish();
mParameters = parameters;
Brendan
  • 1,237
  • 1
  • 16
  • 34
Duke
  • 1,731
  • 2
  • 17
  • 33
  • 1
    no actually there is no solution at all. – Duke Oct 31 '12 at 11:32
  • You need to implement the PPTP protocol yourself. I myself is currently looking into this as I have a working VPN/PPTP connection working for 2.x and want it working for 4.x as well. Try looking at the source code for Hideman - they are doing it :) – slott Jul 01 '13 at 15:34
  • 1.hide man is not a open source project . 2.i decided to use openvpn it is already implemented for android 4 – Duke Jul 01 '13 at 17:47
  • I reckon it is possible depend on kernel version and build option for kernel. – tknv Jan 20 '14 at 21:00
  • @tknv how it is possible? – jameshwart lopez Aug 28 '15 at 09:36
  • @jameshwart lopez about application - I did not research API well, but if no API, I think application could try bash shell even java application(android application). about android OS - the kernel should build with CONFIG_L2TP or CONFIG_PPTP as well. Otherwise I think need to implement L2TP or PPTP client himself at android application and also need to build L2TP or PPTP kernel module for loading when his application running. – tknv Aug 30 '15 at 05:13

2 Answers2

5

Hi this is a bit late but I have found something while searching.

I am also trying to build my own VPN tunnel / connection with using pptp and openvpn.

OpenVPN already has a solution.

PPTP am trying the solution below.

How to programmatically create a new VPN interface with Android 4.0?

link above was found at

How to configure VPN programmatically?

Community
  • 1
  • 1
RGAT
  • 486
  • 3
  • 13
  • what does the openvpn solution look like? Are you referring to intents to start / stop openvpn connections? – ashiaka Jul 24 '14 at 06:42
2

i was trying the same.

For VPN Service u can do this.

 void startVPN(String name) {
   Intent i=new Intent("doenter.onevpn.ACTION_CONNECT");
   i.putExtra("name",name);
   i.putExtra("force", true); 
   i.putExtra("force_same", false); 
   startActivity(i);
      }

    void restartVPN(String name) {
      Intent i=new Intent("doenter.onevpn.ACTION_CONNECT");
     i.putExtra("name",name);
     i.putExtra("force", true); 
     i.putExtra("force_same", true); 
     startActivity(i);
  }

  void stopVPN() {
   Intent i=new Intent("doenter.onevpn.ACTION_DISCONNECT");
   // Stops any VPN regardless of name
    startActivity(i);
     } 

This Link can help you to get your Answer.

http://doandroids.com/Apps/OneVpn/how-to/start-stop-prgrammatically/

Nayan Rath
  • 293
  • 5
  • 18