From d944d2b827ea15df6dff749bbbc20321cee863ba Mon Sep 17 00:00:00 2001 From: Ruakij Date: Fri, 31 Mar 2023 17:55:03 +0200 Subject: [PATCH] Write to index instead of append --- cmd/app/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/app/main.go b/cmd/app/main.go index bd0c6d4..168233b 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -79,7 +79,7 @@ func main() { var wgConfig wgtypes.Config wgConfig.Peers = make([]wgtypes.PeerConfig, len(wgDevice.Peers)) - for _, peer := range wgDevice.Peers { + for i, peer := range wgDevice.Peers { // Create slice with initial size of 2xAllowedIPs as the max we expect var allowedIPs = make([]net.IPNet, len(peer.AllowedIPs)*2) // Copy in all old entries @@ -102,7 +102,7 @@ func main() { } } - wgConfig.Peers = append(wgConfig.Peers, wgtypes.PeerConfig{AllowedIPs: allowedIPs}) + wgConfig.Peers[i] = wgtypes.PeerConfig{AllowedIPs: allowedIPs} } err = client.ConfigureDevice(iface, wgConfig)