13 stable releases (3 major)

3.0.0 Apr 23, 2023
3.0.0-rc1 Jan 14, 2023
2.0.5 May 6, 2022
2.0.2 Dec 25, 2021
0.2.0 Oct 3, 2019

#1113 in Network programming

Download history 6855/week @ 2024-07-24 6898/week @ 2024-07-31 9023/week @ 2024-08-07 6209/week @ 2024-08-14 7003/week @ 2024-08-21 5255/week @ 2024-08-28 6869/week @ 2024-09-04 6823/week @ 2024-09-11 6569/week @ 2024-09-18 7351/week @ 2024-09-25 7379/week @ 2024-10-02 8986/week @ 2024-10-09 9506/week @ 2024-10-16 9676/week @ 2024-10-23 6058/week @ 2024-10-30 6472/week @ 2024-11-06

32,899 downloads per month
Used in wireguard-p2p

MIT license

145KB
3K SLoC

wireguard-uapi-rs

Build Status codecov Crates version docs.rs MIT

This library implements the WireGuard Netlink API in Rust for Linux.

  • If you're just reading a WireGuard device interface, this library fully supports that functionality.
  • If you're creating new WireGuard device interfaces, this library has partial support. Creating and deleting device interfaces is possible, but there's no ability at the moment for adding IP addresses to those devices.

Here's a quick example.

use failure;
use wireguard_uapi::{DeviceInterface, WgSocket};

fn main() -> Result<(), failure::Error> {
  let mut wg = WgSocket::connect()?;
  let device = wg.get_device(DeviceInterface::from_name("wgtest0"))?;

  print_device(&device);
  Ok(())
}

Permissions

Compiled binaries need the CAP_NET_ADMIN capability to read network interfaces. If you're getting an access error while using this library, make sure the compiled executable has that permission. If you trust your compiled binary, one way to grant it is:

sudo setcap CAP_NET_ADMIN=+eip ./my-compiled-binary

Disclaimer

This isn't an official WireGuard product. (Although I'm interested in making it so.)

Feel free to file bugs.

Dependencies

~0.8–1.4MB
~29K SLoC