边缘节点IP支持IPV6

This commit is contained in:
GoEdgeLab
2021-06-07 10:02:07 +08:00
parent be58189af9
commit f3dd470d45
5 changed files with 53 additions and 26 deletions

View File

@@ -8,7 +8,7 @@ import (
"strings"
)
// 将IP转换为整型
// IP2Long 将IP转换为整型
// 注意IPv6没有顺序
func IP2Long(ip string) uint64 {
if len(ip) == 0 {
@@ -24,3 +24,8 @@ func IP2Long(ip string) uint64 {
}
return uint64(binary.BigEndian.Uint32(s.To4()))
}
// IsIPv6 判断是否为IPv6
func IsIPv6(ip string) bool {
return strings.Contains(ip, ":")
}