#wireguard #builder #config #networking #amnezia

wireguard-conf

Construct Wireguard's interface and peer configs

3 unstable releases

0.2.1 Mar 3, 2025
0.2.0 Mar 3, 2025
0.1.0 Feb 15, 2025

#16 in #wireguard

Download history 106/week @ 2025-02-11 16/week @ 2025-02-18 116/week @ 2025-02-25 164/week @ 2025-03-04 21/week @ 2025-03-11 1/week @ 2025-03-18

300 downloads per month

MIT license

26KB
465 lines

Wireguard Conf

Easy to use library for creating wireguard configs.

Installation

Install wireguard-conf and ipnet (for parsing ip networks)

cargo add wireguard-conf ipnet

Usage

More usage examples in tests and on docs.rs

use wireguard_conf::prelude::*;
use wireguard_conf::as_ipnet;

use ipnet::Ipv4Net;

// create peer:
let peer = PeerBuilder::new()
    .add_allowed_ip(as_ipnet!("10.0.0.2/24"))
    .build();

// create interface with that peer:
let interface = InterfaceBuilder::new()
    .address(as_ipnet!("10.0.0.1/24"))
    .add_peer(peer.clone())
    .build();

// to export configs, use `println!()`, `writeln!()`, `.to_string()`, etc.

println!("Server's config:");
println!("{}\n", interface);

println!("Client's config:");
println!("{}", peer.to_interface(&interface).unwrap());

Features

  • amneziawg: adds support for generating/using AmneziaWG obfuscation values.

Dependencies

~2–3.5MB
~69K SLoC