# - server : {{ server.name }}
# - client : {{ client.name }}
# - private: {{ client.priv }}
# - public : {{ client.pub }}
{% if client.android and server.udp2raw %}

# actual_endpoint {{ server.ip }}
# wgquick_path    {{ client.wgquick_path }}
# udp2raw_path    {{ client.udp2raw_path }}
# udp2raw_port    {{ server.udp2raw.port }}
# udp2raw_pass    {{ server.udp2raw.secret }}
{% endif %}

[Interface]
Address = {{ client.ip }}/32
PrivateKey = {{ client.priv }}
MTU = {{ server.mtu }}
{% if client.bind %}

PostUp = mkdir -p "/tmp/bind"
PostUp = echo 'zone "." { type forward; forwarders { {{ server.internal_ip }}; }; };' > '/tmp/bind/named.conf.local'
PostUp = rndc reload

PreDown = mkdir -p "/tmp/bind"
PreDown = echo 'zone "." { type hint; file "{{ client.root_zone_file }}"; };' > "/tmp/bind/named.conf.local"
PreDown = rndc reload
{% endif %}
{% if client.wg_handled_dns %}
DNS = {{ server.internal_ip }}
{% endif %}
{% if server.udp2raw and not client.android %}

PreUp = ip route add {{ server.ip }} via `ip route list match 0 table all scope global | awk '{print $3}'` dev `ip route list match 0 table all scope global | awk '{print $5}'`
PreUp = udp2raw -c -l 127.0.0.1:50001 -r {{ server.ip }}:{{ server.udp2raw.port }} -k "{{ server.udp2raw.secret }}" -a >"{{ client.udp2raw_log_path }}" 2>&1 &
PostDown = ip route del {{ server.ip }} via `ip route list match 0 table all scope global | awk '{print $3}'` dev `ip route list match 0 table all scope global | awk '{print $5}'`
PostDown = pkill -15 udp2raw || true
{% endif %}

[Peer]
PublicKey = {{ server.pub }}
{% if server.udp2raw %}
Endpoint = 127.0.0.1:50001
{% else %}
Endpoint = {{ server.ip }}:{{ server.port }}
{% endif %}
AllowedIPs = 0.0.0.0/0{{ client.client_extra_allowed_str }}
{% if server.udp2raw %}
PersistentKeepalive = 120
{% else %}
PersistentKeepalive = 25
{% endif %}
