russdill / tunsocks

User-level IP forwarding, SOCKS proxy, and HTTP proxy for VPNs that provide tun-like interface
321 stars 67 forks source link

Using as a local VPN for Android #17

Open JonForShort opened 3 years ago

JonForShort commented 3 years ago

Hi, thanks for the project. Do you know if there is a way to use this for creating a local VPN service on Android?

Just to give a bit of background, the way VPN services work on Android is that the application receives a file descriptor that is attached to the devices TUN interface. When the Android application reads from this file descriptor, it gets all the outgoing packets for the device. These packets are raw IP layer-3 packets (including IP header). It is up to the app to figure out how to send these raw IP packets. When the Android application writes to the file descriptor, the system passes these packets back to the device and to the original sending application. These packets also need to be formatted as raw IP packets.

I was looking through the source code and the socks functionality looks like it is what I need but I wasn't sure.

Thanks!