# This file was generated using wireguard-ui (https://github.com/ngoduykhanh/wireguard-ui)
# Please don't modify it manually, otherwise your change might get replaced.

# Address updated at:     {{ .serverConfig.Interface.UpdatedAt }}
# Private Key updated at: {{ .serverConfig.KeyPair.UpdatedAt }}
[Interface]
Address = {{$first :=true}}{{range .serverConfig.Interface.Addresses }}{{if $first}}{{$first = false}}{{else}},{{end}}{{.}}{{end}}
ListenPort = {{ .serverConfig.Interface.ListenPort }}
PrivateKey = {{ .serverConfig.KeyPair.PrivateKey }}
{{if .globalSettings.MTU}}MTU = {{ .globalSettings.MTU }}{{end}}
#This post-up / post-down comes from the config GUI
PostUp = {{ .serverConfig.Interface.PostUp }}
PostDown = {{ .serverConfig.Interface.PostDown }}
Table = {{ .globalSettings.Table }}

##Need to enable IP forwarding and proxy NDP (and ARP, if you're old school)
#PostUp = /bin/bash -c "echo 1 > /proc/sys/net/ipv4/conf/all/forwarding"
#PostUp = /bin/bash -c "echo 1 > /proc/sys/net/ipv4/conf/all/proxy_arp"
PostUp = /bin/bash -c "echo 1 > /proc/sys/net/ipv6/conf/all/forwarding"
PostUp = /bin/bash -c "echo 1 > /proc/sys/net/ipv6/conf/all/proxy_ndp"

## Configuration of ARP/NDP proxies for each client goes in the Interface section
#Note that the interface needs to be the one we are proxying on
#NOT the wireguard interface, so i've set it to eth1 in this example
#Replace with the actual interface you want to bridge to
#instead of %i (which Wireguard will replace with its own interface)
{{range .clientDataList}}{{if eq .Client.Enabled true}}
#ID: {{.Client.ID}} Name: {{.Client.Name}}
{{range .Client.AllocatedIPs}}#IP: {{.}}
PostUp = /bin/bash -c "ip neigh add proxy $(echo {{.}} | sed "s/\/.*//") dev eth1"
PostDown = /bin/bash -c "ip neigh del proxy $(echo {{.}} | sed "s/\/.*//") dev eth1"
{{end}}{{end}}{{end}}


## Clients Section has keys for each client
{{range .clientDataList}}{{if eq .Client.Enabled true}}
# ID:           {{ .Client.ID }}
# Name:         {{ .Client.Name }}
# Email:        {{ .Client.Email }}
# Created at:   {{ .Client.CreatedAt }}
# Update at:    {{ .Client.UpdatedAt }}
[Peer]
PublicKey = {{ .Client.PublicKey }}
{{if .Client.PresharedKey }}PresharedKey = {{ .Client.PresharedKey }}
{{end}}AllowedIPs = {{$first :=true}}{{range .Client.AllocatedIPs }}{{if $first}}{{$first = false}}{{else}},{{end}}{{.}}{{end}}{{range .Client.ExtraAllowedIPs }},{{.}}{{end}}
{{end}}{{end}}