From e6edb6ae2bd7af344a82c61a7219362848d03f8a Mon Sep 17 00:00:00 2001 From: Ruakij Date: Fri, 31 Mar 2023 19:59:17 +0200 Subject: [PATCH] Add check if allowedIp already set --- cmd/app/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/app/main.go b/cmd/app/main.go index dd8d603..fd3c3c2 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -7,7 +7,8 @@ import ( "time" envChecks "git.ruekov.eu/ruakij/routingtabletowg/lib/environmentchecks" - + "git.ruekov.eu/ruakij/routingtabletowg/lib/wgchecks/netchecks" + "github.com/vishvananda/netlink" "golang.zx2c4.com/wireguard/wgctrl" "golang.zx2c4.com/wireguard/wgctrl/wgtypes" @@ -96,6 +97,11 @@ func main() { logger.Warn.Printf("Couldnt parse IPv6 address %s of peer %s: %s", ipv6Address, peer.PublicKey, err) continue } + + // Check if already set + if i, _ := netchecks.IPNetIndexByIPNet(&peer.AllowedIPs, ipv6); i != -1 { + continue + } // Add the IPv6 allowed-ip to the peer allowedIPs = append(allowedIPs, *ipv6)