Merge branch 'develop' into feature_v0.15.1_normalize_networks

This commit is contained in:
Matthew R Kasun
2022-09-07 06:57:14 -04:00
committed by GitHub
21 changed files with 1296 additions and 115 deletions

View File

@@ -171,6 +171,7 @@ func ShouldPublishPeerPorts(serverNode *models.Node) bool {
return false
}
// NormalCidr - returns the first address of CIDR
func NormalizeCIDR(address string) (string, error) {
ip, IPNet, err := net.ParseCIDR(address)
@@ -185,4 +186,20 @@ func NormalizeCIDR(address string) (string, error) {
IPNet.IP = net4.NetworkAddress()
}
return IPNet.String(), nil
func getNetworkProtocols(cidrs []string) (bool, bool) {
ipv4 := false
ipv6 := false
for _, cidr := range cidrs {
ip, _, err := net.ParseCIDR(cidr)
if err != nil {
continue
}
if ip.To4() == nil {
ipv6 = true
} else {
ipv4 = true
}
}
return ipv4, ipv6
}