Android: it is not possible to connect to the VPN server through the ToyVpn application; port exception not available

I am trying to create a VPN client on Android. I looked at the ToyVpn android application, I tried to connect to my PC (Windows 7) from this application, but I get a port exception that is not available.

E/ToyVpnService(2302): Got java.net.PortUnreachableException: E/ToyVpnService(2302): Got java.net.SocketException: sendto failed: ECONNREFUSED (Connection refused) 

But when I connect to my computer through the default vpn client for vpn for Android, it connects successfully. And by typing "netstat" on the command line, I noticed that my PC port 1723 is connected to telephone port 36302. Thus, the output port is available.

This is an example application, it should work ... But I saw some other links that mentioned that they cannot connect to the server through this application.

Does this sample work at all? Is this root phone API needed?

Other than that, I did not find a single example or tutorial to show the correct use of "android.net.VpnService".

Can anyone advise me on this ..?

+4
source share
1 answer

ToyVpnService is an example implementation of a simple custom VPN. This is not up to standard. If you want a standards-compliant VPN, you should use the built-in one.

If you want to test the sample, there is a linux server that understands the ToyVPN protocol, which is packaged with the ToyVPN example.

https://github.com/android/platform_development/tree/master/samples/ToyVpn

This is called ToyVPN because it is simple.

  • It does not encrypt
  • No mutual authentication
  • It sends a pre-shared authentication key in plain text
  • He does not know how to handle unexpected packets.
  • It does not guarantee the integrity or origin of packages.

It only shows how the VpnService API can grab packets from an application on a phone designed for the Internet and push them through the tunnel. Similarly, how to enter packets into the application, as if they were coming from the network.

The rest is a developer for implementation.

+8
source

Source: https://habr.com/ru/post/1443656/


All Articles