Browse Source

allowed addition of manually added allowed ips

worker-9 4 years ago
parent
commit
14cee3a96d
1 changed files with 10 additions and 0 deletions
  1. 10 0
      netclient/server/grpc.go

+ 10 - 0
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