/go-tun2socks

A tun2socks implementation written in Go.

Primary LanguageCMIT LicenseMIT

go-tun2socks

The purpose of this fork(https://github.com/LaiZhou/go-tun2socks):

  • add tun device example in cmd/tun2socks/main.go, you can test it by:
curl --interface tun1 -v https://www.google.com

remind to replace the socks5 server host and port, default 127.0.0.1:1080 with no auth.

  • add socks5 client auth support.

  • add local udp support, routing the traffic to local ethernet.

Build Status

A tun2socks implementation written in Go.

If you're looking for an easy to use tun2socks implementation for iOS, you might be interested in leaf and ileaf. leaf implements tun2socks and it's written in Rust, with significantly less memory usage and significantly better performance compares to the Go version.

To run the tun2socks command line program, depending on OS, you may need to run it as root, create the TUN interface and/or configure IP address of the interface manually. Moreover, you should add corresponding routes to the routing table manually. Mind that you often want to use some different system DNS resolvers, and your proxy server should support UDP.

To use go-tun2socks as a library in your own project, refer to the following files/repos for some ideas:

It's recommended to write your own SOCKS layer. For example, you can create a "tun2shadowsocks" program by implementing a Shadowsocks handler, see https://github.com/Jigsaw-Code/outline-go-tun2socks/tree/master/shadowsocks

It's also recommended to write your own TUN layer to connect the TUN interface and go-tun2socks, see https://github.com/eycorsican/go-tun2socks/tree/master/tun for examples.

The following projects are using go-tun2socks: