use keepalive const in template

This commit is contained in:
Callan Bryant 2020-03-07 14:36:14 +00:00
parent 75549f2ab7
commit 5f735112f2
No known key found for this signature in database
GPG Key ID: C31FA9DF3ACBFFAA

4
add.go
View File

@ -3,6 +3,7 @@ package dsnet
import ( import (
"fmt" "fmt"
"os" "os"
"time"
"text/template" "text/template"
) )
@ -59,13 +60,14 @@ PresharedKey={{ .Peer.PresharedKey.Key }}
Endpoint={{ .DsnetConfig.ExternalIP }}:{{ .DsnetConfig.ListenPort }} Endpoint={{ .DsnetConfig.ExternalIP }}:{{ .DsnetConfig.ListenPort }}
#AllowedIPs=0.0.0.0/0 #AllowedIPs=0.0.0.0/0
AllowedIPs={{ .DsnetConfig.Network }} AllowedIPs={{ .DsnetConfig.Network }}
PersistentKeepalive=21 PersistentKeepalive={{ .Keepalive }}
` `
t := template.Must(template.New("peerConf").Parse(peerConf)) t := template.Must(template.New("peerConf").Parse(peerConf))
err := t.Execute(os.Stdout, map[string]interface{}{ err := t.Execute(os.Stdout, map[string]interface{}{
"Peer": peer, "Peer": peer,
"DsnetConfig": conf, "DsnetConfig": conf,
"Keepalive": time.Duration(KEEPALIVE).Seconds(),
}) })
check(err) check(err)
} }