allowed addition of manually added allowed ips

This commit is contained in:
worker-9 2021-08-12 13:11:34 -04:00
parent c87e39aa61
commit 14cee3a96d

View file

@ -208,6 +208,16 @@ func GetPeers(macaddress string, network string, server string, dualstack bool,
} }
var allowedips []net.IPNet var allowedips []net.IPNet
allowedips = append(allowedips, peeraddr) allowedips = append(allowedips, peeraddr)
// handle manually set peers
for _, allowedIp := range node.AllowedIPs {
if _, ipnet, err := net.ParseCIDR(allowedIp); err == nil {
nodeEndpointArr := strings.Split(node.Endpoint, ":")
if !ipnet.Contains(net.IP(nodeEndpointArr[0])) { // don't need to add an allowed ip that already exists..
allowedips = append(allowedips, *ipnet)
}
}
}
// handle egress gateway peers
if node.IsEgressGateway == "yes" { if node.IsEgressGateway == "yes" {
hasGateway = true hasGateway = true
ranges := node.EgressGatewayRanges ranges := node.EgressGatewayRanges