简体   繁体   English

使用android vpnservice连接pptp vpn

[英]Connect pptp vpn with android vpnservice

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. 我正在尝试编写一个可以用pptp protocol连接到我的VPN服务器的应用程序,因为我正在研究我发现用android.net.vpnservice我可以连接,但是当我读到一些文档时,我不清楚如何连接到VPN (没有用于设置用户名或密码的API,也没有用于设置我的VPN类型的API( l2tp,pptp );我还测试了Google提供的示例应用程序(toyvpn),也没有我之前提到过的内容。

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;

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. 我也在尝试使用pptp和openvpn构建自己的VPN隧道/连接。

OpenVPN already has a solution. OpenVPN已经有了解决方案。

PPTP am trying the solution below. PPTP正在尝试以下解决方案。

How to programmatically create a new VPN interface with Android 4.0? 如何以编程方式创建Android 4.0的新VPN接口?

link above was found at 上面的链接被发现在

How to configure VPN programmatically? 如何以编程方式配置VPN?

i was trying the same. 我也在尝试。

For VPN Service u can do this. 对于VPN服务,您可以这样做。

 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/ http://doandroids.com/Apps/OneVpn/how-to/start-stop-prgrammatically/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM