Add check if allowedIp already set

dev
Ruakij 2 years ago
parent 3ff87ca724
commit e6edb6ae2b

@ -7,6 +7,7 @@ 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"
@ -97,6 +98,11 @@ func main() {
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)
}

Loading…
Cancel
Save