https://github.com/dosgo/go-tun2socks
A tun2socks implementation written in Go.
https://github.com/dosgo/go-tun2socks
Last synced: 5 months ago
JSON representation
A tun2socks implementation written in Go.
- Host: GitHub
- URL: https://github.com/dosgo/go-tun2socks
- Owner: dosgo
- License: mit
- Created: 2020-06-27T14:46:19.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-07-28T07:56:45.000Z (almost 2 years ago)
- Last Synced: 2024-07-28T09:04:34.146Z (almost 2 years ago)
- Language: Go
- Homepage:
- Size: 19.9 MB
- Stars: 21
- Watchers: 4
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tun2socks
A high-performance tun2socks implementation written in Go, powered by gVisor netstack.
# Usage
### Standard TUN Device
You can start a standard TUN device and proxy all traffic to a SOCKS5 server:
```go
var tunDevice = "tun0";
var tunAddr = "10.0.0.2";
var tunMask = "255.255.255.0";
var tunGw = "10.0.0.1";
var mtu = 1500;
var socksAddr = "127.0.0.1:1080";
var tunDns = "8.8.8.8:53";
tun2socks.StartTunDevice(tunDevice, tunAddr, tunMask, tunGw, mtu, socksAddr, tunDns);
```
### Custom I/O (e.g., Android VpnService)
For environments like Android where you already have a File Descriptor or a custom stream, use the ForwardTransportFromIo interface:
// dev is an object that implements io.ReadWriteCloser
tun2socks.ForwardTransportFromIo(dev, mtu, rawTcpForwarder, rawUdpForwarder);
# Thank
* github.com/google/gvisor
* github.com/miekg/dns