From ddb0b4c54952d1bef68079f624c8b09b2e45657e Mon Sep 17 00:00:00 2001 From: Callan Bryant Date: Tue, 27 Oct 2020 21:03:45 +0000 Subject: [PATCH] conditional IPv4/6 and fix vyatta --- add.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/add.go b/add.go index 0bd7d04..554cdae 100644 --- a/add.go +++ b/add.go @@ -8,8 +8,12 @@ import ( ) const wgQuickPeerConf = `[Interface] +{{ if gt (.DsnetConfig.Network.IPNet.IP | len) 0 -}} Address={{ .Peer.IP }}/{{ .CidrSize }} +{{ end -}} +{{ if gt (.DsnetConfig.Network6.IPNet.IP | len) 0 -}} Address={{ .Peer.IP6 }}/{{ .CidrSize6 }} +{{ end -}} PrivateKey={{ .Peer.PrivateKey.Key }} {{- if .DsnetConfig.DNS }} DNS={{ .DsnetConfig.DNS }} @@ -37,11 +41,15 @@ AllowedIPs={{ . }} // TODO use random wg0-wg999 to hopefully avoid conflict by default? const vyattaPeerConf = `configure +{{ if gt (.DsnetConfig.Network.IPNet.IP | len) 0 -}} set interfaces wireguard wg0 address {{ .Peer.IP }}/{{ .CidrSize }} +{{ end -}} +{{ if gt (.DsnetConfig.Network6.IPNet.IP | len) 0 -}} set interfaces wireguard wg0 address {{ .Peer.IP6 }}/{{ .CidrSize6 }} +{{ end -}} set interfaces wireguard wg0 route-allowed-ips true set interfaces wireguard wg0 private-key {{ .Peer.PrivateKey.Key }} -set interfaces wireguard wg0 description {{ conf.InterfaceName }} +set interfaces wireguard wg0 description {{ .DsnetConfig.InterfaceName }} {{- if .DsnetConfig.DNS }} #set service dns forwarding name-server {{ .DsnetConfig.DNS }} {{ end }}