Add check if allowedIp already set
This commit is contained in:
parent
3ff87ca724
commit
e6edb6ae2b
@ -7,7 +7,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
envChecks "git.ruekov.eu/ruakij/routingtabletowg/lib/environmentchecks"
|
envChecks "git.ruekov.eu/ruakij/routingtabletowg/lib/environmentchecks"
|
||||||
|
"git.ruekov.eu/ruakij/routingtabletowg/lib/wgchecks/netchecks"
|
||||||
|
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
"golang.zx2c4.com/wireguard/wgctrl"
|
"golang.zx2c4.com/wireguard/wgctrl"
|
||||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
"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)
|
logger.Warn.Printf("Couldnt parse IPv6 address %s of peer %s: %s", ipv6Address, peer.PublicKey, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if already set
|
||||||
|
if i, _ := netchecks.IPNetIndexByIPNet(&peer.AllowedIPs, ipv6); i != -1 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Add the IPv6 allowed-ip to the peer
|
// Add the IPv6 allowed-ip to the peer
|
||||||
allowedIPs = append(allowedIPs, *ipv6)
|
allowedIPs = append(allowedIPs, *ipv6)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user