View Source Wireguardex (Wireguardex v0.1.0)

Wireguardex is an Elixir library for configuring WireGuard interfaces. It uses Rust NIFs for performance and safety.

This is the main module, providing the API for interface configuration and utilities such as key generation.

Link to this section Summary

Functions

Add a peer to a Device.

Delete a Device by its interface name.

Generates a random preshared key. It is returned as a base64 string.

Generates a random private key. It is returned as a base64 string.

Get a Device by its interface name.

Return a private key's public key as a base64 string.

Get a list of interfaces from wireguard.

Remove a peer from a Device by the peer's public key.

Set a Device by its interface name using a DeviceConfig.

Link to this section Functions

Add a peer to a Device.

Returns :ok if successful. {:error, error_info} will be returned if adding the peer to the device fails.

Delete a Device by its interface name.

Returns :ok if successful. {:error, error_info} will be returned if deleting the device fails.

Link to this function

generate_preshared_key()

View Source

Generates a random preshared key. It is returned as a base64 string.

Generates a random private key. It is returned as a base64 string.

Get a Device by its interface name.

Returns {:ok, Device} if successful. {:error, error_info} will be returned if getting the device fails.

Link to this function

get_public_key(private_key)

View Source

Return a private key's public key as a base64 string.

Get a list of interfaces from wireguard.

Returns {:ok, [...]} if successful. {:error, error_info} will be returned if listing the devices fails.

Link to this function

remove_peer(name, public_key)

View Source

Remove a peer from a Device by the peer's public key.

Returns :ok if successful. {:error, error_info} will be returned if removing the peer from the device fails.

Link to this function

set_device(name, device_config)

View Source

Set a Device by its interface name using a DeviceConfig.

Note if no device is present, a new one will be created for the given interface name.

Returns :ok if successful. {:error, error_info} will be returned if setting the device fails.