Unverified Commit 2e5c9e5c authored by Manuel Buil's avatar Manuel Buil Committed by GitHub

Merge pull request #3916 from manuelbuil/net_v6

Add functions to separate ipv4 and ipv6 CIDRs
parents 34dfe629 96dcef47
......@@ -63,3 +63,25 @@ func GetFirst4String(elems []string) (string, error) {
}
return ip.String(), nil
}
// JoinIP4Nets stringifies and joins a list of IPv4 networks with commas.
func JoinIP4Nets(elems []*net.IPNet) string {
var strs []string
for _, elem := range elems {
if elem != nil && elem.IP.To4() != nil {
strs = append(strs, elem.String())
}
}
return strings.Join(strs, ",")
}
// JoinIP6Nets stringifies and joins a list of IPv6 networks with commas.
func JoinIP6Nets(elems []*net.IPNet) string {
var strs []string
for _, elem := range elems {
if elem != nil && elem.IP.To4() == nil {
strs = append(strs, elem.String())
}
}
return strings.Join(strs, ",")
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment