6 releases

new 0.1.8 Mar 5, 2025
0.1.6 Feb 5, 2025
0.1.5 Nov 20, 2024
0.1.4 Mar 14, 2024
0.1.0 Jun 5, 2023

#975 in Network programming

Download history 149/week @ 2024-11-18 94/week @ 2024-12-02 142/week @ 2024-12-09 10/week @ 2024-12-16 3/week @ 2024-12-23 6/week @ 2025-01-06 5/week @ 2025-01-13 135/week @ 2025-02-03 9/week @ 2025-02-10 2/week @ 2025-02-17 1/week @ 2025-02-24 280/week @ 2025-03-03

298 downloads per month

MIT license

3MB
72K SLoC

C 72K SLoC // 0.2% comments GNU Style Assembly 289 SLoC // 0.3% comments Rust 251 SLoC // 0.0% comments Shell 171 SLoC // 0.0% comments

Tun2Socks

Rust bindings for HevSocks5Tunnel

Features

  • IPv4/IPv6. (dual stack)
  • Redirect TCP connections.
  • Redirect UDP packets. (Fullcone NAT, UDP in UDP/TCP)
  • Linux/Android/FreeBSD/macOS/iOS.

Benchmarks

See here for more details.

Speed

CPU usage

Memory usage

API

/// Start and run the socks5 tunnel, this function will blocks until the
/// quit() is called or an error occurs.
///
/// # Arguments
///
/// * `config_path` - config file path
/// * `tun_fd` - tunnel file descriptor
///
/// # Returns
///
/// Returns Ok(()) on successful, otherwise returns Err(r).
pub fn main_from_file(config_path: &Path, tun_fd: RawFd) -> Result<(), i32>

/// Start and run the socks5 tunnel, this function will blocks until the
/// quit() is called or an error occurs.
///
/// # Arguments
///
/// * `config_str` - config string
/// * `tun_fd` - tunnel file descriptor
///
/// # Returns
///
/// Returns Ok(()) on successful, otherwise returns Err(r).
pub fn main_from_str(config_str: &str, tun_fd: RawFd) -> Result<(), i32>

/// Stop the socks5 tunnel.
pub fn quit()

Contributors

License

MIT

No runtime deps