# vim: set ft=dosini:
[connection]
id={{ peer.interface }}
type=wireguard
interface-name={{ peer.interface }}

[wireguard]
listen-port={{ peer.port }}
private-key={{ peer.private_key }}
private-key-flags=0

{% if peer.address_ipv4 -%}
[ipv4]
address1={{ peer.address_ipv4 }}
method=manual
{% endif %}

{%- if peer.address_ipv6 %}
[ipv6]
address1={{ peer.address_ipv6 }}
method=manual
{% endif %}

{%- for connection in peer.connections %}
[wireguard-peer.{{ connection.peer_b.public_key }}]
{%- if connection.peer_b.endpoint_address %}
endpoint={{ connection.peer_b.endpoint_address }}:{{ connection.peer_b.port }}
{%- endif %}
preshared-key={{ connection.psk }}
preshared-key-flags=0
allowed-ips={% if connection.peer_b.address_ipv4 %}{{ connection.peer_b.address_ipv4 }}{% if connection.peer_b.address_ipv6 %};{% endif %}{% endif %}{%if connection.peer_b.address_ipv6 %}{{ connection.peer_b.address_ipv6 }}{% endif %}
{% endfor %}
