首页 文章

使用android vpnservice连接pptp vpn

提问于
浏览
25

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

这是我发现的一些代码:

// Create a new interface using the builder and save the parameters.
mInterface = builder.setSession(mServerAddress)
                .setConfigureIntent(mConfigureIntent)
                .establish();
mParameters = parameters;

2 回答

  • 5

    嗨,这有点晚了,但我在搜索时发现了一些东西 .

    我也在尝试使用pptp和openvpn构建自己的VPN隧道/连接 .

    OpenVPN已经有了解决方案 .

    PPTP正在尝试以下解决方案 .

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

    上面的链接被发现在

    How to configure VPN programmatically?

  • 3

    我也在尝试 .

    对于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);
         }
    

    此链接可以帮助您获得答案 .

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

相关问题