简体   繁体   English

使用VpnService在Android 4.0中创建VPN

[英]Create VPN in android 4.0 using VpnService

I want to create a vpn connection like PPTP, IPSec, etc in android 4.0 platform. 我想在Android 4.0平台中创建VPN连接,例如PPTP,IPSec等。

Android 4.0 providers us a new class called VpnService, I've already check out the demo project ToyVpn, but I still got some problem. Android 4.0为我们提供了一个名为VpnService的新类,我已经检查了演示项目ToyVpn,但是仍然遇到了一些问题。

ToyVpn seems create a custom vpn implementation, we need to handle the details of the vpn connection. ToyVpn似乎创建了一个自定义的VPN实现,我们需要处理VPN连接的详细信息。

I just want to create vpn like system setting activity, so any one got some idea? 我只想创建类似系统设置活动的VPN,所以有人知道吗? please let me know... 请告诉我...

ps. ps。 In android 2.3 and early, we can use reflection to call system hidden class to create the vpn like system setting page. 在android 2.3及更早版本中,我们可以使用反射来调用系统隐藏类来创建类似vpn的系统设置页面。 But from android 4.0 it doesn't work any more. 但是从android 4.0起它不再起作用了。

Thanks! 谢谢! Ruochao 若超

I know it's been some time, but I've been fussing with this for a while now and thought I'd chime in for those who come across this. 我知道已经有一段时间了,但是我已经对此大惊小怪了一段时间,并认为我会喜欢那些遇到此问题的人。

Android has offered the VpnService class in the API for Android 4.0+. Android在Android 4.0以上版本的API中提供了VpnService类。 This class allows a user-land application (ie your app) to redirect DNS requests and requests matching defined Routes to a new TUN-like interface which is managed by your app. 此类允许用户域应用程序(即,您的应用程序)将DNS请求和与定义的路由匹配的请求重定向到由您的应用程序管理的新的类似TUN的接口。 This does not out-of-the-box implement encryption or anything we'd expect from a usual VPN. 这并没有开箱即用的实现加密功能,也不是我们希望从普通VPN中获得的任何功能。

There are variants available by others: 其他人可以使用以下变体:

Each of these projects use JNI to bridge the Android VpnService to an existing VPN solution ported to Android. 这些项目中的每一个都使用JNI将Android VpnService桥接到已移植到Android的现有VPN解决方案。

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

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