wireguard: add support for optional Name comment
Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
@@ -23,12 +23,16 @@ var configTemplate = template.Must(template.New("config").Funcs(template.FuncMap
|
|||||||
return strings.Join(s, sep)
|
return strings.Join(s, sep)
|
||||||
},
|
},
|
||||||
}).Parse(`[Interface]
|
}).Parse(`[Interface]
|
||||||
|
{{if .Interface.Name}}# Name: {{.Interface.Name}}
|
||||||
|
{{end -}}
|
||||||
Address = {{.Interface.Address}}
|
Address = {{.Interface.Address}}
|
||||||
PrivateKey = {{.Interface.PrivateKey}}
|
PrivateKey = {{.Interface.PrivateKey}}
|
||||||
ListenPort = {{.Interface.ListenPort}}
|
ListenPort = {{.Interface.ListenPort}}
|
||||||
{{- range .Peer }}
|
{{- range .Peer }}
|
||||||
|
|
||||||
[Peer]
|
[Peer]
|
||||||
|
{{if .Name}}# Name: {{.Name}}
|
||||||
|
{{end -}}
|
||||||
PublicKey = {{.PublicKey}}
|
PublicKey = {{.PublicKey}}
|
||||||
Endpoint = {{.Endpoint}}
|
Endpoint = {{.Endpoint}}
|
||||||
AllowedIPs = {{ PrefixJoin .AllowedIPs ", "}}
|
AllowedIPs = {{ PrefixJoin .AllowedIPs ", "}}
|
||||||
@@ -64,6 +68,7 @@ func (f *Config) WriteTo(w io.Writer) (int64, error) {
|
|||||||
|
|
||||||
// InterfaceConfig represents the [Interface] section
|
// InterfaceConfig represents the [Interface] section
|
||||||
type InterfaceConfig struct {
|
type InterfaceConfig struct {
|
||||||
|
Name string
|
||||||
Address netip.Addr
|
Address netip.Addr
|
||||||
PrivateKey PrivateKey
|
PrivateKey PrivateKey
|
||||||
ListenPort uint16
|
ListenPort uint16
|
||||||
@@ -71,6 +76,7 @@ type InterfaceConfig struct {
|
|||||||
|
|
||||||
// PeerConfig represents a [Peer] section
|
// PeerConfig represents a [Peer] section
|
||||||
type PeerConfig struct {
|
type PeerConfig struct {
|
||||||
|
Name string
|
||||||
PublicKey PublicKey
|
PublicKey PublicKey
|
||||||
Endpoint EndpointAddress
|
Endpoint EndpointAddress
|
||||||
AllowedIPs []netip.Prefix
|
AllowedIPs []netip.Prefix
|
||||||
|
|||||||
Reference in New Issue
Block a user