tun2socks
tun2socks is designed to work with the NetworkExtension framework. It is based on the latest stable lwip with minimal modification.
Feature
The whole stack is based on GCD which is efficient and fast.
Only TCP protocol is supported.
All other protocols (UDP, ICMP, IGMP, …) will not be supported since they are stateless or can not be supported in NetworkExtension.
Usage
The overall structure of tun2socks:
╔═══════════════════════╗
║sourceAddress: X.X.X.X ║
║ sourcePort: XX ║ writeData(_:)
╚═══════════════════════╝ │
│ ┌──────────────┐
┌─────────────┐ ┌───────┐ ┌────────────┐ ┌──────▼──────┐ │TSTCPSocketDel│
│ Local ◀──▶ TUN ◀──▶ TSIPStack ◀──▶ TSTCPSocket ├─────▶egate.didReadD│
└─────────────┘ └───────┘ └────────────┘ └─────────────┘ │ ata() │
└──────────────┘
Fully documented API reference can be found here.
It is recommended to use swift package manager to integrate tun2socks.
Another alternative may be NEKit which uses tun2socks and provides many features to build a proxy app.
IPv6 support
As of now, IPv6 is not supported since lwip 1.4 does not support dual stack. IPv6 will be supported in the next major version of lwip.