|
|
|
@ -23,12 +23,16 @@ var configTemplate = template.Must(template.New("config").Funcs(template.FuncMap
|
|
|
|
|
return strings.Join(s, sep) |
|
|
|
|
}, |
|
|
|
|
}).Parse(`[Interface] |
|
|
|
|
{{if .Interface.Name}}# Name: {{.Interface.Name}} |
|
|
|
|
{{end -}} |
|
|
|
|
Address = {{.Interface.Address}} |
|
|
|
|
PrivateKey = {{.Interface.PrivateKey}} |
|
|
|
|
ListenPort = {{.Interface.ListenPort}} |
|
|
|
|
{{- range .Peer }} |
|
|
|
|
|
|
|
|
|
[Peer] |
|
|
|
|
{{if .Name}}# Name: {{.Name}} |
|
|
|
|
{{end -}} |
|
|
|
|
PublicKey = {{.PublicKey}} |
|
|
|
|
Endpoint = {{.Endpoint}} |
|
|
|
|
AllowedIPs = {{ PrefixJoin .AllowedIPs ", "}} |
|
|
|
@ -64,6 +68,7 @@ func (f *Config) WriteTo(w io.Writer) (int64, error) {
|
|
|
|
|
|
|
|
|
|
// InterfaceConfig represents the [Interface] section
|
|
|
|
|
type InterfaceConfig struct { |
|
|
|
|
Name string |
|
|
|
|
Address netip.Addr |
|
|
|
|
PrivateKey PrivateKey |
|
|
|
|
ListenPort uint16 |
|
|
|
@ -71,6 +76,7 @@ type InterfaceConfig struct {
|
|
|
|
|
|
|
|
|
|
// PeerConfig represents a [Peer] section
|
|
|
|
|
type PeerConfig struct { |
|
|
|
|
Name string |
|
|
|
|
PublicKey PublicKey |
|
|
|
|
Endpoint EndpointAddress |
|
|
|
|
AllowedIPs []netip.Prefix |
|
|
|
|