mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-10 03:00:46 +08:00
Merge branch 'develop' into feature_v0.15.1_normalize_networks
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user