go-waku/waku/v2/utils/ip.go

17 lines
257 B
Go

package utils
import (
"net"
"strings"
)
func IsIPv4(str string) bool {
ip := net.ParseIP(str)
return ip != nil && !strings.Contains(str, ":")
}
func IsIPv6(str string) bool {
ip := net.ParseIP(str)
return ip != nil && strings.Contains(str, ":")
}