mirror of
https://git.vectorsigma.ru/public/k3s.git
synced 2026-08-06 19:19:54 +00:00
Add functions to separate ipv4 from ipv6 functions
Signed-off-by: Manuel Buil <mbuil@suse.com>
This commit is contained in:
@@ -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, ",")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user