diff --git a/add.go b/add.go index 736fb9b..711113e 100644 --- a/add.go +++ b/add.go @@ -19,7 +19,11 @@ DNS={{ .DsnetConfig.DNS }} [Peer] PublicKey={{ .DsnetConfig.PrivateKey.PublicKey.Key }} PresharedKey={{ .Peer.PresharedKey.Key }} +{{ if gt (.DsnetConfig.ExternalIP | len) 0 -}} Endpoint={{ .DsnetConfig.ExternalIP }}:{{ .DsnetConfig.ListenPort }} +{{ else -}} +Endpoint={{ .DsnetConfig.ExternalIP6 }}:{{ .DsnetConfig.ListenPort }} +{{ end -}} PersistentKeepalive={{ .Keepalive }} {{ with .DsnetConfig.Network -}} AllowedIPs={{ . }} diff --git a/configtypes.go b/configtypes.go index 21096d1..5688c08 100644 --- a/configtypes.go +++ b/configtypes.go @@ -36,7 +36,7 @@ type PeerConfig struct { type DsnetConfig struct { // domain to append to hostnames. Relies on separate DNS server for // resolution. Informational only. - ExternalIP net.IP `validate:"required"` + ExternalIP net.IP ExternalIP6 net.IP ListenPort int `validate:"gte=1024,lte=65535"` Domain string `validate:"required,gte=1,lte=255"`