mirror of
https://github.com/status-im/go-waku.git
synced 2025-01-12 23:04:45 +00:00
bc06867cc9
* chore: add tests for utils * chore:delete unused code * fix: ipv6 validation issue
19 lines
340 B
Go
19 lines
340 B
Go
package utils
|
|
|
|
import (
|
|
"net"
|
|
"strings"
|
|
)
|
|
|
|
// IsIPv4 validates if string is a valid IPV4 address
|
|
func IsIPv4(str string) bool {
|
|
ip := net.ParseIP(str).To4()
|
|
return ip != nil
|
|
}
|
|
|
|
// IsIPv6 validates if string is a valid IPV6 address
|
|
func IsIPv6(str string) bool {
|
|
ip := net.ParseIP(str)
|
|
return ip != nil && strings.Contains(str, ":")
|
|
}
|