9 releases

0.3.1 Apr 29, 2023
0.3.0 Apr 28, 2023
0.2.5 Jun 14, 2022
0.2.4 Mar 23, 2020
0.1.1 Mar 9, 2020

#985 in Network programming

Download history 3/week @ 2023-12-08 6/week @ 2023-12-15 18/week @ 2024-02-16 27/week @ 2024-02-23 29/week @ 2024-03-01 12/week @ 2024-03-08 3/week @ 2024-03-15 4/week @ 2024-03-22

51 downloads per month

MIT license

21KB
279 lines

Universal Tun/Tap for Rust

Crates.io

This library aims to provide robust, well-tested, unified APIs to open Tun/Tap devices on different OSes. It is runtime-agnostic so that you can create your cross-platform wrappers for Tokio, async-std and so on.

Usage

It simply provides options to open Tun/Tap device files. More options are listed in the documentation.

use utuntap::tun;


let (mut file, filename) = tun::OpenOptions::new()
    .packet_info(false) // Only available on Linux
    .open(10)
    .expect("failed to open device");

Support Platforms

OS CI Status Comment
Linux Build Status musl is also supported.
OpenBSD builds.sr.ht status According to the manual, each packet read or written is prefixed with a tunnel header consisting of a 4-byte network byte order integer containing the address family. The values are listed here.
macOS TUN-only A 4-byte address family prefixed is required by read and write: [0u8, 0, 0, 2] for IPv4; [0u8, 0, 0, 10] for IPv6.

Dependencies

~0.4–410KB