fixing egress omission in peers:

This commit is contained in:
afeiszli 2021-09-22 14:48:44 -04:00
parent c826b782ed
commit dad6097202

View file

@ -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")