#wireguard #vpn #network-security #networking #linux-networking

defguard_wireguard_rs

A unified multi-platform high-level API for managing WireGuard interfaces

10 releases

0.4.2 Feb 8, 2024
0.4.1 Feb 5, 2024
0.4.0 Jan 25, 2024
0.3.2 Dec 19, 2023
0.2.3 Oct 16, 2023

#561 in Network programming

Download history 772/week @ 2024-07-22 803/week @ 2024-07-29 512/week @ 2024-08-05 523/week @ 2024-08-12 686/week @ 2024-08-19 743/week @ 2024-08-26 699/week @ 2024-09-02 691/week @ 2024-09-09 711/week @ 2024-09-16 685/week @ 2024-09-23 233/week @ 2024-09-30 361/week @ 2024-10-07 246/week @ 2024-10-14 168/week @ 2024-10-21 184/week @ 2024-10-28 226/week @ 2024-11-04

849 downloads per month
Used in 2 crates

Apache-2.0

165KB
4K SLoC

defguard

defguard_wireguard_rs is a multi-platform Rust library providing a unified high-level API for managing WireGuard interfaces using native OS kernel and userspace WireGuard protocol implementations. It can be used to create your own WireGuard™️ VPN servers or clients for secure and private networking.

It was developed as part of defguard security platform and used in the gateway/server as well as desktop client.

Supported platforms

  • Native OS Kernel: Linux, FreeBSD (and pfSense/OPNSense), Windows
  • Userspace using wireguard-go - Linux, macOS, FreeBSD

Unique features

  • Peer routing - see WGApi docs.
  • Configuring DNS resolver - see WGApi docs.
    • On FreeBSD network interfaces are managed using ioctl.
    • On Linux, handle network routing using netlink.
    • fwmark handling

Windows support

Please note that WireGuard needs to be installed on Windows with commands wg and wireguard available to be called from the command line.

Note on wireguard-go

If you intend to use the userspace WireGuard implementation you should note that currently the library assumes that the wireguard-go binary will be available at runtime. There are some sanity checks when instantiating the API, but installing it is outside the scope of this project.

Examples

Documentation

See the documentation for more information.

Community and Support

Find us on Matrix: #defguard:teonite.com

Contribution

Please review the Contributing guide for information on how to get started contributing to the project. You might also find our environment setup guide handy.

Legal

WireGuard is registered trademarks of Jason A. Donenfeld.

Dependencies

~0.6–2MB
~45K SLoC