View Source Wireguardex.PeerConfigBuilder (Wireguardex v0.3.4)

This module contains functions to create a PeerConfig which represents a peer's configuration of persistent attributes. They do not change over time and are part of the configuration of a device.

To create the defualt config use peer_config/0 then you can apply each function in this module to specify the config.

examples

Examples

iex> {:ok, public_key} = Wireguardex.get_public_key(Wireguardex.generate_private_key())
...> res =
...> device_config()
...> |> peers([
...>   peer_config()
...>   |> Wireguardex.PeerConfigBuilder.public_key(public_key)
...>   |> endpoint("127.0.0.1:1234")
...>   |> preshared_key(Wireguardex.generate_preshared_key())
...>   |> persistent_keepalive_interval(60)
...>   |> allowed_ips(["127.0.0.1/16"])
...> ])
...> |> Wireguardex.set_device("wg12345")
...> Wireguardex.delete_device("wg12345")
...> res
:ok

Link to this section Summary

Functions

The allowed ip addresses this peer is allowed to have.

The endpoint this peer listens for connections on (nil means any).

Creates the default peer configuration that you can then specify which each of the provided functions.

The interval for sending keepalive packets (nil means disabled).

The preshared key available to both peers (nil means no PSK is used).

The public key of the peer.

Link to this section Functions

Link to this function

allowed_ips(peer_config, allowed_ips)

View Source

The allowed ip addresses this peer is allowed to have.

Link to this function

endpoint(peer_config, endpoint)

View Source

The endpoint this peer listens for connections on (nil means any).

Creates the default peer configuration that you can then specify which each of the provided functions.

Link to this function

persistent_keepalive_interval(peer_config, persistent_keepalive_interval)

View Source

The interval for sending keepalive packets (nil means disabled).

Link to this function

preshared_key(peer_config, preshared_key)

View Source

The preshared key available to both peers (nil means no PSK is used).

Link to this function

public_key(peer_config, public_key)

View Source

The public key of the peer.