Browse Source

fixing egress omission in peers:

afeiszli 3 years ago
parent
commit
dad6097202
1 changed files with 7 additions and 3 deletions
  1. 7 3
      netclient/server/grpc.go

+ 7 - 3
netclient/server/grpc.go

@@ -214,11 +214,15 @@ func GetPeers(macaddress string, network string, server string, dualstack bool,
 					ncutils.PrintLog("could not parse gateway IP range. Not adding "+iprange, 1)
 					continue // if can't parse CIDR
 				}
-				nodeEndpointArr := strings.Split(nodecfg.Endpoint, ":") // getting the public ip of node
-				if ipnet.Contains(net.IP(nodeEndpointArr[0])) {         // ensuring egress gateway range does not contain public ip of node
-					ncutils.PrintLog("egress IP range of "+iprange+" overlaps with "+nodecfg.Endpoint+", omitting", 1)
+				nodeEndpointArr := strings.Split(node.Endpoint, ":") // getting the public ip of node
+				if ipnet.Contains(net.ParseIP(nodeEndpointArr[0])) {         // ensuring egress gateway range does not contain public ip of node
+					ncutils.PrintLog("egress IP range of "+iprange+" overlaps with "+node.Endpoint+", omitting", 2)
 					continue // skip adding egress range if overlaps with node's ip
 				}
+				if ipnet.Contains(net.ParseIP(nodecfg.LocalAddress)) {         // ensuring egress gateway range does not contain public ip of node
+					ncutils.PrintLog("egress IP range of "+iprange+" overlaps with "+nodecfg.LocalAddress+", omitting", 2)
+					continue // skip adding egress range if overlaps with node's local ip
+				}
 				gateways = append(gateways, iprange)
 				if err != nil {
 					log.Println("ERROR ENCOUNTERED SETTING GATEWAY")