From 14cee3a96d6a3c299423dc7866addda1aeac4404 Mon Sep 17 00:00:00 2001 From: worker-9 Date: Thu, 12 Aug 2021 13:11:34 -0400 Subject: [PATCH] allowed addition of manually added allowed ips --- netclient/server/grpc.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/netclient/server/grpc.go b/netclient/server/grpc.go index f26e9b26..8b997134 100644 --- a/netclient/server/grpc.go +++ b/netclient/server/grpc.go @@ -208,6 +208,16 @@ func GetPeers(macaddress string, network string, server string, dualstack bool, } var allowedips []net.IPNet 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" { hasGateway = true ranges := node.EgressGatewayRanges