wip: create/update/...

This commit is contained in:
Christoph Haas
2020-11-07 18:36:23 +01:00
parent ea65e6b43c
commit cc06019738
8 changed files with 164 additions and 195 deletions

View File

@@ -1,6 +1,9 @@
package common
import "net"
import (
"net"
"strings"
)
// BroadcastAddr returns the last address in the given network, or the broadcast address.
func BroadcastAddr(n *net.IPNet) net.IP {
@@ -35,3 +38,20 @@ func IsIPv6(address string) bool {
}
return ip.To4() == nil
}
func ParseIPList(lst string) []string {
ips := strings.Split(lst, ",")
validatedIPs := make([]string, 0, len(ips))
for i := range ips {
ips[i] = strings.TrimSpace(ips[i])
if ips[i] != "" {
validatedIPs = append(validatedIPs, ips[i])
}
}
return validatedIPs
}
func IPListToString(lst []string) string {
return strings.Join(lst, ", ")
}