mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-19 19:59:13 +03:00

PresharedKey is now only set in the server and client config if the key is set and not null (or empty). I added this feature because I was importing old config files from clients that did not have a preshared key set. Clients can be created without preshared keys when editing db/client/ files manually. If the field is not set, wireguard-ui creates invalid configs by producing: PresharedKey = This patch remvoes this behavior and just skips the preshared key if not set. Co-authored-by: Khanh Ngo <k@ndk.name>
24 lines
1.2 KiB
Text
24 lines
1.2 KiB
Text
# 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}}
|
|
PostUp = {{ .serverConfig.Interface.PostUp }}
|
|
PostDown = {{ .serverConfig.Interface.PostDown }}
|
|
|
|
{{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}}
|