Wireguard exporter friendly tags (#81)

* add friendly name

* add friendly name as option to configuration

* add friendly name configuration to readme
This commit is contained in:
ultram4rine
2021-12-16 22:35:15 +04:00
committed by GitHub
parent acb629f672
commit e581b3a69f
6 changed files with 64 additions and 57 deletions

View File

@@ -338,12 +338,13 @@ func (d Device) GetConfig() wgtypes.Config {
return cfg
}
func (d Device) GetConfigFile(peers []Peer) ([]byte, error) {
func (d Device) GetConfigFile(peers []Peer, friendlyNames bool) ([]byte, error) {
var tplBuff bytes.Buffer
err := templateCache.ExecuteTemplate(&tplBuff, "interface.tpl", gin.H{
"Peers": peers,
"Interface": d,
"Peers": peers,
"Interface": d,
"FriendlyNames": friendlyNames,
})
if err != nil {
return nil, errors.Wrap(err, "failed to execute server template")

View File

@@ -56,6 +56,9 @@ PostDown = {{ .Interface.PostDown }}
# -WGP- PrivateKey: {{.PrivateKey}}
{{- end}}
[Peer]
{{- if $.FriendlyNames}}
# friendly_name = {{ .Identifier }}
{{- end}}
PublicKey = {{ .PublicKey }}
{{- if .PresharedKey}}
PresharedKey = {{ .PresharedKey }}
@@ -75,4 +78,4 @@ Endpoint = {{ .Endpoint }}
PersistentKeepalive = {{ .PersistentKeepalive }}
{{- end}}
{{- end}}
{{end}}
{{end}}