How to use VPN in Android? [closed]

陌路散爱 提交于 2019-12-01 04:09:47

问题


I am exploring VPN Connectivity in Android. I am new to this section.

  1. I want to know how to setup a VPN connection in Android using an application?

  2. I came across a sample code namely ToyVpn.I ran the application but i dont know what datas i need to give in the form shown by that application, Consider iam having a VPN server with IP address (say 10.162.1.2), what do I need to do in that application to make that app work?

  3. If I try to use any public VPN server, what do I need to do?

  4. I had downloaded Openvpn source from here and I compiled and ran in my ICS device, but i don't know how to configure the data that need to be entered. Please provide the exact way to use this app.


回答1:


I want to know how to setup a VPN connection in Android using an application?

The Android SDK comes bundled with a sample; see ToyVpn in the android-16 samples directory. Also consult the documentation for VpnService and VpnService.Builder.

I came across a sample code namely ToyVpn.I ran the application but i dont know what datas i need to give in the form shown by that application, Consider iam having a VPN server with ip-address (say 10.162.1.2), What i need to do in that application to make that app work .

Your VPN will need to create a new socket, protect the socket from being routed back into the VPN using VpnService.protect(Socket), and connect the socket to 10.162.1.2. Having set up a tunnel connection to the VPN server, you should proceed to writing the input stream of the VpnService's interface into the tunnel's output stream, and in turn write the tunnel response back into the interface output stream.

If i try to use any public VPN server, What i need to do?

There is no standard mechanism in place for setting up a connection to a VPN server. ToyVpn simply communicates over a socket using raw TCP packets. You can either implement an existing protocol (see RFC 4026) like OpenVPN has done or write something yourself.



来源:https://stackoverflow.com/questions/13233477/how-to-use-vpn-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!